aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKitto Flora2010-02-12 15:56:21 -0500
committerKitto Flora2010-02-12 15:56:21 -0500
commit9568718addfd8e5d4094a456127ca469987f1f7a (patch)
tree8b700d1db70ea9736c38ba5caa770e8c41a8f9ff
parentMerge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff)
downloadopensim-SC_OLD-9568718addfd8e5d4094a456127ca469987f1f7a.zip
opensim-SC_OLD-9568718addfd8e5d4094a456127ca469987f1f7a.tar.gz
opensim-SC_OLD-9568718addfd8e5d4094a456127ca469987f1f7a.tar.bz2
opensim-SC_OLD-9568718addfd8e5d4094a456127ca469987f1f7a.tar.xz
Angular motor adjustments
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs48
1 files changed, 26 insertions, 22 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
index 4eb3313..55d6945 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEDynamics.cs
@@ -224,6 +224,8 @@ namespace OpenSim.Region.Physics.OdePlugin
224 // These are vector properties but the engine lets you use a single float value to 224 // These are vector properties but the engine lets you use a single float value to
225 // set all of the components to the same value 225 // set all of the components to the same value
226 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 226 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
227 if (pValue > 30f) pValue = 30f;
228 if (pValue < 0.1f) pValue = 0.1f;
227 m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue); 229 m_angularFrictionTimescale = new Vector3(pValue, pValue, pValue);
228 break; 230 break;
229 case Vehicle.ANGULAR_MOTOR_DIRECTION: 231 case Vehicle.ANGULAR_MOTOR_DIRECTION:
@@ -250,6 +252,12 @@ namespace OpenSim.Region.Physics.OdePlugin
250 switch (pParam) 252 switch (pParam)
251 { 253 {
252 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 254 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
255 if (pValue.X > 30f) pValue.X = 30f;
256 if (pValue.X < 0.1f) pValue.X = 0.1f;
257 if (pValue.Y > 30f) pValue.Y = 30f;
258 if (pValue.Y < 0.1f) pValue.Y = 0.1f;
259 if (pValue.Z > 30f) pValue.Z = 30f;
260 if (pValue.Z < 0.1f) pValue.Z = 0.1f;
253 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 261 m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
254 break; 262 break;
255 case Vehicle.ANGULAR_MOTOR_DIRECTION: 263 case Vehicle.ANGULAR_MOTOR_DIRECTION:
@@ -306,7 +314,7 @@ namespace OpenSim.Region.Physics.OdePlugin
306 { 314 {
307 case Vehicle.TYPE_SLED: 315 case Vehicle.TYPE_SLED:
308 m_linearFrictionTimescale = new Vector3(30, 1, 1000); 316 m_linearFrictionTimescale = new Vector3(30, 1, 1000);
309 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 317 m_angularFrictionTimescale = new Vector3(30, 30, 30);
310// m_lLinMotorVel = Vector3.Zero; 318// m_lLinMotorVel = Vector3.Zero;
311 m_linearMotorTimescale = 1000; 319 m_linearMotorTimescale = 1000;
312 m_linearMotorDecayTimescale = 120; 320 m_linearMotorDecayTimescale = 120;
@@ -333,7 +341,7 @@ namespace OpenSim.Region.Physics.OdePlugin
333 break; 341 break;
334 case Vehicle.TYPE_CAR: 342 case Vehicle.TYPE_CAR:
335 m_linearFrictionTimescale = new Vector3(100, 2, 1000); 343 m_linearFrictionTimescale = new Vector3(100, 2, 1000);
336 m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); 344 m_angularFrictionTimescale = new Vector3(30, 30, 30); // was 1000, but sl max frict time is 30.
337// m_lLinMotorVel = Vector3.Zero; 345// m_lLinMotorVel = Vector3.Zero;
338 m_linearMotorTimescale = 1; 346 m_linearMotorTimescale = 1;
339 m_linearMotorDecayTimescale = 60; 347 m_linearMotorDecayTimescale = 60;
@@ -548,6 +556,7 @@ namespace OpenSim.Region.Physics.OdePlugin
548 if (m_linearFrictionTimescale.Z < 300.0f) 556 if (m_linearFrictionTimescale.Z < 300.0f)
549 { 557 {
550 float fricfactor = m_linearFrictionTimescale.Z / pTimestep; 558 float fricfactor = m_linearFrictionTimescale.Z / pTimestep;
559//if(frcount == 0) Console.WriteLine("Zfric={0}", fricfactor);
551 float fricZ = m_lLinObjectVel.Z / fricfactor; 560 float fricZ = m_lLinObjectVel.Z / fricfactor;
552 m_lLinObjectVel.Z -= fricZ; 561 m_lLinObjectVel.Z -= fricZ;
553 } 562 }
@@ -639,7 +648,6 @@ namespace OpenSim.Region.Physics.OdePlugin
639 */ 648 */
640//if(frcount == 0) Console.WriteLine("MoveAngular "); 649//if(frcount == 0) Console.WriteLine("MoveAngular ");
641 650
642//####
643 // Get what the body is doing, this includes 'external' influences 651 // Get what the body is doing, this includes 'external' influences
644 d.Vector3 angularObjectVel = d.BodyGetAngularVel(Body); 652 d.Vector3 angularObjectVel = d.BodyGetAngularVel(Body);
645 Vector3 angObjectVel = new Vector3(angularObjectVel.X, angularObjectVel.Y, angularObjectVel.Z); 653 Vector3 angObjectVel = new Vector3(angularObjectVel.X, angularObjectVel.Y, angularObjectVel.Z);
@@ -652,9 +660,18 @@ namespace OpenSim.Region.Physics.OdePlugin
652 // Decay Angular Motor 2. 660 // Decay Angular Motor 2.
653 if (m_angularMotorDecayTimescale < 300.0f) 661 if (m_angularMotorDecayTimescale < 300.0f)
654 { 662 {
655 float decayfactor = m_angularMotorDecayTimescale/pTimestep; // df = Dec / pts 663//####
656 Vector3 decayAmount = (m_angularMotorDVel/decayfactor); // v-da = v-Dvel / df = v-Dvel * pts / Dec 664 if ( Vector3.Mag(m_angularMotorDVel) < 1.0f)
657 m_angularMotorDVel -= decayAmount; // v-Dvel = v-Dvel - (v-Dvel / df = v-Dvel * pts / Dec) 665 {
666 float decayfactor = (m_angularMotorDecayTimescale)/pTimestep;
667 Vector3 decayAmount = (m_angularMotorDVel/decayfactor);
668 m_angularMotorDVel -= decayAmount;
669 }
670 else
671 {
672 Vector3 decel = Vector3.Normalize(m_angularMotorDVel) * pTimestep / m_angularMotorDecayTimescale;
673 m_angularMotorDVel -= decel;
674 }
658 675
659 if (m_angularMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) 676 if (m_angularMotorDVel.ApproxEquals(Vector3.Zero, 0.01f))
660 { 677 {
@@ -743,22 +760,9 @@ namespace OpenSim.Region.Physics.OdePlugin
743//if(frcount == 0) Console.WriteLine("V2+= {0}", angObjectVel); 760//if(frcount == 0) Console.WriteLine("V2+= {0}", angObjectVel);
744 } 761 }
745 762
746 if (m_angularFrictionTimescale.X < 300.0f) 763 angObjectVel.X -= angObjectVel.X / (m_angularFrictionTimescale.X * 0.7f / pTimestep);
747 { 764 angObjectVel.Y -= angObjectVel.Y / (m_angularFrictionTimescale.Y * 0.7f / pTimestep);
748 float fricfactor = m_angularFrictionTimescale.X / pTimestep; 765 angObjectVel.Z -= angObjectVel.Z / (m_angularFrictionTimescale.Z * 0.7f / pTimestep);
749 angObjectVel.X -= angObjectVel.X / fricfactor;
750 }
751 if (m_angularFrictionTimescale.Y < 300.0f)
752 {
753 float fricfactor = m_angularFrictionTimescale.Y / pTimestep;
754 angObjectVel.Y -= angObjectVel.Y / fricfactor;
755 }
756 if (m_angularFrictionTimescale.Z < 300.0f)
757 {
758 float fricfactor = m_angularFrictionTimescale.Z / pTimestep;
759 angObjectVel.Z -= angObjectVel.Z / fricfactor;
760 Console.WriteLine("z fric");
761 }
762 } // else no signif. motion 766 } // else no signif. motion
763 767
764//if(frcount == 0) Console.WriteLine("Dmotor {0} Obj {1}", m_angularMotorDVel, angObjectVel); 768//if(frcount == 0) Console.WriteLine("Dmotor {0} Obj {1}", m_angularMotorDVel, angObjectVel);