aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs38
1 files changed, 33 insertions, 5 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 311cf4f..51207f1 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -209,7 +209,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
209 m_VhoverTimescale = Math.Max(pValue, 0.01f); 209 m_VhoverTimescale = Math.Max(pValue, 0.01f);
210 break; 210 break;
211 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 211 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
212 m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f); 212 m_linearDeflectionEfficiency = ClampInRange(0f, pValue, 1f);
213 break; 213 break;
214 case Vehicle.LINEAR_DEFLECTION_TIMESCALE: 214 case Vehicle.LINEAR_DEFLECTION_TIMESCALE:
215 m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); 215 m_linearDeflectionTimescale = Math.Max(pValue, 0.01f);
@@ -1029,9 +1029,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1029 Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation); 1029 Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
1030 Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV); 1030 Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV);
1031 1031
1032 //Compute Linear deflection.
1033 Vector3 linearDeflectionFactorV = ComputeLinearDeflection(m_linearDeflectionEfficiency, currentVelV, pTimestep);
1034 linearMotorCorrectionV += linearDeflectionFactorV;
1035
1032 // Friction reduces vehicle motion 1036 // Friction reduces vehicle motion
1033 Vector3 frictionFactorW = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep); 1037 Vector3 frictionFactorV = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep);
1034 linearMotorCorrectionV -= (currentVelV * frictionFactorW); 1038 linearMotorCorrectionV -= (currentVelV * frictionFactorV);
1035 1039
1036 // Motor is vehicle coordinates. Rotate it to world coordinates 1040 // Motor is vehicle coordinates. Rotate it to world coordinates
1037 Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation; 1041 Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
@@ -1048,9 +1052,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1048 1052
1049 1053
1050 1054
1051 VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}", 1055 VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6},LinearDeflec={7}",
1052 ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, 1056 ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV,
1053 linearMotorVelocityW, VehicleVelocity, frictionFactorW); 1057 linearMotorVelocityW, VehicleVelocity, frictionFactorV, linearDeflectionFactorV);
1054 } 1058 }
1055 1059
1056 public void ComputeLinearTerrainHeightCorrection(float pTimestep) 1060 public void ComputeLinearTerrainHeightCorrection(float pTimestep)
@@ -1651,6 +1655,30 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1651 } 1655 }
1652 return frictionFactor; 1656 return frictionFactor;
1653 } 1657 }
1658 //Given a Deflection Effiency and a Velocity, Returns a Velocity that is Partially Deflected onto the X Axis
1659 //Clamped so that a DeflectionTimescale of less then 1 does not increase force over original velocity
1660 private Vector3 ComputeLinearDeflection(float DeflectionEfficiency,Vector3 Velocity,float pTimestep)
1661 {
1662 Vector3 LinearDeflection = Vector3.Zero;
1663 LinearDeflection.Y = SortedClampInRange(0, (Velocity.Y * DeflectionEfficiency) / m_linearDeflectionTimescale, Velocity.Y);
1664 LinearDeflection.Z = SortedClampInRange(0, (Velocity.Z * DeflectionEfficiency) / m_linearDeflectionTimescale, Velocity.Z);
1665 LinearDeflection.X += Math.Abs(LinearDeflection.Y);
1666 LinearDeflection.X += Math.Abs(LinearDeflection.Z);
1667 LinearDeflection *= pTimestep;
1668 return LinearDeflection*=new Vector3(1,-1,-1);
1669
1670 }
1671 private float SortedClampInRange(float clampa, float val, float clampb)
1672 {
1673 if (clampa > clampb)
1674 {
1675 float temp = clampa;
1676 clampa = clampb;
1677 clampb = temp;
1678 }
1679 return ClampInRange(clampa, val, clampb);
1680
1681 }
1654 1682
1655 private float ClampInRange(float low, float val, float high) 1683 private float ClampInRange(float low, float val, float high)
1656 { 1684 {