BulletSim: reduce the force of gravity on ground vehicles when they

are on the ground. Makes them a little more stable.
user_profiles
Robert Adams 2013-01-24 16:26:04 -08:00
parent a2a32fc844
commit 6a5d088197
1 changed files with 11 additions and 0 deletions

View File

@ -158,6 +158,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); } get { return (Type != Vehicle.TYPE_NONE && Prim.IsPhysicallyActive); }
} }
// Return 'true' if this a vehicle that should be sitting on the ground
public bool IsGroundVehicle
{
get { return (Type == Vehicle.TYPE_CAR || Type == Vehicle.TYPE_SLED); }
}
#region Vehicle parameter setting #region Vehicle parameter setting
internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue)
{ {
@ -1176,6 +1182,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
private void ApplyGravity(float pTimeStep) private void ApplyGravity(float pTimeStep)
{ {
Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass;
// Hack to reduce downward force if the vehicle is probably sitting on the ground
if (Prim.IsColliding && IsGroundVehicle)
appliedGravity *= 0.2f;
VehicleAddForce(appliedGravity); VehicleAddForce(appliedGravity);
VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}", VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},appliedForce-{2}",