aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/Tests
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
parentminor: change name of json script tests to JsonStoreScriptModuleTests instead... (diff)
downloadopensim-SC_OLD-a61ecee227450ea81c9afe85a62b207fefa888a9.zip
opensim-SC_OLD-a61ecee227450ea81c9afe85a62b207fefa888a9.tar.gz
opensim-SC_OLD-a61ecee227450ea81c9afe85a62b207fefa888a9.tar.bz2
opensim-SC_OLD-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')
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs45
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs14
2 files changed, 45 insertions, 14 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 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs
index 215e92f..28207a4 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO;
29using System.Collections.Generic; 30using System.Collections.Generic;
30using System.Linq; 31using System.Linq;
31using System.Text; 32using System.Text;
@@ -65,9 +66,16 @@ public static class BulletSimTestsUtil
65 bulletSimConfig.Set(kvp.Key, kvp.Value); 66 bulletSimConfig.Set(kvp.Key, kvp.Value);
66 } 67 }
67 } 68 }
68 // bulletSimConfig.Set("PhysicsLoggingEnabled","True"); 69
69 // bulletSimConfig.Set("PhysicsLoggingDoFlush","True"); 70 // If a special directory exists, put detailed logging therein.
70 // bulletSimConfig.Set("VehicleLoggingEnabled","True"); 71 // This allows local testing/debugging without having to worry that the build engine will output logs.
72 if (Directory.Exists("physlogs"))
73 {
74 bulletSimConfig.Set("PhysicsLoggingDir","./physlogs");
75 bulletSimConfig.Set("PhysicsLoggingEnabled","True");
76 bulletSimConfig.Set("PhysicsLoggingDoFlush","True");
77 bulletSimConfig.Set("VehicleLoggingEnabled","True");
78 }
71 79
72 BSPlugin bsPlugin = new BSPlugin(); 80 BSPlugin bsPlugin = new BSPlugin();
73 81