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));
|
return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private float VehicleForwardSpeed
|
private float VehicleForwardSpeed
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1040,26 +1041,37 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
||||||
Vector3 linearDeflectionV = Vector3.Zero;
|
Vector3 linearDeflectionV = Vector3.Zero;
|
||||||
Vector3 velocityV = VehicleForwardVelocity;
|
Vector3 velocityV = VehicleForwardVelocity;
|
||||||
|
|
||||||
// Velocity in Y and Z dimensions is movement to the side or turning.
|
if (BSParam.VehicleEnableLinearDeflection)
|
||||||
// Compute deflection factor from the to the side and rotational velocity
|
{
|
||||||
linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
|
// Velocity in Y and Z dimensions is movement to the side or turning.
|
||||||
linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z);
|
// Compute deflection factor from the to the side and rotational velocity
|
||||||
|
linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
|
||||||
|
linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z);
|
||||||
|
|
||||||
// Velocity to the side and around is corrected and moved into the forward direction
|
// Velocity to the side and around is corrected and moved into the forward direction
|
||||||
linearDeflectionV.X += Math.Abs(linearDeflectionV.Y);
|
linearDeflectionV.X += Math.Abs(linearDeflectionV.Y);
|
||||||
linearDeflectionV.X += Math.Abs(linearDeflectionV.Z);
|
linearDeflectionV.X += Math.Abs(linearDeflectionV.Z);
|
||||||
|
|
||||||
// Scale the deflection to the fractional simulation time
|
// Scale the deflection to the fractional simulation time
|
||||||
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;
|
||||||
|
|
||||||
VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}",
|
// Optionally, if not colliding, don't effect world downward velocity. Let falling things fall.
|
||||||
ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
|
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)
|
public void ComputeLinearTerrainHeightCorrection(float pTimestep)
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in New Issue