From 80b1e32bfa00a2d3354f0d7e0df83a5b0b3e2c49 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 21 Jan 2013 23:43:24 -0800 Subject: BulletSim: Tweeks to vehicle motion. Pass through old angular velocity making for smoother transitions. Remove some old kludges for angular motion (damping and rotvel suppression). --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 21 ++++++++------------- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 3 ++- 3 files changed, 11 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index f8fc3de..dbe44de 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1192,7 +1192,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // set directly on the vehicle. private void MoveAngular(float pTimestep) { - VehicleRotationalVelocity = Vector3.Zero; + // VehicleRotationalVelocity = Vector3.Zero; ComputeAngularTurning(pTimestep); @@ -1203,12 +1203,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin ComputeAngularBanking(); // ================================================================== - // All of the above computation are made relative to vehicle coordinates. - // Convert to world coordinates. - // TODO: Should this be applied as an angular force (torque)? - VehicleRotationalVelocity *= VehicleOrientation; - - // ================================================================== if (VehicleRotationalVelocity.ApproxEquals(Vector3.Zero, 0.01f)) { // The vehicle is not adding anything angular wise. @@ -1256,7 +1250,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin private void ComputeAngularTurning(float pTimestep) { // The user wants this many radians per second angular change? - Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep); + Vector3 currentAngular = VehicleRotationalVelocity * Quaternion.Inverse(VehicleOrientation); + Vector3 angularMotorContribution = m_angularMotor.Step(pTimestep, currentAngular); // ================================================================== // From http://wiki.secondlife.com/wiki/LlSetVehicleFlags : @@ -1272,7 +1267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin angularMotorContribution.Y = 0f; } - VehicleRotationalVelocity += angularMotorContribution; + VehicleRotationalVelocity += angularMotorContribution * VehicleOrientation; VDetailLog("{0}, MoveAngular,angularTurning,angularMotorContrib={1}", Prim.LocalID, angularMotorContribution); } @@ -1312,7 +1307,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin if (verticalError.Z < 0f) { vertContribution.X += PIOverFour; - vertContribution.Y += PIOverFour; + // vertContribution.Y -= PIOverFour; } // 'vertContrbution' is now the necessary angular correction to correct tilt in one second. @@ -1320,7 +1315,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 unscaledContrib = vertContribution; // DEBUG DEBUG vertContribution /= m_verticalAttractionTimescale; - VehicleRotationalVelocity += vertContribution; + VehicleRotationalVelocity += vertContribution * VehicleOrientation; VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}", Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContribution); @@ -1371,7 +1366,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin deflectContribution = (-deflectionError) * m_angularDeflectionEfficiency; deflectContribution /= m_angularDeflectionTimescale; - VehicleRotationalVelocity += deflectContribution; + VehicleRotationalVelocity += deflectContribution * VehicleOrientation; VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", Prim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContribution); @@ -1438,7 +1433,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Don't do it all at once. bankingContribution /= m_bankingTimescale; - VehicleRotationalVelocity += bankingContribution; + VehicleRotationalVelocity += bankingContribution * VehicleOrientation; VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, bankingContribution); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 2b4488a..da7438a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -450,7 +450,7 @@ public static class BSParam (s) => { return (float)VehicleMaxAngularVelocity; }, (s,p,l,v) => { VehicleMaxAngularVelocity = v; } ), new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)", - 0.95f, + 0.0f, (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); }, (s) => { return VehicleAngularDamping; }, (s,p,l,v) => { VehicleAngularDamping = v; } ), diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 468ff40..e6b8507 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1009,6 +1009,7 @@ public sealed class BSPrim : BSPhysObject { DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); PhysicsScene.PE.SetAngularVelocity(PhysBody, _rotationalVelocity); + // PhysicsScene.PE.SetInterpolationAngularVelocity(PhysBody, _rotationalVelocity); ActivateIfPhysical(false); } } @@ -1649,7 +1650,7 @@ public sealed class BSPrim : BSPhysObject // TODO: handle physics introduced by Bullet with computed vehicle physics. if (_vehicle.IsActive) { - entprop.RotationalVelocity = OMV.Vector3.Zero; + // entprop.RotationalVelocity = OMV.Vector3.Zero; } // Assign directly to the local variables so the normal set actions do not happen -- cgit v1.1