BulletSim: add INI parameter for angular banking timescale fudge parameter.

user_profiles
Robert Adams 2013-03-16 15:34:07 -07:00
parent fc84ebb819
commit 464201b41d
2 changed files with 12 additions and 7 deletions

View File

@ -1437,21 +1437,21 @@ namespace OpenSim.Region.Physics.BulletSPlugin
// As the vehicle rolls to the right or left, the Y value will increase from
// zero (straight up) to 1 or -1 (full tilt right or left)
Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation;
// Figure out the yaw value for this much roll.
// Squared because that seems to give a good value
// float yawAngle = (float)Math.Asin(rollComponents.X * rollComponents.X) * m_bankingEfficiency;
float yawAngle = m_angularMotorDirection.X * m_bankingEfficiency;
// actual error = static turn error + dynamic turn error
float mixedYawAngle =(yawAngle * (1f - m_bankingMix)) + ((yawAngle * m_bankingMix) * VehicleForwardSpeed);
// TODO: the banking effect should not go to infinity but what to limit it to? and what should happen when this is
// being added to a user defined yaw that is already PI*4?
// TODO: the banking effect should not go to infinity but what to limit it to?
// And what should happen when this is being added to a user defined yaw that is already PI*4?
mixedYawAngle = ClampInRange(-12, mixedYawAngle, 12);
// Build the force vector to change rotation from what it is to what it should be
bankingContributionV.Z = -mixedYawAngle;
// Don't do it all at once. 60 becouse 1 second is too fast with most user defined roll as PI*4
bankingContributionV /= m_bankingTimescale*60;
// Don't do it all at once. Fudge because 1 second is too fast with most user defined roll as PI*4.
bankingContributionV /= m_bankingTimescale * BSParam.VehicleAngularBankingTimescaleFudge;
//VehicleRotationalVelocity += bankingContributionV * VehicleOrientation;
VehicleRotationalVelocity += bankingContributionV;

View File

@ -123,6 +123,7 @@ public static class BSParam
public static Vector3 VehicleLinearFactor { get; private set; }
public static Vector3 VehicleAngularFactor { get; private set; }
public static float VehicleGroundGravityFudge { get; private set; }
public static float VehicleAngularBankingTimescaleFudge { get; private set; }
public static bool VehicleDebuggingEnabled { get; private set; }
// Linkset implementation parameters
@ -543,10 +544,14 @@ public static class BSParam
0.0f,
(s) => { return VehicleRestitution; },
(s,v) => { VehicleRestitution = v; } ),
new ParameterDefn<float>("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)",
new ParameterDefn<float>("VehicleGroundGravityFudge", "Factor to multiply gravity if a ground vehicle is probably on the ground (0.0 - 1.0)",
0.2f,
(s) => { return VehicleGroundGravityFudge; },
(s,v) => { VehicleGroundGravityFudge = v; } ),
new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
60.0f,
(s) => { return VehicleAngularBankingTimescaleFudge; },
(s,v) => { VehicleAngularBankingTimescaleFudge = v; } ),
new ParameterDefn<bool>("VehicleDebuggingEnable", "Turn on/off vehicle debugging",
false,
(s) => { return VehicleDebuggingEnabled; },