aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorRobert Adams2012-12-17 13:22:04 -0800
committerRobert Adams2012-12-17 13:22:04 -0800
commit11532a4390ce3054f5a6798b4bf8dcf39d002e77 (patch)
tree020311696b99bf9d4f143397efc4fadf039075e8 /OpenSim/Region
parentBulletSim: fix vehicles being shot in the air at border crossings because of ... (diff)
downloadopensim-SC_OLD-11532a4390ce3054f5a6798b4bf8dcf39d002e77.zip
opensim-SC_OLD-11532a4390ce3054f5a6798b4bf8dcf39d002e77.tar.gz
opensim-SC_OLD-11532a4390ce3054f5a6798b4bf8dcf39d002e77.tar.bz2
opensim-SC_OLD-11532a4390ce3054f5a6798b4bf8dcf39d002e77.tar.xz
BulletSim: fix vehicles going underground when unsat. Problem was that, when doing unsit, the order of operations on the prims and the vehicle is very chaotic and not in a good order so the root prim was being left physical and thus it fell for a bit. Also changed default of velocity scaling to be closer to the movement standard.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs43
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs14
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs2
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt2
4 files changed, 32 insertions, 29 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index ef68471..48ba419 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -87,7 +87,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
87 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate 87 private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate
88 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate 88 private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate
89 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate 89 private Vector3 m_angularFrictionTimescale = Vector3.Zero; // body angular velocity decay rate
90 private Vector3 m_lastAngularCorrection = Vector3.Zero; 90 private Vector3 m_lastAngularVelocity = Vector3.Zero;
91 private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body 91 private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body
92 92
93 //Deflection properties 93 //Deflection properties
@@ -128,7 +128,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
128 // Return 'true' if this vehicle is doing vehicle things 128 // Return 'true' if this vehicle is doing vehicle things
129 public bool IsActive 129 public bool IsActive
130 { 130 {
131 get { return Type != Vehicle.TYPE_NONE; } 131 get { return Type != Vehicle.TYPE_NONE && Prim.IsPhysical; }
132 } 132 }
133 133
134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) 134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
@@ -664,6 +664,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
664 // an UpdateProperties event to send the changes up to the simulator. 664 // an UpdateProperties event to send the changes up to the simulator.
665 BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr); 665 BulletSimAPI.PushUpdate2(Prim.PhysBody.ptr);
666 } 666 }
667 m_knownChanged = 0;
667 } 668 }
668 669
669 // Since the computation of terrain height can be a little involved, this routine 670 // Since the computation of terrain height can be a little involved, this routine
@@ -993,11 +994,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
993 public Vector3 ComputeLinearMotorUp(float pTimestep) 994 public Vector3 ComputeLinearMotorUp(float pTimestep)
994 { 995 {
995 Vector3 ret = Vector3.Zero; 996 Vector3 ret = Vector3.Zero;
997 float distanceAboveGround = 0f;
996 998
997 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) 999 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
998 { 1000 {
999 float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); 1001 float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition);
1000 float distanceAboveGround = VehiclePosition.Z - targetHeight; 1002 distanceAboveGround = VehiclePosition.Z - targetHeight;
1001 // Not colliding if the vehicle is off the ground 1003 // Not colliding if the vehicle is off the ground
1002 if (!Prim.IsColliding) 1004 if (!Prim.IsColliding)
1003 { 1005 {
@@ -1010,9 +1012,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1010 // has a decay factor. This says this force should 1012 // has a decay factor. This says this force should
1011 // be computed with a motor. 1013 // be computed with a motor.
1012 // TODO: add interaction with banking. 1014 // TODO: add interaction with banking.
1013 VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}",
1014 Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret);
1015 } 1015 }
1016 VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}",
1017 Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret);
1016 return ret; 1018 return ret;
1017 } 1019 }
1018 1020
@@ -1049,8 +1051,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1049 // ================================================================== 1051 // ==================================================================
1050 m_lastVertAttractor = verticalAttractionContribution; 1052 m_lastVertAttractor = verticalAttractionContribution;
1051 1053
1054 // DEBUG DEBUG DEBUG: optionally scale the angular velocity. Debugging SL vs ODE turning functions.
1055 Vector3 originalAngularMotorContrib = angularMotorContribution;
1056 if (PhysicsScene.VehicleScaleAngularVelocityByTimestep)
1057 angularMotorContribution *= pTimestep;
1058
1052 // Sum corrections 1059 // Sum corrections
1053 m_lastAngularCorrection = angularMotorContribution 1060 m_lastAngularVelocity = angularMotorContribution
1054 + verticalAttractionContribution 1061 + verticalAttractionContribution
1055 + deflectionContribution 1062 + deflectionContribution
1056 + bankingContribution; 1063 + bankingContribution;
@@ -1058,19 +1065,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1058 // ================================================================== 1065 // ==================================================================
1059 // Apply the correction velocity. 1066 // Apply the correction velocity.
1060 // TODO: Should this be applied as an angular force (torque)? 1067 // TODO: Should this be applied as an angular force (torque)?
1061 if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f)) 1068 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1062 { 1069 {
1063 // DEBUG DEBUG DEBUG: optionally scale the angular velocity. Debugging SL vs ODE turning functions. 1070 VehicleRotationalVelocity = m_lastAngularVelocity;
1064 Vector3 scaledCorrection = m_lastAngularCorrection;
1065 if (PhysicsScene.VehicleScaleAngularVelocityByTimestep)
1066 scaledCorrection *= pTimestep;
1067 VehicleRotationalVelocity = scaledCorrection;
1068 1071
1069 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}", 1072 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5}",
1070 Prim.LocalID, 1073 Prim.LocalID,
1071 angularMotorContribution, verticalAttractionContribution, 1074 angularMotorContribution, verticalAttractionContribution,
1072 bankingContribution, deflectionContribution, 1075 bankingContribution, deflectionContribution,
1073 m_lastAngularCorrection, scaledCorrection 1076 m_lastAngularVelocity
1074 ); 1077 );
1075 } 1078 }
1076 else 1079 else
@@ -1124,18 +1127,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1124 { 1127 {
1125 Vector3 ret = Vector3.Zero; 1128 Vector3 ret = Vector3.Zero;
1126 1129
1127 // If vertical attaction timescale is reasonable and we applied an angular force last time... 1130 // If vertical attaction timescale is reasonable
1128 if (m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1131 if (m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1129 { 1132 {
1130 // Take a vector pointing up and convert it from world to vehicle relative coords. 1133 // Take a vector pointing up and convert it from world to vehicle relative coords.
1131 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1134 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1132 verticalError.Normalize();
1133 1135
1134 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ) 1136 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ)
1135 // is now leaning to one side (rotated around the X axis) and the Y value will 1137 // is now:
1136 // go from zero (nearly straight up) to one (completely to the side) or leaning 1138 // leaning to one side: rotated around the X axis with the Y value going
1137 // front-to-back (rotated around the Y axis) and the value of X will be between 1139 // from zero (nearly straight up) to one (completely to the side)) or
1138 // zero and one. 1140 // leaning front-to-back: rotated around the Y axis with the value of X being between
1141 // zero and one.
1139 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees. 1142 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees.
1140 1143
1141 // If verticalError.Z is negative, the vehicle is upside down. Add additional push. 1144 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 4d4f712..2a7b72c 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -94,10 +94,10 @@ public sealed class BSLinksetCompound : BSLinkset
94 } 94 }
95 95
96 // Schedule a refresh to happen after all the other taint processing. 96 // Schedule a refresh to happen after all the other taint processing.
97 private void ScheduleRebuild() 97 private void ScheduleRebuild(BSPhysObject requestor)
98 { 98 {
99 DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,rebuilding={1}", 99 DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,rebuilding={1}",
100 LinksetRoot.LocalID, Rebuilding); 100 requestor.LocalID, Rebuilding);
101 // When rebuilding, it is possible to set properties that would normally require a rebuild. 101 // When rebuilding, it is possible to set properties that would normally require a rebuild.
102 // If already rebuilding, don't request another rebuild. 102 // If already rebuilding, don't request another rebuild.
103 if (!Rebuilding) 103 if (!Rebuilding)
@@ -124,7 +124,7 @@ public sealed class BSLinksetCompound : BSLinkset
124 { 124 {
125 // The root is going dynamic. Make sure mass is properly set. 125 // The root is going dynamic. Make sure mass is properly set.
126 m_mass = ComputeLinksetMass(); 126 m_mass = ComputeLinksetMass();
127 ScheduleRebuild(); 127 ScheduleRebuild(LinksetRoot);
128 } 128 }
129 else 129 else
130 { 130 {
@@ -153,7 +153,7 @@ public sealed class BSLinksetCompound : BSLinkset
153 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 153 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child));
154 if (IsRoot(child)) 154 if (IsRoot(child))
155 { 155 {
156 ScheduleRebuild(); 156 ScheduleRebuild(LinksetRoot);
157 } 157 }
158 else 158 else
159 { 159 {
@@ -182,7 +182,7 @@ public sealed class BSLinksetCompound : BSLinkset
182 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition)) 182 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition))
183 { 183 {
184 updated.LinksetInfo = null; 184 updated.LinksetInfo = null;
185 ScheduleRebuild(); 185 ScheduleRebuild(updated);
186 } 186 }
187 } 187 }
188 188
@@ -266,7 +266,7 @@ public sealed class BSLinksetCompound : BSLinkset
266 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); 266 DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID);
267 267
268 // Rebuild the compound shape with the new child shape included 268 // Rebuild the compound shape with the new child shape included
269 ScheduleRebuild(); 269 ScheduleRebuild(child);
270 } 270 }
271 return; 271 return;
272 } 272 }
@@ -294,7 +294,7 @@ public sealed class BSLinksetCompound : BSLinkset
294 else 294 else
295 { 295 {
296 // Rebuild the compound shape with the child removed 296 // Rebuild the compound shape with the child removed
297 ScheduleRebuild(); 297 ScheduleRebuild(child);
298 } 298 }
299 } 299 }
300 return; 300 return;
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 7b44574..ebaf97e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -1240,7 +1240,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
1240 (s) => { return s.m_params[0].vehicleAngularDamping; }, 1240 (s) => { return s.m_params[0].vehicleAngularDamping; },
1241 (s,p,l,v) => { s.m_params[0].vehicleAngularDamping = v; } ), 1241 (s,p,l,v) => { s.m_params[0].vehicleAngularDamping = v; } ),
1242 new ParameterDefn("VehicleScaleAngularVelocityByTimestep", "If true, scale angular turning by timestep", 1242 new ParameterDefn("VehicleScaleAngularVelocityByTimestep", "If true, scale angular turning by timestep",
1243 ConfigurationParameters.numericFalse, 1243 ConfigurationParameters.numericTrue,
1244 (s,cf,p,v) => { s.VehicleScaleAngularVelocityByTimestep = cf.GetBoolean(p, s.BoolNumeric(v)); }, 1244 (s,cf,p,v) => { s.VehicleScaleAngularVelocityByTimestep = cf.GetBoolean(p, s.BoolNumeric(v)); },
1245 (s) => { return s.NumericBool(s.VehicleScaleAngularVelocityByTimestep); }, 1245 (s) => { return s.NumericBool(s.VehicleScaleAngularVelocityByTimestep); },
1246 (s,p,l,v) => { s.VehicleScaleAngularVelocityByTimestep = s.BoolNumeric(v); } ), 1246 (s,p,l,v) => { s.VehicleScaleAngularVelocityByTimestep = s.BoolNumeric(v); } ),
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index 31dd790..0d9a156 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -5,7 +5,7 @@ Eliminate all crashes (DONEish)
5 Border crossing of physical linkset (DONE) 5 Border crossing of physical linkset (DONE)
6Enable vehicle border crossings (at least as poorly as ODE) 6Enable vehicle border crossings (at least as poorly as ODE)
7 Avatar created in previous region and not new region when crossing border 7 Avatar created in previous region and not new region when crossing border
8 Vehicle recreated in new sim at small Z value (offset from root value?) 8 Vehicle recreated in new sim at small Z value (offset from root value?) (DONE)
9Calibrate turning radius 9Calibrate turning radius
10limitMotorUp calibration (more down?) 10limitMotorUp calibration (more down?)
11study PID motors (include 'efficiency' implementation 11study PID motors (include 'efficiency' implementation