aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRobert Adams2013-01-23 14:21:52 -0800
committerRobert Adams2013-01-23 14:25:42 -0800
commita7b810ddeebda8b13af3ab9fbeb24bef1a8094c6 (patch)
treee3f9b4f03f712dc63a4aefc5ac389f9b1c36ed8d
parentBulletSim: small change to center-of-mass computation left out last commit (diff)
downloadopensim-SC_OLD-a7b810ddeebda8b13af3ab9fbeb24bef1a8094c6.zip
opensim-SC_OLD-a7b810ddeebda8b13af3ab9fbeb24bef1a8094c6.tar.gz
opensim-SC_OLD-a7b810ddeebda8b13af3ab9fbeb24bef1a8094c6.tar.bz2
opensim-SC_OLD-a7b810ddeebda8b13af3ab9fbeb24bef1a8094c6.tar.xz
BulletSim: remove setting of vehicle InterpolationRotationalVelocity.
This doesn't seem to help the vehicle stability. Rename vehicle internal variables adding a "V" or "W" so it is clear when coordinates are vehicle or world relative.
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs66
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs4
2 files changed, 34 insertions, 36 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index dbe44de..fe7891e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -690,7 +690,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
690 // Bullet does a bunch of smoothing for changing parameters. 690 // Bullet does a bunch of smoothing for changing parameters.
691 // Since the vehicle is demanding this setting, we override Bullet's smoothing 691 // Since the vehicle is demanding this setting, we override Bullet's smoothing
692 // by telling Bullet the value was the same last time. 692 // by telling Bullet the value was the same last time.
693 PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, m_knownVelocity); 693 // PhysicsScene.PE.SetInterpolationLinearVelocity(Prim.PhysBody, m_knownVelocity);
694 } 694 }
695 695
696 if ((m_knownChanged & m_knownChangedForce) != 0) 696 if ((m_knownChanged & m_knownChangedForce) != 0)
@@ -702,7 +702,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
702 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0) 702 if ((m_knownChanged & m_knownChangedRotationalVelocity) != 0)
703 { 703 {
704 Prim.ForceRotationalVelocity = m_knownRotationalVelocity; 704 Prim.ForceRotationalVelocity = m_knownRotationalVelocity;
705 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); 705 // PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity);
706 } 706 }
707 707
708 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0) 708 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0)
@@ -963,23 +963,23 @@ namespace OpenSim.Region.Physics.BulletSPlugin
963 { 963 {
964 // Step the motor from the current value. Get the correction needed this step. 964 // Step the motor from the current value. Get the correction needed this step.
965 Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation); 965 Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
966 Vector3 linearMotorCorrection = m_linearMotor.Step(pTimestep, currentVel); 966 Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVel);
967 967
968 // Motor is vehicle coordinates. Rotate it to world coordinates 968 // Motor is vehicle coordinates. Rotate it to world coordinates
969 Vector3 linearMotorVelocity = linearMotorCorrection * VehicleOrientation; 969 Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
970 970
971 // If we're a ground vehicle, don't add any upward Z movement 971 // If we're a ground vehicle, don't add any upward Z movement
972 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) 972 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
973 { 973 {
974 if (linearMotorVelocity.Z > 0f) 974 if (linearMotorVelocityW.Z > 0f)
975 linearMotorVelocity.Z = 0f; 975 linearMotorVelocityW.Z = 0f;
976 } 976 }
977 977
978 // Add this correction to the velocity to make it faster/slower. 978 // Add this correction to the velocity to make it faster/slower.
979 VehicleVelocity += linearMotorVelocity; 979 VehicleVelocity += linearMotorVelocityW;
980 980
981 VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}", 981 VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}",
982 Prim.LocalID, VehicleVelocity, linearMotorCorrection, linearMotorVelocity); 982 Prim.LocalID, VehicleVelocity, linearMotorCorrectionV, linearMotorVelocityW);
983 } 983 }
984 984
985 public void ComputeLinearTerrainHeightCorrection(float pTimestep) 985 public void ComputeLinearTerrainHeightCorrection(float pTimestep)
@@ -1123,8 +1123,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1123 // a downward raycast to find what is below. 1123 // a downward raycast to find what is below.
1124 public void ComputeLinearMotorUp(float pTimestep) 1124 public void ComputeLinearMotorUp(float pTimestep)
1125 { 1125 {
1126 Vector3 ret = Vector3.Zero;
1127
1128 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) 1126 if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0)
1129 { 1127 {
1130 // This code tries to decide if the object is not on the ground and then pushing down 1128 // This code tries to decide if the object is not on the ground and then pushing down
@@ -1250,8 +1248,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1250 private void ComputeAngularTurning(float pTimestep) 1248 private void ComputeAngularTurning(float pTimestep)
1251 { 1249 {
1252 // The user wants this many radians per second angular change? 1250 // The user wants this many radians per second angular change?
1253 Vector3 currentAngular = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation); 1251 Vector3 currentAngularV = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation);
1254 Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep, currentAngular); 1252 Vector3 angularMotorContributionV = m_angularMotor.Step(pTimestep, currentAngularV);
1255 1253
1256 // ================================================================== 1254 // ==================================================================
1257 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags : 1255 // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags :
@@ -1263,12 +1261,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1263 // is a linear effect. Where should this check go? 1261 // is a linear effect. Where should this check go?
1264 if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) 1262 if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0)
1265 { 1263 {
1266 angularMotorContribution.X = 0f; 1264 angularMotorContributionV.X = 0f;
1267 angularMotorContribution.Y = 0f; 1265 angularMotorContributionV.Y = 0f;
1268 } 1266 }
1269 1267
1270 VehicleRotationalVelocity += angularMotorContribution * VehicleOrientation; 1268 VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation;
1271 VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution); 1269 VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV);
1272 } 1270 }
1273 1271
1274 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial: 1272 // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial:
@@ -1284,7 +1282,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1284 // If vertical attaction timescale is reasonable 1282 // If vertical attaction timescale is reasonable
1285 if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1283 if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1286 { 1284 {
1287 Vector3 vertContribution = Vector3.Zero; 1285 Vector3 vertContributionV = Vector3.Zero;
1288 1286
1289 // Take a vector pointing up and convert it from world to vehicle relative coords. 1287 // Take a vector pointing up and convert it from world to vehicle relative coords.
1290 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1288 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
@@ -1299,26 +1297,26 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1299 1297
1300 // Y error means needed rotation around X axis and visa versa. 1298 // Y error means needed rotation around X axis and visa versa.
1301 // Since the error goes from zero to one, the asin is the corresponding angle. 1299 // Since the error goes from zero to one, the asin is the corresponding angle.
1302 vertContribution.X = (float)Math.Asin(verticalError.Y); 1300 vertContributionV.X = (float)Math.Asin(verticalError.Y);
1303 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.) 1301 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.)
1304 vertContribution.Y = -(float)Math.Asin(verticalError.X); 1302 vertContributionV.Y = -(float)Math.Asin(verticalError.X);
1305 1303
1306 // If verticalError.Z is negative, the vehicle is upside down. Add additional push. 1304 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.
1307 if (verticalError.Z < 0f) 1305 if (verticalError.Z < 0f)
1308 { 1306 {
1309 vertContribution.X += PIOverFour; 1307 vertContributionV.X += PIOverFour;
1310 // vertContribution.Y -= PIOverFour; 1308 // vertContribution.Y -= PIOverFour;
1311 } 1309 }
1312 1310
1313 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second. 1311 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
1314 // Correction happens over a number of seconds. 1312 // Correction happens over a number of seconds.
1315 Vector3 unscaledContrib = vertContribution; // DEBUG DEBUG 1313 Vector3 unscaledContrib = vertContributionV; // DEBUG DEBUG
1316 vertContribution /= m_verticalAttractionTimescale; 1314 vertContributionV /= m_verticalAttractionTimescale;
1317 1315
1318 VehicleRotationalVelocity += vertContribution * VehicleOrientation; 1316 VehicleRotationalVelocity += vertContributionV * VehicleOrientation;
1319 1317
1320 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}", 1318 VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
1321 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContribution); 1319 Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
1322 } 1320 }
1323 } 1321 }
1324 1322
@@ -1336,7 +1334,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1336 1334
1337 if (enableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2) 1335 if (enableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2)
1338 { 1336 {
1339 Vector3 deflectContribution = Vector3.Zero; 1337 Vector3 deflectContributionV = Vector3.Zero;
1340 1338
1341 // The direction the vehicle is moving 1339 // The direction the vehicle is moving
1342 Vector3 movingDirection = VehicleVelocity; 1340 Vector3 movingDirection = VehicleVelocity;
@@ -1363,13 +1361,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1363 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError); 1361 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError);
1364 1362
1365 // Scale the correction by recovery timescale and efficiency 1363 // Scale the correction by recovery timescale and efficiency
1366 deflectContribution = (-deflectionError) * m_angularDeflectionEfficiency; 1364 deflectContributionV = (-deflectionError) * m_angularDeflectionEfficiency;
1367 deflectContribution /= m_angularDeflectionTimescale; 1365 deflectContributionV /= m_angularDeflectionTimescale;
1368 1366
1369 VehicleRotationalVelocity += deflectContribution * VehicleOrientation; 1367 VehicleRotationalVelocity += deflectContributionV * VehicleOrientation;
1370 1368
1371 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", 1369 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
1372 Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContribution); 1370 Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV);
1373 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3}", 1371 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3}",
1374 Prim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale); 1372 Prim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale);
1375 } 1373 }
@@ -1410,7 +1408,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1410 { 1408 {
1411 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1409 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1412 { 1410 {
1413 Vector3 bankingContribution = Vector3.Zero; 1411 Vector3 bankingContributionV = Vector3.Zero;
1414 1412
1415 // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented. 1413 // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented.
1416 // As the vehicle rolls to the right or left, the Y value will increase from 1414 // As the vehicle rolls to the right or left, the Y value will increase from
@@ -1428,15 +1426,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1428 mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f); 1426 mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f);
1429 1427
1430 // Build the force vector to change rotation from what it is to what it should be 1428 // Build the force vector to change rotation from what it is to what it should be
1431 bankingContribution.Z = -mixedYawAngle; 1429 bankingContributionV.Z = -mixedYawAngle;
1432 1430
1433 // Don't do it all at once. 1431 // Don't do it all at once.
1434 bankingContribution /= m_bankingTimescale; 1432 bankingContributionV /= m_bankingTimescale;
1435 1433
1436 VehicleRotationalVelocity += bankingContribution * VehicleOrientation; 1434 VehicleRotationalVelocity += bankingContributionV * VehicleOrientation;
1437 1435
1438 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", 1436 VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}",
1439 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContribution); 1437 Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV);
1440 } 1438 }
1441 } 1439 }
1442 1440
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 731ab7b..f80084a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -1619,7 +1619,7 @@ public sealed class BSPrim : BSPhysObject
1619 // entprop.RotationalVelocity = OMV.Vector3.Zero; 1619 // entprop.RotationalVelocity = OMV.Vector3.Zero;
1620 } 1620 }
1621 1621
1622 DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1622 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1623 1623
1624 // Undo any center-of-mass displacement that might have been done. 1624 // Undo any center-of-mass displacement that might have been done.
1625 if (PositionDisplacement != OMV.Vector3.Zero) 1625 if (PositionDisplacement != OMV.Vector3.Zero)
@@ -1636,7 +1636,7 @@ public sealed class BSPrim : BSPhysObject
1636 _acceleration = entprop.Acceleration; 1636 _acceleration = entprop.Acceleration;
1637 _rotationalVelocity = entprop.RotationalVelocity; 1637 _rotationalVelocity = entprop.RotationalVelocity;
1638 1638
1639 DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1639 // DetailLog("{0},BSPrim.UpdateProperties,afterAssign,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1640 1640
1641 // The sanity check can change the velocity and/or position. 1641 // The sanity check can change the velocity and/or position.
1642 if (IsPhysical && PositionSanityCheck(true)) 1642 if (IsPhysical && PositionSanityCheck(true))