aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
diff options
context:
space:
mode:
authorRobert Adams2013-01-29 17:01:27 -0800
committerRobert Adams2013-01-29 17:04:28 -0800
commita61ecee227450ea81c9afe85a62b207fefa888a9 (patch)
tree8209ad276576a95e86d054f3e36c70b9ec5fb813 /OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
parentminor: change name of json script tests to JsonStoreScriptModuleTests instead... (diff)
downloadopensim-SC-a61ecee227450ea81c9afe85a62b207fefa888a9.zip
opensim-SC-a61ecee227450ea81c9afe85a62b207fefa888a9.tar.gz
opensim-SC-a61ecee227450ea81c9afe85a62b207fefa888a9.tar.bz2
opensim-SC-a61ecee227450ea81c9afe85a62b207fefa888a9.tar.xz
BulletSim: fix physics repositioning when under ground to only happen
for physical objects. Non-physical objects can go anywhere they want.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs45
1 files changed, 34 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
index 5900103..33232bd 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
@@ -51,7 +51,7 @@ public class BasicVehicles : OpenSimTestCase
51 BSScene PhysicsScene { get; set; } 51 BSScene PhysicsScene { get; set; }
52 BSPrim TestVehicle { get; set; } 52 BSPrim TestVehicle { get; set; }
53 Vector3 TestVehicleInitPosition { get; set; } 53 Vector3 TestVehicleInitPosition { get; set; }
54 float timeStep = 0.089f; 54 float simulationTimeStep = 0.089f;
55 55
56 [TestFixtureSetUp] 56 [TestFixtureSetUp]
57 public void Init() 57 public void Init()
@@ -87,39 +87,62 @@ public class BasicVehicles : OpenSimTestCase
87 } 87 }
88 } 88 }
89 89
90 [TestCase(25, 0.25f, 0.25f, 0.25f)] 90 [TestCase(2f, 0.2f, 0.25f, 0.25f, 0.25f)]
91 [TestCase(25, -0.25f, 0.25f, 0.25f)] 91 [TestCase(2f, 0.2f, -0.25f, 0.25f, 0.25f)]
92 [TestCase(25, 0.25f, -0.25f, 0.25f)] 92 [TestCase(2f, 0.2f, 0.25f, -0.25f, 0.25f)]
93 [TestCase(25, -0.25f, -0.25f, 0.25f)] 93 [TestCase(2f, 0.2f, -0.25f, -0.25f, 0.25f)]
94 public void VerticalAttraction(int simSteps, float initRoll, float initPitch, float initYaw) 94 // [TestCase(2f, 0.2f, 0.785f, 0.0f, 0.25f) /*, "Leaning 45 degrees to the side" */]
95 // [TestCase(2f, 0.2f, 1.650f, 0.0f, 0.25f) /*, "Leaning more than 90 degrees to the side" */]
96 // [TestCase(2f, 0.2f, 2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped right" */]
97 // [TestCase(2f, 0.2f,-2.750f, 0.0f, 0.25f) /*, "Almost upside down, tipped left" */]
98 // [TestCase(2f, 0.2f, 0.0f, 0.785f, 0.25f) /*, "Tipped back 45 degrees" */]
99 // [TestCase(2f, 0.2f, 0.0f, 1.650f, 0.25f) /*, "Tipped back more than 90 degrees" */]
100 // [TestCase(2f, 0.2f, 0.0f, 2.750f, 0.25f) /*, "Almost upside down, tipped back" */]
101 // [TestCase(2f, 0.2f, 0.0f,-2.750f, 0.25f) /*, "Almost upside down, tipped forward" */]
102 public void AngularVerticalAttraction(float timeScale, float efficiency, float initRoll, float initPitch, float initYaw)
95 { 103 {
104 // Enough simulation steps to cover the timescale the operation should take
105 int simSteps = (int)(timeScale / simulationTimeStep) + 1;
106
107 // Tip the vehicle
96 Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw); 108 Quaternion initOrientation = Quaternion.CreateFromEulers(initRoll, initPitch, initYaw);
97 TestVehicle.Orientation = initOrientation; 109 TestVehicle.Orientation = initOrientation;
98 110
99 TestVehicle.Position = TestVehicleInitPosition; 111 TestVehicle.Position = TestVehicleInitPosition;
100 112
101 // The vehicle controller is not enabled directly (set a vehicle type). 113 // The vehicle controller is not enabled directly (by setting a vehicle type).
102 // 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
103 // controller we want to exercise. Stepping the physics engine then applies 115 // controller we want to exercise. Stepping the physics engine then applies
104 // the actions of that one feature. 116 // the actions of that one feature.
105 TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, 0.2f); 117 TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
106 TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, 2f); 118 TestVehicle.VehicleController.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
107 TestVehicle.VehicleController.enableAngularVerticalAttraction = true; 119 TestVehicle.VehicleController.enableAngularVerticalAttraction = true;
108 120
109 TestVehicle.IsPhysical = true; 121 TestVehicle.IsPhysical = true;
110 PhysicsScene.ProcessTaints(); 122 PhysicsScene.ProcessTaints();
111 123
112 // Step the simulator a bunch of times and and vertical attraction should orient the vehicle up 124 // Step the simulator a bunch of times and vertical attraction should orient the vehicle up
113 for (int ii = 0; ii < simSteps; ii++) 125 for (int ii = 0; ii < simSteps; ii++)
114 { 126 {
115 TestVehicle.VehicleController.ForgetKnownVehicleProperties(); 127 TestVehicle.VehicleController.ForgetKnownVehicleProperties();
116 TestVehicle.VehicleController.ComputeAngularVerticalAttraction(); 128 TestVehicle.VehicleController.ComputeAngularVerticalAttraction();
117 TestVehicle.VehicleController.PushKnownChanged(); 129 TestVehicle.VehicleController.PushKnownChanged();
118 130
119 PhysicsScene.Simulate(timeStep); 131 PhysicsScene.Simulate(simulationTimeStep);
120 } 132 }
121 133
134 TestVehicle.IsPhysical = false;
135 PhysicsScene.ProcessTaints();
136
122 // After these steps, the vehicle should be upright 137 // After these steps, the vehicle should be upright
138 /*
139 float finalRoll, finalPitch, finalYaw;
140 TestVehicle.Orientation.GetEulerAngles(out finalRoll, out finalPitch, out finalYaw);
141 Assert.That(finalRoll, Is.InRange(-0.01f, 0.01f));
142 Assert.That(finalPitch, Is.InRange(-0.01f, 0.01f));
143 Assert.That(finalYaw, Is.InRange(initYaw - 0.1f, initYaw + 0.1f));
144 */
145
123 Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation; 146 Vector3 upPointer = Vector3.UnitZ * TestVehicle.Orientation;
124 Assert.That(upPointer.Z, Is.GreaterThan(0.99f)); 147 Assert.That(upPointer.Z, Is.GreaterThan(0.99f));
125 } 148 }