diff options
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 70 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs | 32 |
2 files changed, 70 insertions, 32 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 90f74df..b2947c6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -70,18 +70,17 @@ public class BSPrim : BSPhysObject | |||
70 | private int CrossingFailures { get; set; } | 70 | private int CrossingFailures { get; set; } |
71 | 71 | ||
72 | // Keep a handle to the vehicle actor so it is easy to set parameters on same. | 72 | // Keep a handle to the vehicle actor so it is easy to set parameters on same. |
73 | public BSDynamics VehicleActor; | ||
74 | public const string VehicleActorName = "BasicVehicle"; | 73 | public const string VehicleActorName = "BasicVehicle"; |
75 | 74 | ||
76 | // Parameters for the hover actor | 75 | // Parameters for the hover actor |
77 | public const string HoverActorName = "HoverActor"; | 76 | public const string HoverActorName = "BSPrim.HoverActor"; |
78 | // Parameters for the axis lock actor | 77 | // Parameters for the axis lock actor |
79 | public const String LockedAxisActorName = "BSPrim.LockedAxis"; | 78 | public const String LockedAxisActorName = "BSPrim.LockedAxis"; |
80 | // Parameters for the move to target actor | 79 | // Parameters for the move to target actor |
81 | public const string MoveToTargetActorName = "MoveToTargetActor"; | 80 | public const string MoveToTargetActorName = "BSPrim.MoveToTargetActor"; |
82 | // Parameters for the setForce and setTorque actors | 81 | // Parameters for the setForce and setTorque actors |
83 | public const string SetForceActorName = "SetForceActor"; | 82 | public const string SetForceActorName = "BSPrim.SetForceActor"; |
84 | public const string SetTorqueActorName = "SetTorqueActor"; | 83 | public const string SetTorqueActorName = "BSPrim.SetTorqueActor"; |
85 | 84 | ||
86 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, | 85 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, |
87 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) | 86 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) |
@@ -100,9 +99,8 @@ public class BSPrim : BSPhysObject | |||
100 | _isPhysical = pisPhysical; | 99 | _isPhysical = pisPhysical; |
101 | _isVolumeDetect = false; | 100 | _isVolumeDetect = false; |
102 | 101 | ||
103 | // We keep a handle to the vehicle actor so we can set vehicle parameters later. | 102 | // Add a dynamic vehicle to our set of actors that can move this prim. |
104 | VehicleActor = new BSDynamics(PhysScene, this, VehicleActorName); | 103 | PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); |
105 | PhysicalActors.Add(VehicleActorName, VehicleActor); | ||
106 | 104 | ||
107 | _mass = CalculateMass(); | 105 | _mass = CalculateMass(); |
108 | 106 | ||
@@ -505,9 +503,25 @@ public class BSPrim : BSPhysObject | |||
505 | } | 503 | } |
506 | } | 504 | } |
507 | 505 | ||
506 | // Find and return a handle to the current vehicle actor. | ||
507 | // Return 'null' if there is no vehicle actor. | ||
508 | public BSDynamics GetVehicleActor() | ||
509 | { | ||
510 | BSDynamics ret = null; | ||
511 | BSActor actor; | ||
512 | if (PhysicalActors.TryGetActor(VehicleActorName, out actor)) | ||
513 | { | ||
514 | ret = actor as BSDynamics; | ||
515 | } | ||
516 | return ret; | ||
517 | } | ||
508 | public override int VehicleType { | 518 | public override int VehicleType { |
509 | get { | 519 | get { |
510 | return (int)VehicleActor.Type; | 520 | int ret = (int)Vehicle.TYPE_NONE; |
521 | BSDynamics vehicleActor = GetVehicleActor(); | ||
522 | if (vehicleActor != null) | ||
523 | ret = (int)vehicleActor.Type; | ||
524 | return ret; | ||
511 | } | 525 | } |
512 | set { | 526 | set { |
513 | Vehicle type = (Vehicle)value; | 527 | Vehicle type = (Vehicle)value; |
@@ -518,8 +532,12 @@ public class BSPrim : BSPhysObject | |||
518 | // change all the parameters. Like a plane changing to CAR when on the | 532 | // change all the parameters. Like a plane changing to CAR when on the |
519 | // ground. In this case, don't want to zero motion. | 533 | // ground. In this case, don't want to zero motion. |
520 | // ZeroMotion(true /* inTaintTime */); | 534 | // ZeroMotion(true /* inTaintTime */); |
521 | VehicleActor.ProcessTypeChange(type); | 535 | BSDynamics vehicleActor = GetVehicleActor(); |
522 | ActivateIfPhysical(false); | 536 | if (vehicleActor != null) |
537 | { | ||
538 | vehicleActor.ProcessTypeChange(type); | ||
539 | ActivateIfPhysical(false); | ||
540 | } | ||
523 | }); | 541 | }); |
524 | } | 542 | } |
525 | } | 543 | } |
@@ -527,31 +545,47 @@ public class BSPrim : BSPhysObject | |||
527 | { | 545 | { |
528 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 546 | PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
529 | { | 547 | { |
530 | VehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | 548 | BSDynamics vehicleActor = GetVehicleActor(); |
531 | ActivateIfPhysical(false); | 549 | if (vehicleActor != null) |
550 | { | ||
551 | vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); | ||
552 | ActivateIfPhysical(false); | ||
553 | } | ||
532 | }); | 554 | }); |
533 | } | 555 | } |
534 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 556 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
535 | { | 557 | { |
536 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 558 | PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
537 | { | 559 | { |
538 | VehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | 560 | BSDynamics vehicleActor = GetVehicleActor(); |
539 | ActivateIfPhysical(false); | 561 | if (vehicleActor != null) |
562 | { | ||
563 | vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); | ||
564 | ActivateIfPhysical(false); | ||
565 | } | ||
540 | }); | 566 | }); |
541 | } | 567 | } |
542 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 568 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
543 | { | 569 | { |
544 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 570 | PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
545 | { | 571 | { |
546 | VehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | 572 | BSDynamics vehicleActor = GetVehicleActor(); |
547 | ActivateIfPhysical(false); | 573 | if (vehicleActor != null) |
574 | { | ||
575 | vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); | ||
576 | ActivateIfPhysical(false); | ||
577 | } | ||
548 | }); | 578 | }); |
549 | } | 579 | } |
550 | public override void VehicleFlags(int param, bool remove) | 580 | public override void VehicleFlags(int param, bool remove) |
551 | { | 581 | { |
552 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() | 582 | PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() |
553 | { | 583 | { |
554 | VehicleActor.ProcessVehicleFlags(param, remove); | 584 | BSDynamics vehicleActor = GetVehicleActor(); |
585 | if (vehicleActor != null) | ||
586 | { | ||
587 | vehicleActor.ProcessVehicleFlags(param, remove); | ||
588 | } | ||
555 | }); | 589 | }); |
556 | } | 590 | } |
557 | 591 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs index b040e21..583c436 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs | |||
@@ -114,21 +114,25 @@ public class BasicVehicles : OpenSimTestCase | |||
114 | // Instead the appropriate values are set and calls are made just the parts of the | 114 | // Instead the appropriate values are set and calls are made just the parts of the |
115 | // controller we want to exercise. Stepping the physics engine then applies | 115 | // controller we want to exercise. Stepping the physics engine then applies |
116 | // the actions of that one feature. | 116 | // the actions of that one feature. |
117 | TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); | 117 | BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); |
118 | TestVehicle.VehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); | 118 | if (vehicleActor != null) |
119 | TestVehicle.VehicleActor.enableAngularVerticalAttraction = true; | ||
120 | |||
121 | TestVehicle.IsPhysical = true; | ||
122 | PhysicsScene.ProcessTaints(); | ||
123 | |||
124 | // Step the simulator a bunch of times and vertical attraction should orient the vehicle up | ||
125 | for (int ii = 0; ii < simSteps; ii++) | ||
126 | { | 119 | { |
127 | TestVehicle.VehicleActor.ForgetKnownVehicleProperties(); | 120 | vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); |
128 | TestVehicle.VehicleActor.ComputeAngularVerticalAttraction(); | 121 | vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); |
129 | TestVehicle.VehicleActor.PushKnownChanged(); | 122 | vehicleActor.enableAngularVerticalAttraction = true; |
130 | 123 | ||
131 | PhysicsScene.Simulate(simulationTimeStep); | 124 | TestVehicle.IsPhysical = true; |
125 | PhysicsScene.ProcessTaints(); | ||
126 | |||
127 | // Step the simulator a bunch of times and vertical attraction should orient the vehicle up | ||
128 | for (int ii = 0; ii < simSteps; ii++) | ||
129 | { | ||
130 | vehicleActor.ForgetKnownVehicleProperties(); | ||
131 | vehicleActor.ComputeAngularVerticalAttraction(); | ||
132 | vehicleActor.PushKnownChanged(); | ||
133 | |||
134 | PhysicsScene.Simulate(simulationTimeStep); | ||
135 | } | ||
132 | } | 136 | } |
133 | 137 | ||
134 | TestVehicle.IsPhysical = false; | 138 | TestVehicle.IsPhysical = false; |