aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs45
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BulletSimTestsUtil.cs14
3 files changed, 50 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 2b0a539..b5dd131 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -344,6 +344,10 @@ public sealed class BSPrim : BSPhysObject
344 { 344 {
345 bool ret = false; 345 bool ret = false;
346 346
347 // We don't care where non-physical items are placed
348 if (!IsPhysicallyActive)
349 return ret;
350
347 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) 351 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
348 { 352 {
349 // The physical object is out of the known/simulated area. 353 // The physical object is out of the known/simulated area.
@@ -1643,7 +1647,7 @@ public sealed class BSPrim : BSPhysObject
1643 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1647 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1644 1648
1645 // The sanity check can change the velocity and/or position. 1649 // The sanity check can change the velocity and/or position.
1646 if (IsPhysical && PositionSanityCheck(true /* inTaintTime */ )) 1650 if (PositionSanityCheck(true /* inTaintTime */ ))
1647 { 1651 {
1648 entprop.Position = _position; 1652 entprop.Position = _position;
1649 entprop.Velocity = _velocity; 1653 entprop.Velocity = _velocity;
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