From 36f401d85011b0ffb548e79923381be894dbfabb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 25 Jan 2013 16:52:16 -0800 Subject: BulletSim: parameterize the value for gravity reduction for ground vehicles on the ground. Set defaults for vehicle factors to one. Debug logging changes. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 15 ++++++++------- OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 12 +++++++++--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 06b4620..90482fd 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -976,8 +976,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin public void ComputeLinearVelocity(float pTimestep) { // Step the motor from the current value. Get the correction needed this step. - Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation); - Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVel); + Vector3 origVelW = VehicleVelocity; // DEBUG + Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation); + Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV); // Motor is vehicle coordinates. Rotate it to world coordinates Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation; @@ -992,8 +993,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Add this correction to the velocity to make it faster/slower. VehicleVelocity += linearMotorVelocityW; - VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}", - Prim.LocalID, VehicleVelocity, linearMotorCorrectionV, linearMotorVelocityW); + VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5}", + Prim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity); } public void ComputeLinearTerrainHeightCorrection(float pTimestep) @@ -1193,12 +1194,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Hack to reduce downward force if the vehicle is probably sitting on the ground if (Prim.IsColliding && IsGroundVehicle) - appliedGravity *= 0.2f; + appliedGravity *= BSParam.VehicleGroundGravityFudge; VehicleAddForce(appliedGravity); - VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", - Prim.LocalID, m_VehicleGravity, appliedGravity); + VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},appliedForce={3}", + Prim.LocalID, m_VehicleGravity, Prim.IsColliding, appliedGravity); } // ======================================================================= diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 2c8dd23..6c53c50 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -232,7 +232,7 @@ public sealed class BSLinksetCompound : BSLinkset newLsi.OffsetFromCenterOfMass, newLsi.OffsetRot, true /* shouldRecalculateLocalAabb */); - DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1}newLsi={2}", + DetailLog("{0},BSLinksetCompound.UpdateProperties,changeChildPosRot,whichUpdated={1},newLsi={2}", updated.LocalID, whichUpdated, newLsi); updated.LinksetInfo = newLsi; updatedChild = true; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 8de8905..75eed86 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -110,6 +110,7 @@ public static class BSParam return (Vector3)vehicleAngularFactorV; } } + public static float VehicleGroundGravityFudge { get; private set; } public static float VehicleDebuggingEnabled { get; private set; } public static float LinksetImplementation { get; private set; } @@ -480,12 +481,12 @@ public static class BSParam (s) => { return VehicleAngularDamping; }, (s,p,l,v) => { VehicleAngularDamping = v; } ), new ParameterDefn("VehicleLinearFactor", "Fraction of physical linear changes applied to vehicle (0.0 - 1.0)", - 0.2f, + 1.0f, (s,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); }, (s) => { return VehicleLinearFactor; }, (s,p,l,v) => { VehicleLinearFactor = v; } ), new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)", - 0.2f, + 1.0f, (s,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); }, (s) => { return VehicleAngularFactor; }, (s,p,l,v) => { VehicleAngularFactor = v; } ), @@ -495,10 +496,15 @@ public static class BSParam (s) => { return VehicleFriction; }, (s,p,l,v) => { VehicleFriction = v; } ), new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)", - 0.0f, + 0.2f, (s,cf,p,v) => { VehicleRestitution = cf.GetFloat(p, v); }, (s) => { return VehicleRestitution; }, (s,p,l,v) => { VehicleRestitution = v; } ), + new ParameterDefn("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", + 1.0f, + (s,cf,p,v) => { VehicleGroundGravityFudge = cf.GetFloat(p, v); }, + (s) => { return VehicleGroundGravityFudge; }, + (s,p,l,v) => { VehicleGroundGravityFudge = v; } ), new ParameterDefn("VehicleDebuggingEnable", "Turn on/off vehicle debugging", ConfigurationParameters.numericFalse, (s,cf,p,v) => { VehicleDebuggingEnabled = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, -- cgit v1.1