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)
{
// 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);
}
// =======================================================================

View File

@ -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;

View File

@ -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))); },