aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs28
1 files changed, 17 insertions, 11 deletions
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
index 9fefc4e..8f2feba 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEDynamics.cs
@@ -118,6 +118,7 @@ namespace OpenSim.Region.Physics.OdePlugin
118 118
119 // auxiliar 119 // auxiliar
120 private float m_lmEfect = 0; // current linear motor eficiency 120 private float m_lmEfect = 0; // current linear motor eficiency
121 private float m_lmDecay = 1.0f;
121 private float m_amEfect = 0; // current angular motor eficiency 122 private float m_amEfect = 0; // current angular motor eficiency
122 private float m_ffactor = 1.0f; 123 private float m_ffactor = 1.0f;
123 124
@@ -155,6 +156,7 @@ namespace OpenSim.Region.Physics.OdePlugin
155 156
156 m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale; 157 m_linearMotorDecayTimescale = vd.m_linearMotorDecayTimescale;
157 if (m_linearMotorDecayTimescale < m_timestep) m_linearMotorDecayTimescale = m_timestep; 158 if (m_linearMotorDecayTimescale < m_timestep) m_linearMotorDecayTimescale = m_timestep;
159 m_linearMotorDecayTimescale += 0.2f;
158 m_linearMotorDecayTimescale *= m_invtimestep; 160 m_linearMotorDecayTimescale *= m_invtimestep;
159 161
160 m_linearMotorTimescale = vd.m_linearMotorTimescale; 162 m_linearMotorTimescale = vd.m_linearMotorTimescale;
@@ -208,6 +210,7 @@ namespace OpenSim.Region.Physics.OdePlugin
208 m_referenceFrame = vd.m_referenceFrame; 210 m_referenceFrame = vd.m_referenceFrame;
209 211
210 m_lmEfect = 0; 212 m_lmEfect = 0;
213 m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
211 m_amEfect = 0; 214 m_amEfect = 0;
212 m_ffactor = 1.0f; 215 m_ffactor = 1.0f;
213 } 216 }
@@ -279,7 +282,7 @@ namespace OpenSim.Region.Physics.OdePlugin
279 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 282 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
280 if (pValue < m_timestep) pValue = m_timestep; 283 if (pValue < m_timestep) pValue = m_timestep;
281 else if (pValue > 120) pValue = 120; 284 else if (pValue > 120) pValue = 120;
282 m_linearMotorDecayTimescale = pValue * m_invtimestep; 285 m_linearMotorDecayTimescale = (0.2f +pValue) * m_invtimestep;
283 break; 286 break;
284 case Vehicle.LINEAR_MOTOR_TIMESCALE: 287 case Vehicle.LINEAR_MOTOR_TIMESCALE:
285 if (pValue < m_timestep) pValue = m_timestep; 288 if (pValue < m_timestep) pValue = m_timestep;
@@ -318,9 +321,10 @@ namespace OpenSim.Region.Physics.OdePlugin
318 case Vehicle.LINEAR_MOTOR_DIRECTION: 321 case Vehicle.LINEAR_MOTOR_DIRECTION:
319 m_linearMotorDirection = new Vector3(pValue, pValue, pValue); 322 m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
320 len = m_linearMotorDirection.Length(); 323 len = m_linearMotorDirection.Length();
321 if (len > 30.0f) 324 if (len > 100.0f)
322 m_linearMotorDirection *= (30.0f / len); 325 m_linearMotorDirection *= (100.0f / len);
323 m_lmEfect = 1.0f; // turn it on 326 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
327 m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on
324 m_ffactor = 0.01f; 328 m_ffactor = 0.01f;
325 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 329 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
326 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 330 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
@@ -368,9 +372,10 @@ namespace OpenSim.Region.Physics.OdePlugin
368 case Vehicle.LINEAR_MOTOR_DIRECTION: 372 case Vehicle.LINEAR_MOTOR_DIRECTION:
369 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); 373 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
370 len = m_linearMotorDirection.Length(); 374 len = m_linearMotorDirection.Length();
371 if (len > 30.0f) 375 if (len > 100.0f)
372 m_linearMotorDirection *= (30.0f / len); 376 m_linearMotorDirection *= (100.0f / len);
373 m_lmEfect = 1.0f; // turn it on 377 m_lmDecay = 1.0f - 1.0f / m_linearMotorDecayTimescale;
378 m_lmEfect = 1.0f / m_linearMotorTimescale; // turn it on
374 m_ffactor = 0.01f; 379 m_ffactor = 0.01f;
375 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body) 380 if (rootPrim.Body != IntPtr.Zero && !d.BodyIsEnabled(rootPrim.Body)
376 && !rootPrim.m_isSelected && !rootPrim.m_disabled) 381 && !rootPrim.m_isSelected && !rootPrim.m_disabled)
@@ -603,12 +608,13 @@ namespace OpenSim.Region.Physics.OdePlugin
603// VehicleFlag.HOVER_GLOBAL_HEIGHT); 608// VehicleFlag.HOVER_GLOBAL_HEIGHT);
604 break; 609 break;
605 } 610 }
606 611 m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
607 }//end SetDefaultsForType 612 }//end SetDefaultsForType
608 613
609 internal void Stop() 614 internal void Stop()
610 { 615 {
611 m_lmEfect = 0; 616 m_lmEfect = 0;
617 m_lmDecay = 1.0f;
612 m_amEfect = 0; 618 m_amEfect = 0;
613 m_ffactor = 1f; 619 m_ffactor = 1f;
614 } 620 }
@@ -739,10 +745,10 @@ namespace OpenSim.Region.Physics.OdePlugin
739 Vector3 curLocalAngVel = curAngVel * irotq; // current angular velocity in local 745 Vector3 curLocalAngVel = curAngVel * irotq; // current angular velocity in local
740 746
741 // linear motor 747 // linear motor
742 if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) 748 if (m_lmEfect > 0.001 && m_linearMotorTimescale < 1000)
743 { 749 {
744 tmpV = m_linearMotorDirection - curLocalVel; // velocity error 750 tmpV = m_linearMotorDirection - curLocalVel; // velocity error
745 tmpV *= m_lmEfect / m_linearMotorTimescale; // error to correct in this timestep 751 tmpV *= m_lmEfect; // error to correct in this timestep
746 tmpV *= rotq; // to world 752 tmpV *= rotq; // to world
747 753
748 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0) 754 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != 0)
@@ -760,7 +766,7 @@ namespace OpenSim.Region.Physics.OdePlugin
760 force.Y += tmpV.Y; 766 force.Y += tmpV.Y;
761 force.Z += tmpV.Z; 767 force.Z += tmpV.Z;
762 } 768 }
763 m_lmEfect *= (1.0f - 1.0f / m_linearMotorDecayTimescale); 769 m_lmEfect *= m_lmDecay;
764 770
765 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared(); 771 m_ffactor = 0.01f + 1e-4f * curVel.LengthSquared();
766 } 772 }