apply external forces and torque to vehicles also, as other engines do

LSLKeyTest
UbitUmarov 2016-08-04 16:24:19 +01:00
parent ad76687227
commit 3f2291611f
2 changed files with 15 additions and 8 deletions

View File

@ -935,8 +935,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
float roll;
float pitch;
float ftmp = m_invtimestep / m_verticalAttractionTimescale / m_verticalAttractionTimescale;
float ftmp2;
@ -957,7 +955,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
effroll = 1 - effroll;
effroll *= roll;
torque.X += effroll * ftmp;
if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) == 0)
@ -1074,10 +1071,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
torque.Z -= curLocalAngVel.Z * m_amdampZ;
}
force *= dmass.mass;
force += rootPrim.m_force;
force += rootPrim.m_forceacc;
rootPrim.m_forceacc = Vector3.Zero;
if (force.X != 0 || force.Y != 0 || force.Z != 0)
{
force *= dmass.mass;
d.BodyAddForce(Body, force.X, force.Y, force.Z);
}
@ -1091,6 +1092,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
d.MultiplyM3V3(out dvtmp, ref dmass.I, ref dtorque);
d.BodyAddRelTorque(Body, dvtmp.X, dvtmp.Y, dvtmp.Z); // add torque in object frame
}
torque = rootPrim.m_torque;
torque += rootPrim.m_angularForceacc;
rootPrim.m_angularForceacc = Vector3.Zero;
if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)
d.BodyAddTorque(Body,torque.X, torque.Y, torque.Z);
}
}
}

View File

@ -81,7 +81,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private Vector3 _position;
private Vector3 _velocity;
private Vector3 m_torque;
private Vector3 m_lastVelocity;
private Vector3 m_lastposition;
private Vector3 m_rotationalVelocity;
@ -89,9 +88,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
private Vector3 _acceleration;
private IntPtr Amotor;
private Vector3 m_force;
private Vector3 m_forceacc;
private Vector3 m_angularForceacc;
internal Vector3 m_force;
internal Vector3 m_forceacc;
internal Vector3 m_torque;
internal Vector3 m_angularForceacc;
private float m_invTimeStep;
private float m_timeStep;