aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2009-04-17 23:04:33 +0000
committerTeravus Ovares2009-04-17 23:04:33 +0000
commit68190617b4ffda74191cff1797589597feb65b6e (patch)
treee67fe82d60168a961c8f424ce4d72aed3ca51feb /OpenSim/Region/Physics/OdePlugin
parentFixes Mantis # 3469. Thank you kindly, BlueWall, for a patch that: (diff)
downloadopensim-SC_OLD-68190617b4ffda74191cff1797589597feb65b6e.zip
opensim-SC_OLD-68190617b4ffda74191cff1797589597feb65b6e.tar.gz
opensim-SC_OLD-68190617b4ffda74191cff1797589597feb65b6e.tar.bz2
opensim-SC_OLD-68190617b4ffda74191cff1797589597feb65b6e.tar.xz
* A few fixes to the Linear Motor
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs36
1 files changed, 21 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs b/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
index b61e1c5..04de9a7 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEVehicleSettings.cs
@@ -64,6 +64,7 @@ namespace OpenSim.Region.Physics.OdePlugin
64 private Vector3 m_angularMotorDirection = Vector3.Zero; 64 private Vector3 m_angularMotorDirection = Vector3.Zero;
65 private Vector3 m_linearFrictionTimescale = Vector3.Zero; 65 private Vector3 m_linearFrictionTimescale = Vector3.Zero;
66 private Vector3 m_linearMotorDirection = Vector3.Zero; 66 private Vector3 m_linearMotorDirection = Vector3.Zero;
67 private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero;
67 private Vector3 m_linearMotorOffset = Vector3.Zero; 68 private Vector3 m_linearMotorOffset = Vector3.Zero;
68 private float m_angularDeflectionEfficiency = 0; 69 private float m_angularDeflectionEfficiency = 0;
69 private float m_angularDeflectionTimescale = 0; 70 private float m_angularDeflectionTimescale = 0;
@@ -86,7 +87,7 @@ namespace OpenSim.Region.Physics.OdePlugin
86 private VehicleFlag m_flags = (VehicleFlag) 0; 87 private VehicleFlag m_flags = (VehicleFlag) 0;
87 88
88 private bool m_LinearMotorSetLastFrame = false; 89 private bool m_LinearMotorSetLastFrame = false;
89 90
90 91
91 92
92 93
@@ -173,7 +174,7 @@ namespace OpenSim.Region.Physics.OdePlugin
173 break; 174 break;
174 case Vehicle.LINEAR_MOTOR_DIRECTION: 175 case Vehicle.LINEAR_MOTOR_DIRECTION:
175 m_linearMotorDirection = new Vector3(pValue, pValue, pValue); 176 m_linearMotorDirection = new Vector3(pValue, pValue, pValue);
176 m_LinearMotorSetLastFrame = true; 177 m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue);
177 break; 178 break;
178 case Vehicle.LINEAR_MOTOR_OFFSET: 179 case Vehicle.LINEAR_MOTOR_OFFSET:
179 m_linearMotorOffset = new Vector3(pValue, pValue, pValue); 180 m_linearMotorOffset = new Vector3(pValue, pValue, pValue);
@@ -199,6 +200,7 @@ namespace OpenSim.Region.Physics.OdePlugin
199 break; 200 break;
200 case Vehicle.LINEAR_MOTOR_DIRECTION: 201 case Vehicle.LINEAR_MOTOR_DIRECTION:
201 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); 202 m_linearMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z);
203 m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z);
202 break; 204 break;
203 case Vehicle.LINEAR_MOTOR_OFFSET: 205 case Vehicle.LINEAR_MOTOR_OFFSET:
204 m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); 206 m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z);
@@ -466,27 +468,31 @@ namespace OpenSim.Region.Physics.OdePlugin
466 468
467 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f)) 469 if (!m_linearMotorDirection.ApproxEquals(Vector3.Zero, 0.01f))
468 { 470 {
471
469 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep); 472 Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale/pTimestep);
470 m_lastLinearVelocityVector += (addAmount*10); 473 m_lastLinearVelocityVector += (addAmount*10);
471 474
472 // This will work temporarily, but we really need to compare speed on an axis 475 // This will work temporarily, but we really need to compare speed on an axis
473 if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirection.X)) 476 if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X))
474 m_lastLinearVelocityVector.X = m_linearMotorDirection.X; 477 m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X;
475 if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirection.Y)) 478 if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y))
476 m_lastLinearVelocityVector.Y = m_linearMotorDirection.Y; 479 m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y;
477 if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirection.Z)) 480 if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z))
478 m_lastLinearVelocityVector.Z = m_linearMotorDirection.Z; 481 m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z;
479 //System.Console.WriteLine("add: " + addAmount); 482 //Console.WriteLine("add: " + addAmount);
480 483
481 m_linearMotorDirection -= (m_linearMotorDirection*new Vector3(1, 1, 1)/ 484 Vector3 decayfraction = ((Vector3.One/(m_linearMotorDecayTimescale/pTimestep)));
482 (m_linearMotorDecayTimescale/pTimestep)) * 0.10f; 485 //Console.WriteLine("decay: " + decayfraction);
486
487 m_linearMotorDirection -= m_linearMotorDirection * decayfraction;
483 //Console.WriteLine("actual: " + m_linearMotorDirection); 488 //Console.WriteLine("actual: " + m_linearMotorDirection);
484 } 489 }
490
485 //System.Console.WriteLine(m_linearMotorDirection + " " + m_lastLinearVelocityVector); 491 //System.Console.WriteLine(m_linearMotorDirection + " " + m_lastLinearVelocityVector);
486 492
487 SetMotorProperties(); 493 SetMotorProperties();
488 494
489 Vector3 decayamount = new Vector3(1,1,1)/(m_linearFrictionTimescale/pTimestep); 495 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
490 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; 496 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
491 497
492 //m_linearMotorDirection *= decayamount; 498 //m_linearMotorDirection *= decayamount;
@@ -507,7 +513,7 @@ namespace OpenSim.Region.Physics.OdePlugin
507 { 513 {
508 514
509 d.JointSetLMotorAxis(m_lMotor1, 0, 1, dirNorm.X, dirNorm.Y, dirNorm.Z); 515 d.JointSetLMotorAxis(m_lMotor1, 0, 1, dirNorm.X, dirNorm.Y, dirNorm.Z);
510 d.JointSetLMotorParam(m_lMotor1, (int)dParam.Vel, m_linearMotorDirection.Length()); 516 d.JointSetLMotorParam(m_lMotor1, (int)dParam.Vel, m_lastLinearVelocityVector.Length());
511 517
512 d.JointSetLMotorParam(m_lMotor1, (int)dParam.FMax, 35f * objMass.mass); 518 d.JointSetLMotorParam(m_lMotor1, (int)dParam.FMax, 35f * objMass.mass);
513 } 519 }