BulletSim: add parameter to optionally disable vehicle linear deflection.

Add parameter to not apply vehicle linear deflection Z forces if
vehicle is not colliding. This defaults to 'true' so vehicles will fall
even if there is some linear deflection to apply.
cpu-performance
Robert Adams 2013-07-09 09:33:46 -07:00
parent 065f8f56a2
commit 2c761cef19
2 changed files with 34 additions and 16 deletions

View File

@ -905,6 +905,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation)); return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
} }
} }
private float VehicleForwardSpeed private float VehicleForwardSpeed
{ {
get get
@ -1040,6 +1041,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
Vector3 linearDeflectionV = Vector3.Zero; Vector3 linearDeflectionV = Vector3.Zero;
Vector3 velocityV = VehicleForwardVelocity; Vector3 velocityV = VehicleForwardVelocity;
if (BSParam.VehicleEnableLinearDeflection)
{
// Velocity in Y and Z dimensions is movement to the side or turning. // Velocity in Y and Z dimensions is movement to the side or turning.
// Compute deflection factor from the to the side and rotational velocity // Compute deflection factor from the to the side and rotational velocity
linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y); linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
@ -1053,14 +1056,23 @@ namespace OpenSim.Region.Physics.BulletSPlugin
linearDeflectionV *= pTimestep; linearDeflectionV *= pTimestep;
// Subtract the sideways and rotational velocity deflection factors while adding the correction forward // Subtract the sideways and rotational velocity deflection factors while adding the correction forward
linearDeflectionV *= new Vector3(1,-1,-1); linearDeflectionV *= new Vector3(1, -1, -1);
// Correciont is vehicle relative. Convert to world coordinates and add to the velocity // Correction is vehicle relative. Convert to world coordinates.
VehicleVelocity += linearDeflectionV * VehicleOrientation; Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation;
// Optionally, if not colliding, don't effect world downward velocity. Let falling things fall.
if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding)
{
linearDeflectionW.Z = 0f;
}
VehicleVelocity += linearDeflectionW;
VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}", VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}",
ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV); ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
} }
}
public void ComputeLinearTerrainHeightCorrection(float pTimestep) public void ComputeLinearTerrainHeightCorrection(float pTimestep)
{ {

View File

@ -155,6 +155,8 @@ public static class BSParam
public static Vector3 VehicleInertiaFactor { get; private set; } public static Vector3 VehicleInertiaFactor { get; private set; }
public static float VehicleGroundGravityFudge { get; private set; } public static float VehicleGroundGravityFudge { get; private set; }
public static float VehicleAngularBankingTimescaleFudge { get; private set; } public static float VehicleAngularBankingTimescaleFudge { get; private set; }
public static bool VehicleEnableLinearDeflection { get; private set; }
public static bool VehicleLinearDeflectionNotCollidingNoZ { get; private set; }
public static bool VehicleEnableAngularVerticalAttraction { get; private set; } public static bool VehicleEnableAngularVerticalAttraction { get; private set; }
public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; } public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; }
public static bool VehicleEnableAngularDeflection { get; private set; } public static bool VehicleEnableAngularDeflection { get; private set; }
@ -609,10 +611,14 @@ public static class BSParam
0.2f ), 0.2f ),
new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.", new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
60.0f ), 60.0f ),
new ParameterDefn<bool>("VehicleEnableLinearDeflection", "Turn on/off vehicle linear deflection effect",
true ),
new ParameterDefn<bool>("VehicleLinearDeflectionNotCollidingNoZ", "Turn on/off linear deflection Z effect on non-colliding vehicles",
true ),
new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect", new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect",
true ), true ),
new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.", new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.",
1 ), 0 ),
new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect", new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect",
true ), true ),
new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect", new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect",