aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs46
1 files changed, 15 insertions, 31 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 68a6c41..ec78fdc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -72,7 +72,8 @@ public class BSPrim : BSPhysObject
72 72
73 private int CrossingFailures { get; set; } 73 private int CrossingFailures { get; set; }
74 74
75 public BSDynamics VehicleController { get; private set; } 75 public BSDynamics VehicleActor;
76 public string VehicleActorName = "BasicVehicle";
76 77
77 private BSVMotor _targetMotor; 78 private BSVMotor _targetMotor;
78 private OMV.Vector3 _PIDTarget; 79 private OMV.Vector3 _PIDTarget;
@@ -100,11 +101,12 @@ public class BSPrim : BSPhysObject
100 _isPhysical = pisPhysical; 101 _isPhysical = pisPhysical;
101 _isVolumeDetect = false; 102 _isVolumeDetect = false;
102 103
103 VehicleController = new BSDynamics(PhysicsScene, this); // add vehicleness 104 VehicleActor = new BSDynamics(PhysicsScene, this, VehicleActorName);
105 PhysicalActors.Add(VehicleActorName, VehicleActor);
104 106
105 _mass = CalculateMass(); 107 _mass = CalculateMass();
106 108
107 DetailLog("{0},BSPrim.constructor,call", LocalID); 109 // DetailLog("{0},BSPrim.constructor,call", LocalID);
108 // do the actual object creation at taint time 110 // do the actual object creation at taint time
109 PhysicsScene.TaintedObject("BSPrim.create", delegate() 111 PhysicsScene.TaintedObject("BSPrim.create", delegate()
110 { 112 {
@@ -272,6 +274,7 @@ public class BSPrim : BSPhysObject
272 { 274 {
273 PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate() 275 PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate()
274 { 276 {
277 DetailLog("{0},BSPrim.LockAngularMotion,taint,registeringLockAxisActor", LocalID);
275 // If there is not already an axis locker, make one 278 // If there is not already an axis locker, make one
276 if (!PhysicalActors.HasActor(LockedAxisActorName)) 279 if (!PhysicalActors.HasActor(LockedAxisActorName))
277 { 280 {
@@ -537,7 +540,7 @@ public class BSPrim : BSPhysObject
537 540
538 public override int VehicleType { 541 public override int VehicleType {
539 get { 542 get {
540 return (int)VehicleController.Type; // if we are a vehicle, return that type 543 return (int)VehicleActor.Type; // if we are a vehicle, return that type
541 } 544 }
542 set { 545 set {
543 Vehicle type = (Vehicle)value; 546 Vehicle type = (Vehicle)value;
@@ -546,20 +549,8 @@ public class BSPrim : BSPhysObject
546 { 549 {
547 // Done at taint time so we're sure the physics engine is not using the variables 550 // Done at taint time so we're sure the physics engine is not using the variables
548 // Vehicle code changes the parameters for this vehicle type. 551 // Vehicle code changes the parameters for this vehicle type.
549 VehicleController.ProcessTypeChange(type); 552 VehicleActor.ProcessTypeChange(type);
550 ActivateIfPhysical(false); 553 ActivateIfPhysical(false);
551
552 // If an active vehicle, register the vehicle code to be called before each step
553 if (VehicleController.Type == Vehicle.TYPE_NONE)
554 {
555 UnRegisterPreStepAction("BSPrim.Vehicle", LocalID);
556 UnRegisterPostStepAction("BSPrim.Vehicle", LocalID);
557 }
558 else
559 {
560 RegisterPreStepAction("BSPrim.Vehicle", LocalID, VehicleController.Step);
561 RegisterPostStepAction("BSPrim.Vehicle", LocalID, VehicleController.PostStep);
562 }
563 }); 554 });
564 } 555 }
565 } 556 }
@@ -567,7 +558,7 @@ public class BSPrim : BSPhysObject
567 { 558 {
568 PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() 559 PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate()
569 { 560 {
570 VehicleController.ProcessFloatVehicleParam((Vehicle)param, value); 561 VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value);
571 ActivateIfPhysical(false); 562 ActivateIfPhysical(false);
572 }); 563 });
573 } 564 }
@@ -575,7 +566,7 @@ public class BSPrim : BSPhysObject
575 { 566 {
576 PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() 567 PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate()
577 { 568 {
578 VehicleController.ProcessVectorVehicleParam((Vehicle)param, value); 569 VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value);
579 ActivateIfPhysical(false); 570 ActivateIfPhysical(false);
580 }); 571 });
581 } 572 }
@@ -583,7 +574,7 @@ public class BSPrim : BSPhysObject
583 { 574 {
584 PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() 575 PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate()
585 { 576 {
586 VehicleController.ProcessRotationVehicleParam((Vehicle)param, rotation); 577 VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation);
587 ActivateIfPhysical(false); 578 ActivateIfPhysical(false);
588 }); 579 });
589 } 580 }
@@ -591,7 +582,7 @@ public class BSPrim : BSPhysObject
591 { 582 {
592 PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate() 583 PhysicsScene.TaintedObject("BSPrim.VehicleFlags", delegate()
593 { 584 {
594 VehicleController.ProcessVehicleFlags(param, remove); 585 VehicleActor.ProcessVehicleFlags(param, remove);
595 }); 586 });
596 } 587 }
597 588
@@ -848,7 +839,7 @@ public class BSPrim : BSPhysObject
848 MakeDynamic(IsStatic); 839 MakeDynamic(IsStatic);
849 840
850 // Update vehicle specific parameters (after MakeDynamic() so can change physical parameters) 841 // Update vehicle specific parameters (after MakeDynamic() so can change physical parameters)
851 VehicleController.Refresh(); 842 VehicleActor.Refresh();
852 PhysicalActors.Refresh(); 843 PhysicalActors.Refresh();
853 844
854 // Arrange for collision events if the simulator wants them 845 // Arrange for collision events if the simulator wants them
@@ -1655,9 +1646,9 @@ public class BSPrim : BSPhysObject
1655 volume *= (profileEnd - profileBegin); 1646 volume *= (profileEnd - profileBegin);
1656 1647
1657 returnMass = Density * BSParam.DensityScaleFactor * volume; 1648 returnMass = Density * BSParam.DensityScaleFactor * volume;
1658 DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
1659 1649
1660 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); 1650 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
1651 // DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
1661 1652
1662 return returnMass; 1653 return returnMass;
1663 }// end CalculateMass 1654 }// end CalculateMass
@@ -1686,7 +1677,7 @@ public class BSPrim : BSPhysObject
1686 1677
1687 protected virtual void RemoveBodyDependencies() 1678 protected virtual void RemoveBodyDependencies()
1688 { 1679 {
1689 VehicleController.RemoveBodyDependencies(this); 1680 VehicleActor.RemoveBodyDependencies();
1690 PhysicalActors.RemoveBodyDependencies(); 1681 PhysicalActors.RemoveBodyDependencies();
1691 } 1682 }
1692 1683
@@ -1696,13 +1687,6 @@ public class BSPrim : BSPhysObject
1696 { 1687 {
1697 TriggerPreUpdatePropertyAction(ref entprop); 1688 TriggerPreUpdatePropertyAction(ref entprop);
1698 1689
1699 // A temporary kludge to suppress the rotational effects introduced on vehicles by Bullet
1700 // TODO: handle physics introduced by Bullet with computed vehicle physics.
1701 if (VehicleController.IsActive)
1702 {
1703 entprop.RotationalVelocity = OMV.Vector3.Zero;
1704 }
1705
1706 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1690 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1707 1691
1708 // Assign directly to the local variables so the normal set actions do not happen 1692 // Assign directly to the local variables so the normal set actions do not happen