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
parent
065f8f56a2
commit
2c761cef19
|
@ -905,6 +905,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
|
||||
}
|
||||
}
|
||||
|
||||
private float VehicleForwardSpeed
|
||||
{
|
||||
get
|
||||
|
@ -1040,6 +1041,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
Vector3 linearDeflectionV = Vector3.Zero;
|
||||
Vector3 velocityV = VehicleForwardVelocity;
|
||||
|
||||
if (BSParam.VehicleEnableLinearDeflection)
|
||||
{
|
||||
// Velocity in Y and Z dimensions is movement to the side or turning.
|
||||
// Compute deflection factor from the to the side and rotational velocity
|
||||
linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
|
||||
|
@ -1055,12 +1058,21 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// Subtract the sideways and rotational velocity deflection factors while adding the correction forward
|
||||
linearDeflectionV *= new Vector3(1, -1, -1);
|
||||
|
||||
// Correciont is vehicle relative. Convert to world coordinates and add to the velocity
|
||||
VehicleVelocity += linearDeflectionV * VehicleOrientation;
|
||||
// Correction is vehicle relative. Convert to world coordinates.
|
||||
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}",
|
||||
ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
|
||||
}
|
||||
}
|
||||
|
||||
public void ComputeLinearTerrainHeightCorrection(float pTimestep)
|
||||
{
|
||||
|
|
|
@ -155,6 +155,8 @@ public static class BSParam
|
|||
public static Vector3 VehicleInertiaFactor { get; private set; }
|
||||
public static float VehicleGroundGravityFudge { 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 int VehicleAngularVerticalAttractionAlgorithm { get; private set; }
|
||||
public static bool VehicleEnableAngularDeflection { get; private set; }
|
||||
|
@ -609,10 +611,14 @@ public static class BSParam
|
|||
0.2f ),
|
||||
new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
|
||||
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",
|
||||
true ),
|
||||
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",
|
||||
true ),
|
||||
new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect",
|
||||
|
|
Loading…
Reference in New Issue