diff options
Diffstat (limited to 'OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs index e88e559..e27be1e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs | |||
@@ -63,6 +63,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
63 | private OdeScene _pParentScene; | 63 | private OdeScene _pParentScene; |
64 | 64 | ||
65 | // Vehicle properties | 65 | // Vehicle properties |
66 | // WARNING this are working copies for internel use | ||
67 | // their values may not be the corresponding parameter | ||
68 | |||
66 | private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier | 69 | private Quaternion m_referenceFrame = Quaternion.Identity; // Axis modifier |
67 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? | 70 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; // what hell is this ? |
68 | 71 | ||
@@ -244,6 +247,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
244 | if (pValue < m_timestep) pValue = m_timestep; | 247 | if (pValue < m_timestep) pValue = m_timestep; |
245 | else if (pValue > 120) pValue = 120; | 248 | else if (pValue > 120) pValue = 120; |
246 | m_angularMotorDecayTimescale = pValue * m_invtimestep; | 249 | m_angularMotorDecayTimescale = pValue * m_invtimestep; |
250 | m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; | ||
247 | break; | 251 | break; |
248 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: | 252 | case Vehicle.ANGULAR_MOTOR_TIMESCALE: |
249 | if (pValue < m_timestep) pValue = m_timestep; | 253 | if (pValue < m_timestep) pValue = m_timestep; |
@@ -293,6 +297,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
293 | if (pValue < m_timestep) pValue = m_timestep; | 297 | if (pValue < m_timestep) pValue = m_timestep; |
294 | else if (pValue > 120) pValue = 120; | 298 | else if (pValue > 120) pValue = 120; |
295 | m_linearMotorDecayTimescale = (0.2f +pValue) * m_invtimestep; | 299 | m_linearMotorDecayTimescale = (0.2f +pValue) * m_invtimestep; |
300 | m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale); | ||
296 | break; | 301 | break; |
297 | case Vehicle.LINEAR_MOTOR_TIMESCALE: | 302 | case Vehicle.LINEAR_MOTOR_TIMESCALE: |
298 | if (pValue < m_timestep) pValue = m_timestep; | 303 | if (pValue < m_timestep) pValue = m_timestep; |
@@ -320,7 +325,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
320 | if (len > 12.566f) | 325 | if (len > 12.566f) |
321 | m_angularMotorDirection *= (12.566f / len); | 326 | m_angularMotorDirection *= (12.566f / len); |
322 | 327 | ||
323 | m_amEfect = 1.0f / m_angularMotorTimescale; // turn it on | 328 | m_amEfect = 1.0f ; // turn it on |
324 | m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; | 329 | m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; |
325 | 330 | ||
326 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | 331 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) |
@@ -338,7 +343,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
338 | m_linearMotorDirection *= (100.0f / len); | 343 | m_linearMotorDirection *= (100.0f / len); |
339 | 344 | ||
340 | m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; | 345 | m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; |
341 | m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on | 346 | m_lmEfect = 1.0f; // turn it on |
342 | 347 | ||
343 | m_ffactor = 0.01f; | 348 | m_ffactor = 0.01f; |
344 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | 349 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) |
@@ -374,7 +379,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
374 | if (len > 12.566f) | 379 | if (len > 12.566f) |
375 | m_angularMotorDirection *= (12.566f / len); | 380 | m_angularMotorDirection *= (12.566f / len); |
376 | 381 | ||
377 | m_amEfect = 1.0f / m_angularMotorTimescale; // turn it on | 382 | m_amEfect = 1.0f; // turn it on |
378 | m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; | 383 | m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; |
379 | 384 | ||
380 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | 385 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) |
@@ -393,11 +398,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
393 | if (len > 100.0f) | 398 | if (len > 100.0f) |
394 | m_linearMotorDirection *= (100.0f / len); | 399 | m_linearMotorDirection *= (100.0f / len); |
395 | 400 | ||
396 | m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on | 401 | m_lmEfect = 1.0f; // turn it on |
397 | m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; | 402 | m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale; |
398 | 403 | ||
399 | |||
400 | |||
401 | m_ffactor = 0.01f; | 404 | m_ffactor = 0.01f; |
402 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) | 405 | if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) |
403 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) | 406 | && !rootPrim.m_isSelected && !rootPrim.m_disabled) |
@@ -747,6 +750,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
747 | { | 750 | { |
748 | IntPtr Body = rootPrim.Body; | 751 | IntPtr Body = rootPrim.Body; |
749 | 752 | ||
753 | d.Mass dmass; | ||
754 | d.BodyGetMass(Body, out dmass); | ||
755 | |||
750 | d.Quaternion rot = d.BodyGetQuaternion(Body); | 756 | d.Quaternion rot = d.BodyGetQuaternion(Body); |
751 | Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object | 757 | Quaternion objrotq = new Quaternion(rot.X, rot.Y, rot.Z, rot.W); // rotq = rotation of object |
752 | Quaternion rotq = objrotq; // rotq = rotation of object | 758 | Quaternion rotq = objrotq; // rotq = rotation of object |
@@ -776,10 +782,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
776 | float ldampZ = 0; | 782 | float ldampZ = 0; |
777 | 783 | ||
778 | // linear motor | 784 | // linear motor |
779 | if (m_lmEfect > 0.001 && m_linearMotorTimescale < 1000) | 785 | if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) |
780 | { | 786 | { |
781 | tmpV = m_linearMotorDirection - curLocalVel; // velocity error | 787 | tmpV = m_linearMotorDirection - curLocalVel; // velocity error |
782 | tmpV *= m_lmEfect; // error to correct in this timestep | 788 | tmpV *= m_lmEfect / m_linearMotorTimescale; // error to correct in this timestep |
783 | tmpV *= rotq; // to world | 789 | tmpV *= rotq; // to world |
784 | 790 | ||
785 | if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) | 791 | if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) |
@@ -788,7 +794,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
788 | if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0) | 794 | if (m_linearMotorOffset.X != 0 || m_linearMotorOffset.Y != 0 || m_linearMotorOffset.Z != 0) |
789 | { | 795 | { |
790 | // have offset, do it now | 796 | // have offset, do it now |
791 | tmpV *= rootPrim.Mass; | 797 | tmpV *= dmass.mass; |
792 | d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); | 798 | d.BodyAddForceAtRelPos(Body, tmpV.X, tmpV.Y, tmpV.Z, m_linearMotorOffset.X, m_linearMotorOffset.Y, m_linearMotorOffset.Z); |
793 | } | 799 | } |
794 | else | 800 | else |
@@ -799,9 +805,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
799 | } | 805 | } |
800 | 806 | ||
801 | m_lmEfect *= m_lmDecay; | 807 | m_lmEfect *= m_lmDecay; |
802 | 808 | m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared(); | |
803 | // m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared(); | ||
804 | m_ffactor = 0; | ||
805 | } | 809 | } |
806 | else | 810 | else |
807 | { | 811 | { |
@@ -1007,7 +1011,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1007 | if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000) | 1011 | if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000) |
1008 | { | 1012 | { |
1009 | tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error | 1013 | tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error |
1010 | tmpV *= m_amEfect; // error to correct in this timestep | 1014 | tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep |
1011 | torque.X += tmpV.X * m_ampwr; | 1015 | torque.X += tmpV.X * m_ampwr; |
1012 | torque.Y += tmpV.Y * m_ampwr; | 1016 | torque.Y += tmpV.Y * m_ampwr; |
1013 | torque.Z += tmpV.Z; | 1017 | torque.Z += tmpV.Z; |
@@ -1057,13 +1061,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1057 | } | 1061 | } |
1058 | 1062 | ||
1059 | 1063 | ||
1060 | d.Mass dmass; | ||
1061 | d.BodyGetMass(Body,out dmass); | ||
1062 | 1064 | ||
1063 | if (force.X != 0 || force.Y != 0 || force.Z != 0) | 1065 | if (force.X != 0 || force.Y != 0 || force.Z != 0) |
1064 | { | 1066 | { |
1065 | force *= dmass.mass; | 1067 | force *= dmass.mass; |
1066 | d.BodySetForce(Body, force.X, force.Y, force.Z); | 1068 | d.BodyAddForce(Body, force.X, force.Y, force.Z); |
1067 | } | 1069 | } |
1068 | 1070 | ||
1069 | if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) | 1071 | if (torque.X != 0 || torque.Y != 0 || torque.Z != 0) |