BulletSim: simplify the initialization of some of the parameters.
Disable vertical attraction for vehicles by default (for the moment). Fix bug where vehicle would go crazy when velocity got above a certain speed.user_profiles
parent
26d4596080
commit
b546af9ac2
|
@ -141,7 +141,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// in changes by making enablement of debugging flags from INI file.
|
||||
public void SetupVehicleDebugging()
|
||||
{
|
||||
enableAngularVerticalAttraction = true;
|
||||
enableAngularVerticalAttraction = false;
|
||||
enableAngularDeflection = false;
|
||||
enableAngularBanking = false;
|
||||
if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse)
|
||||
|
@ -803,7 +803,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
m_knownVelocity = Prim.ForceVelocity;
|
||||
m_knownHas |= m_knownChangedVelocity;
|
||||
}
|
||||
return (Vector3)m_knownVelocity;
|
||||
return m_knownVelocity;
|
||||
}
|
||||
set
|
||||
{
|
||||
|
@ -926,6 +926,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// Called after the simulation step
|
||||
internal void PostStep(float pTimestep)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
if (PhysicsScene.VehiclePhysicalLoggingEnabled)
|
||||
PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody);
|
||||
}
|
||||
|
@ -961,10 +963,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
// ==================================================================
|
||||
// Clamp high or low velocities
|
||||
float newVelocityLengthSq = VehicleVelocity.LengthSquared();
|
||||
if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocity)
|
||||
if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySq)
|
||||
{
|
||||
Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG
|
||||
VehicleVelocity /= VehicleVelocity.Length();
|
||||
VehicleVelocity *= BSParam.VehicleMaxLinearVelocity;
|
||||
VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}",
|
||||
Prim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySq, VehicleVelocity);
|
||||
}
|
||||
else if (newVelocityLengthSq < 0.001f)
|
||||
VehicleVelocity = Vector3.Zero;
|
||||
|
@ -1301,6 +1306,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
|
||||
{
|
||||
Vector3 vertContributionV = Vector3.Zero;
|
||||
Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG
|
||||
|
||||
// Take a vector pointing up and convert it from world to vehicle relative coords.
|
||||
Vector3 verticalError = Vector3.UnitZ * VehicleOrientation;
|
||||
|
@ -1328,13 +1334,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
|
|||
|
||||
// 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
|
||||
// Correction happens over a number of seconds.
|
||||
Vector3 unscaledContrib = vertContributionV; // DEBUG DEBUG
|
||||
Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG
|
||||
vertContributionV /= m_verticalAttractionTimescale;
|
||||
|
||||
VehicleRotationalVelocity += vertContributionV * VehicleOrientation;
|
||||
|
||||
VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}",
|
||||
Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
|
||||
VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}",
|
||||
Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV,
|
||||
m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -84,32 +84,16 @@ public static class BSParam
|
|||
|
||||
// Vehicle parameters
|
||||
public static float VehicleMaxLinearVelocity { get; private set; }
|
||||
public static float VehicleMaxLinearVelocitySq { get; private set; }
|
||||
public static float VehicleMaxAngularVelocity { get; private set; }
|
||||
public static float VehicleMaxAngularVelocitySq { get; private set; }
|
||||
public static float VehicleAngularDamping { get; private set; }
|
||||
public static float VehicleFriction { get; private set; }
|
||||
public static float VehicleRestitution { get; private set; }
|
||||
public static float VehicleLinearFactor { get; private set; }
|
||||
private static Vector3? vehicleLinearFactorV;
|
||||
public static Vector3 VehicleLinearFactorV
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!vehicleLinearFactorV.HasValue)
|
||||
vehicleLinearFactorV = new Vector3(VehicleLinearFactor, VehicleLinearFactor, VehicleLinearFactor);
|
||||
return (Vector3)vehicleLinearFactorV;
|
||||
}
|
||||
}
|
||||
public static Vector3 VehicleLinearFactorV { get; private set; }
|
||||
public static float VehicleAngularFactor { get; private set; }
|
||||
private static Vector3? vehicleAngularFactorV;
|
||||
public static Vector3 VehicleAngularFactorV
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!vehicleAngularFactorV.HasValue)
|
||||
vehicleAngularFactorV = new Vector3(VehicleAngularFactor, VehicleAngularFactor, VehicleAngularFactor);
|
||||
return (Vector3)vehicleAngularFactorV;
|
||||
}
|
||||
}
|
||||
public static Vector3 VehicleAngularFactorV { get; private set; }
|
||||
public static float VehicleGroundGravityFudge { get; private set; }
|
||||
public static float VehicleDebuggingEnabled { get; private set; }
|
||||
|
||||
|
@ -469,12 +453,12 @@ public static class BSParam
|
|||
1000.0f,
|
||||
(s,cf,p,v) => { VehicleMaxLinearVelocity = cf.GetFloat(p, v); },
|
||||
(s) => { return (float)VehicleMaxLinearVelocity; },
|
||||
(s,p,l,v) => { VehicleMaxLinearVelocity = v; } ),
|
||||
(s,p,l,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySq = v * v; } ),
|
||||
new ParameterDefn("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle",
|
||||
12.0f,
|
||||
(s,cf,p,v) => { VehicleMaxAngularVelocity = cf.GetFloat(p, v); },
|
||||
(s) => { return (float)VehicleMaxAngularVelocity; },
|
||||
(s,p,l,v) => { VehicleMaxAngularVelocity = v; } ),
|
||||
(s,p,l,v) => { VehicleMaxAngularVelocity = v; VehicleMaxAngularVelocitySq = v * v; } ),
|
||||
new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)",
|
||||
0.0f,
|
||||
(s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); },
|
||||
|
@ -484,24 +468,24 @@ public static class BSParam
|
|||
1.0f,
|
||||
(s,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); },
|
||||
(s) => { return VehicleLinearFactor; },
|
||||
(s,p,l,v) => { VehicleLinearFactor = v; } ),
|
||||
(s,p,l,v) => { VehicleLinearFactor = v; VehicleLinearFactorV = new Vector3(v, v, v); } ),
|
||||
new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)",
|
||||
1.0f,
|
||||
(s,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); },
|
||||
(s) => { return VehicleAngularFactor; },
|
||||
(s,p,l,v) => { VehicleAngularFactor = v; } ),
|
||||
(s,p,l,v) => { VehicleAngularFactor = v; VehicleAngularFactorV = new Vector3(v, v, v); } ),
|
||||
new ParameterDefn("VehicleFriction", "Friction of vehicle on the ground (0.0 - 1.0)",
|
||||
0.0f,
|
||||
(s,cf,p,v) => { VehicleFriction = cf.GetFloat(p, v); },
|
||||
(s) => { return VehicleFriction; },
|
||||
(s,p,l,v) => { VehicleFriction = v; } ),
|
||||
new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)",
|
||||
0.2f,
|
||||
0.0f,
|
||||
(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,
|
||||
0.2f,
|
||||
(s,cf,p,v) => { VehicleGroundGravityFudge = cf.GetFloat(p, v); },
|
||||
(s) => { return VehicleGroundGravityFudge; },
|
||||
(s,p,l,v) => { VehicleGroundGravityFudge = v; } ),
|
||||
|
|
Loading…
Reference in New Issue