ubitODE fix force in case of mlinear motor offset present

avinationmerge
UbitUmarov 2012-05-13 01:28:20 +01:00
parent 9b7023a159
commit 9870d7e4e7
1 changed files with 5 additions and 4 deletions

View File

@ -750,6 +750,9 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
IntPtr Body = rootPrim.Body; IntPtr Body = rootPrim.Body;
d.Mass dmass;
d.BodyGetMass(Body, out dmass);
d.Quaternion rot = d.BodyGetQuaternion(Body); d.Quaternion rot = d.BodyGetQuaternion(Body);
Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object
Quaternion rotq = objrotq; // rotq = rotation of object Quaternion rotq = objrotq; // rotq = rotation of object
@ -791,7 +794,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0) if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0)
{ {
// have offset, do it now // have offset, do it now
tmpV *= rootPrim.Mass; tmpV *= dmass.mass;
d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z);
} }
else else
@ -1058,13 +1061,11 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
d.Mass dmass;
d.BodyGetMass(Body,out dmass);
if (force.X != 0 || force.Y != 0 || force.Z != 0) if (force.X != 0 || force.Y != 0 || force.Z != 0)
{ {
force *= dmass.mass; force *= dmass.mass;
d.BodySetForce(Body, force.X, force.Y, force.Z); d.BodyAddForce(Body, force.X, force.Y, force.Z);
} }
if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) if (torque.X != 0 || torque.Y != 0 || torque.Z != 0)