aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
diff options
context:
space:
mode:
authorMelanie2012-12-18 09:45:40 +0000
committerMelanie2012-12-18 09:45:40 +0000
commitcaea7601cb64be6c872dd44b61df10fb2e5f4e96 (patch)
tree9cba3186c574d3ecbef73646e0efc3ab3b68f90c /OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
parentMerge branch 'master' into careminster (diff)
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-caea7601cb64be6c872dd44b61df10fb2e5f4e96.zip
opensim-SC_OLD-caea7601cb64be6c872dd44b61df10fb2e5f4e96.tar.gz
opensim-SC_OLD-caea7601cb64be6c872dd44b61df10fb2e5f4e96.tar.bz2
opensim-SC_OLD-caea7601cb64be6c872dd44b61df10fb2e5f4e96.tar.xz
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs39
1 files changed, 18 insertions, 21 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index ef68471..5887249 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,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1049 // ================================================================== 1051 // ==================================================================
1050 m_lastVertAttractor = verticalAttractionContribution; 1052 m_lastVertAttractor = verticalAttractionContribution;
1051 1053
1052 // Sum corrections 1054 m_lastAngularVelocity = angularMotorContribution
1053 m_lastAngularCorrection = angularMotorContribution
1054 + verticalAttractionContribution 1055 + verticalAttractionContribution
1055 + deflectionContribution 1056 + deflectionContribution
1056 + bankingContribution; 1057 + bankingContribution;
@@ -1058,19 +1059,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1058 // ================================================================== 1059 // ==================================================================
1059 // Apply the correction velocity. 1060 // Apply the correction velocity.
1060 // TODO: Should this be applied as an angular force (torque)? 1061 // TODO: Should this be applied as an angular force (torque)?
1061 if (!m_lastAngularCorrection.ApproxEquals(Vector3.Zero, 0.01f)) 1062 if (!m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
1062 { 1063 {
1063 // DEBUG DEBUG DEBUG: optionally scale the angular velocity. Debugging SL vs ODE turning functions. 1064 VehicleRotationalVelocity = m_lastAngularVelocity;
1064 Vector3 scaledCorrection = m_lastAngularCorrection;
1065 if (PhysicsScene.VehicleScaleAngularVelocityByTimestep)
1066 scaledCorrection *= pTimestep;
1067 VehicleRotationalVelocity = scaledCorrection;
1068 1065
1069 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5},scaledCorr={6}", 1066 VDetailLog("{0}, MoveAngular,done,nonZero,angMotorContrib={1},vertAttrContrib={2},bankContrib={3},deflectContrib={4},totalContrib={5}",
1070 Prim.LocalID, 1067 Prim.LocalID,
1071 angularMotorContribution, verticalAttractionContribution, 1068 angularMotorContribution, verticalAttractionContribution,
1072 bankingContribution, deflectionContribution, 1069 bankingContribution, deflectionContribution,
1073 m_lastAngularCorrection, scaledCorrection 1070 m_lastAngularVelocity
1074 ); 1071 );
1075 } 1072 }
1076 else 1073 else
@@ -1124,18 +1121,18 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1124 { 1121 {
1125 Vector3 ret = Vector3.Zero; 1122 Vector3 ret = Vector3.Zero;
1126 1123
1127 // If vertical attaction timescale is reasonable and we applied an angular force last time... 1124 // If vertical attaction timescale is reasonable
1128 if (m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1125 if (m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1129 { 1126 {
1130 // Take a vector pointing up and convert it from world to vehicle relative coords. 1127 // Take a vector pointing up and convert it from world to vehicle relative coords.
1131 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; 1128 Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
1132 verticalError.Normalize();
1133 1129
1134 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ) 1130 // 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 1131 // is now:
1136 // go from zero (nearly straight up) to one (completely to the side) or leaning 1132 // 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 1133 // from zero (nearly straight up) to one (completely to the side)) or
1138 // zero and one. 1134 // leaning front-to-back: rotated around the Y axis with the value of X being between
1135 // zero and one.
1139 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees. 1136 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees.
1140 1137
1141 // If verticalError.Z is negative, the vehicle is upside down. Add additional push. 1138 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.