BulletSim: parameterize the value for gravity reduction for ground vehicles on the ground. Set defaults for vehicle factors to one. Debug logging changes.

user_profiles
Robert Adams 2013-01-25 16:52:16 -08:00
parent ddef8f16e5
commit 36f401d850
3 changed files with 18 additions and 11 deletions

View File

@ -976,8 +976,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
public void ComputeLinearVelocity(float pTimestep) public void ComputeLinearVelocity(float pTimestep)
{ {
// Step the motor from the current value. Get the correction needed this step. // Step the motor from the current value. Get the correction needed this step.
Vector3 currentVel = VehicleVelocity * Quaternion.Inverse(VehicleOrientation); Vector3 origVelW = VehicleVelocity; // DEBUG
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVel); Vector3 currentVelV = VehicleVelocity * Quaternion.Inverse(VehicleOrientation);
Vector3 linearMotorCorrectionV = m_linearMotor.Step(pTimestep, currentVelV);
// Motor is vehicle coordinates. Rotate it to world coordinates // Motor is vehicle coordinates. Rotate it to world coordinates
Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation; Vector3 linearMotorVelocityW = linearMotorCorrectionV * VehicleOrientation;
@ -992,8 +993,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// Add this correction to the velocity to make it faster/slower. // Add this correction to the velocity to make it faster/slower.
VehicleVelocity += linearMotorVelocityW; VehicleVelocity += linearMotorVelocityW;
VDetailLog("{0}, MoveLinear,velocity,vehVel={1},correction={2},force={3}", VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5}",
Prim.LocalID, VehicleVelocity, linearMotorCorrectionV, linearMotorVelocityW); Prim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity);
} }
public void ComputeLinearTerrainHeightCorrection(float pTimestep) 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 // Hack to reduce downward force if the vehicle is probably sitting on the ground
if (Prim.IsColliding && IsGroundVehicle) if (Prim.IsColliding && IsGroundVehicle)
appliedGravity *= 0.2f; appliedGravity *= BSParam.VehicleGroundGravityFudge;
VehicleAddForce(appliedGravity); VehicleAddForce(appliedGravity);
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},appliedForce={3}",
Prim.LocalID, m_VehicleGravity, appliedGravity); Prim.LocalID, m_VehicleGravity, Prim.IsColliding, appliedGravity);
} }
// ======================================================================= // =======================================================================

View File

@ -232,7 +232,7 @@ public sealed class BSLinksetCompound : BSLinkset
newLsi.OffsetFromCenterOfMass, newLsi.OffsetFromCenterOfMass,
newLsi.OffsetRot, newLsi.OffsetRot,
true /* shouldRecalculateLocalAabb */); 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.LocalID, whichUpdated, newLsi);
updated.LinksetInfo = newLsi; updated.LinksetInfo = newLsi;
updatedChild = true; updatedChild = true;

View File

@ -110,6 +110,7 @@ public static class BSParam
return (Vector3)vehicleAngularFactorV; return (Vector3)vehicleAngularFactorV;
} }
} }
public static float VehicleGroundGravityFudge { get; private set; }
public static float VehicleDebuggingEnabled { get; private set; } public static float VehicleDebuggingEnabled { get; private set; }
public static float LinksetImplementation { get; private set; } public static float LinksetImplementation { get; private set; }
@ -480,12 +481,12 @@ public static class BSParam
(s) => { return VehicleAngularDamping; }, (s) => { return VehicleAngularDamping; },
(s,p,l,v) => { VehicleAngularDamping = v; } ), (s,p,l,v) => { VehicleAngularDamping = v; } ),
new ParameterDefn("VehicleLinearFactor", "Fraction of physical linear changes applied to vehicle (0.0 - 1.0)", 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,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); },
(s) => { return VehicleLinearFactor; }, (s) => { return VehicleLinearFactor; },
(s,p,l,v) => { VehicleLinearFactor = v; } ), (s,p,l,v) => { VehicleLinearFactor = v; } ),
new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)", 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,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); },
(s) => { return VehicleAngularFactor; }, (s) => { return VehicleAngularFactor; },
(s,p,l,v) => { VehicleAngularFactor = v; } ), (s,p,l,v) => { VehicleAngularFactor = v; } ),
@ -495,10 +496,15 @@ public static class BSParam
(s) => { return VehicleFriction; }, (s) => { return VehicleFriction; },
(s,p,l,v) => { VehicleFriction = v; } ), (s,p,l,v) => { VehicleFriction = v; } ),
new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)", 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,cf,p,v) => { VehicleRestitution = cf.GetFloat(p, v); },
(s) => { return VehicleRestitution; }, (s) => { return VehicleRestitution; },
(s,p,l,v) => { VehicleRestitution = v; } ), (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", new ParameterDefn("VehicleDebuggingEnable", "Turn on/off vehicle debugging",
ConfigurationParameters.numericFalse, ConfigurationParameters.numericFalse,
(s,cf,p,v) => { VehicleDebuggingEnabled = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, (s,cf,p,v) => { VehicleDebuggingEnabled = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },