From 93e1986d690cda415c9cce639a2656bc773a9a29 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 6 May 2013 16:48:01 -0700 Subject: BulletSim: apply linear and angular friction in vehicle coordinates and not world coordinates. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 272a162..04ea289 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1042,12 +1042,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin VehicleVelocity += linearMotorVelocityW; // Friction reduces vehicle motion - Vector3 frictionFactor = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep); - VehicleVelocity -= (VehicleVelocity * frictionFactor); + Vector3 frictionFactorW = ComputeFrictionFactor(m_linearFrictionTimescale, pTimestep) * VehicleOrientation; + VehicleVelocity -= (VehicleVelocity * frictionFactorW); VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}", ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, - linearMotorVelocityW, VehicleVelocity, frictionFactor); + linearMotorVelocityW, VehicleVelocity, frictionFactorW); } public void ComputeLinearTerrainHeightCorrection(float pTimestep) @@ -1340,10 +1340,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin VehicleRotationalVelocity += angularMotorContributionV * VehicleOrientation; // Reduce any velocity by friction. - Vector3 frictionFactor = ComputeFrictionFactor(m_angularFrictionTimescale, pTimestep); - VehicleRotationalVelocity -= (VehicleRotationalVelocity * frictionFactor); + Vector3 frictionFactorW = ComputeFrictionFactor(m_angularFrictionTimescale, pTimestep) * VehicleOrientation; + VehicleRotationalVelocity -= (VehicleRotationalVelocity * frictionFactorW); - VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", ControllingPrim.LocalID, angularMotorContributionV); + VDetailLog("{0}, MoveAngular,angularTurning,angContribV={1}", ControllingPrim.LocalID, angularMotorContributionV); } // From http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial: -- cgit v1.1