diff options
author | Vegaslon | 2013-03-16 17:16:01 -0400 |
---|---|---|
committer | Robert Adams | 2013-03-16 15:13:40 -0700 |
commit | fc84ebb819b590099bbfa5bd357e886ce7460063 (patch) | |
tree | 075c828400d620ae03621e60b63788d8675f880b /OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |
parent | *Yet another HTTPServer update code changes in OpenSim Libs. * This fixes a c... (diff) | |
download | opensim-SC_OLD-fc84ebb819b590099bbfa5bd357e886ce7460063.zip opensim-SC_OLD-fc84ebb819b590099bbfa5bd357e886ce7460063.tar.gz opensim-SC_OLD-fc84ebb819b590099bbfa5bd357e886ce7460063.tar.bz2 opensim-SC_OLD-fc84ebb819b590099bbfa5bd357e886ce7460063.tar.xz |
BulletSim: Working Implementation of Angular Banking for Vehicles (Not SL Grade, Other features when implemented should slow it down for now be Strong with Vertical Angular attraction setting and conservative with Angular Velocity on X axis)
Signed-off-by: Robert Adams <Robert.Adams@intel.com>
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index d347159..96eaa6b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
143 | { | 143 | { |
144 | enableAngularVerticalAttraction = true; | 144 | enableAngularVerticalAttraction = true; |
145 | enableAngularDeflection = false; | 145 | enableAngularDeflection = false; |
146 | enableAngularBanking = false; | 146 | enableAngularBanking = true; |
147 | if (BSParam.VehicleDebuggingEnabled) | 147 | if (BSParam.VehicleDebuggingEnabled) |
148 | { | 148 | { |
149 | enableAngularVerticalAttraction = true; | 149 | enableAngularVerticalAttraction = true; |
@@ -1280,11 +1280,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1280 | // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement | 1280 | // That is, NO_DEFLECTION_UP says angular motion should not add any pitch or roll movement |
1281 | // TODO: This is here because this is where ODE put it but documentation says it | 1281 | // TODO: This is here because this is where ODE put it but documentation says it |
1282 | // is a linear effect. Where should this check go? | 1282 | // is a linear effect. Where should this check go? |
1283 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) | 1283 | //if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) |
1284 | { | 1284 | // { |
1285 | angularMotorContributionV.X = 0f; | 1285 | // angularMotorContributionV.X = 0f; |
1286 | angularMotorContributionV.Y = 0f; | 1286 | // angularMotorContributionV.Y = 0f; |
1287 | } | 1287 | // } |
1288 | 1288 | ||
1289 | VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation; | 1289 | VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation; |
1290 | VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV); | 1290 | VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContributionV); |
@@ -1437,24 +1437,25 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1437 | // As the vehicle rolls to the right or left, the Y value will increase from | 1437 | // As the vehicle rolls to the right or left, the Y value will increase from |
1438 | // zero (straight up) to 1 or -1 (full tilt right or left) | 1438 | // zero (straight up) to 1 or -1 (full tilt right or left) |
1439 | Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation; | 1439 | Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation; |
1440 | |||
1441 | // Figure out the yaw value for this much roll. | 1440 | // Figure out the yaw value for this much roll. |
1442 | // Squared because that seems to give a good value | 1441 | // Squared because that seems to give a good value |
1443 | float yawAngle = (float)Math.Asin(rollComponents.Y * rollComponents.Y) * m_bankingEfficiency; | 1442 | // float yawAngle = (float)Math.Asin(rollComponents.X * rollComponents.X) * m_bankingEfficiency; |
1444 | 1443 | float yawAngle = m_angularMotorDirection.X * m_bankingEfficiency; | |
1445 | // actual error = static turn error + dynamic turn error | 1444 | // actual error = static turn error + dynamic turn error |
1446 | float mixedYawAngle = yawAngle * (1f - m_bankingMix) + yawAngle * m_bankingMix * VehicleForwardSpeed; | 1445 | float mixedYawAngle =(yawAngle * (1f - m_bankingMix)) + ((yawAngle * m_bankingMix) * VehicleForwardSpeed); |
1447 | 1446 | // TODO: the banking effect should not go to infinity but what to limit it to? and what should happen when this is | |
1448 | // TODO: the banking effect should not go to infinity but what to limit it to? | 1447 | // being added to a user defined yaw that is already PI*4? |
1449 | mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f); | 1448 | mixedYawAngle = ClampInRange(-12, mixedYawAngle, 12); |
1450 | 1449 | ||
1451 | // Build the force vector to change rotation from what it is to what it should be | 1450 | // Build the force vector to change rotation from what it is to what it should be |
1452 | bankingContributionV.Z = -mixedYawAngle; | 1451 | bankingContributionV.Z = -mixedYawAngle; |
1453 | 1452 | ||
1454 | // Don't do it all at once. | 1453 | // Don't do it all at once. 60 becouse 1 second is too fast with most user defined roll as PI*4 |
1455 | bankingContributionV /= m_bankingTimescale; | 1454 | bankingContributionV /= m_bankingTimescale*60; |
1456 | 1455 | ||
1457 | VehicleRotationalVelocity += bankingContributionV * VehicleOrientation; | 1456 | //VehicleRotationalVelocity += bankingContributionV * VehicleOrientation; |
1457 | VehicleRotationalVelocity += bankingContributionV; | ||
1458 | |||
1458 | 1459 | ||
1459 | VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", | 1460 | VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", |
1460 | Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV); | 1461 | Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContributionV); |