aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/ChOdePlugin
diff options
context:
space:
mode:
authorKitto Flora2010-04-11 14:12:01 -0400
committerKitto Flora2010-04-11 14:12:01 -0400
commit9b6e89457c692fd65a0a221ef7809cc0e4836fe7 (patch)
treed535dc07cb7dd7af56514a3637ab40f4be7a0d11 /OpenSim/Region/Physics/ChOdePlugin
parentMerge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff)
downloadopensim-SC_OLD-9b6e89457c692fd65a0a221ef7809cc0e4836fe7.zip
opensim-SC_OLD-9b6e89457c692fd65a0a221ef7809cc0e4836fe7.tar.gz
opensim-SC_OLD-9b6e89457c692fd65a0a221ef7809cc0e4836fe7.tar.bz2
opensim-SC_OLD-9b6e89457c692fd65a0a221ef7809cc0e4836fe7.tar.xz
Fixed LINEAR_MOTOR Z drive, Mantis #30
Diffstat (limited to 'OpenSim/Region/Physics/ChOdePlugin')
-rw-r--r--OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs58
1 files changed, 35 insertions, 23 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
index 67f8af5..01c3f81 100644
--- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs
@@ -2626,15 +2626,15 @@ Console.WriteLine(" JointCreateFixed");
2626 // m_angularDeflectionEfficiency = pValue; 2626 // m_angularDeflectionEfficiency = pValue;
2627 break; 2627 break;
2628 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 2628 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
2629 if (pValue < 0.01f) pValue = 0.01f; 2629 if (pValue < 0.1f) pValue = 0.1f;
2630 // m_angularDeflectionTimescale = pValue; 2630 // m_angularDeflectionTimescale = pValue;
2631 break; 2631 break;
2632 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: 2632 case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE:
2633 if (pValue < 0.01f) pValue = 0.01f; 2633 if (pValue < 0.3f) pValue = 0.3f;
2634 m_angularMotorDecayTimescale = pValue; 2634 m_angularMotorDecayTimescale = pValue;
2635 break; 2635 break;
2636 case Vehicle.ANGULAR_MOTOR_TIMESCALE: 2636 case Vehicle.ANGULAR_MOTOR_TIMESCALE:
2637 if (pValue < 0.01f) pValue = 0.01f; 2637 if (pValue < 0.3f) pValue = 0.3f;
2638 m_angularMotorTimescale = pValue; 2638 m_angularMotorTimescale = pValue;
2639 break; 2639 break;
2640 case Vehicle.BANKING_EFFICIENCY: 2640 case Vehicle.BANKING_EFFICIENCY:
@@ -2663,7 +2663,7 @@ Console.WriteLine(" JointCreateFixed");
2663 m_VhoverHeight = pValue; 2663 m_VhoverHeight = pValue;
2664 break; 2664 break;
2665 case Vehicle.HOVER_TIMESCALE: 2665 case Vehicle.HOVER_TIMESCALE:
2666 if (pValue < 0.01f) pValue = 0.01f; 2666 if (pValue < 0.1f) pValue = 0.1f;
2667 m_VhoverTimescale = pValue; 2667 m_VhoverTimescale = pValue;
2668 break; 2668 break;
2669 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: 2669 case Vehicle.LINEAR_DEFLECTION_EFFICIENCY:
@@ -2675,11 +2675,11 @@ Console.WriteLine(" JointCreateFixed");
2675 // m_linearDeflectionTimescale = pValue; 2675 // m_linearDeflectionTimescale = pValue;
2676 break; 2676 break;
2677 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: 2677 case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE:
2678 if (pValue < 0.01f) pValue = 0.01f; 2678 if (pValue < 0.3f) pValue = 0.3f;
2679 m_linearMotorDecayTimescale = pValue; 2679 m_linearMotorDecayTimescale = pValue;
2680 break; 2680 break;
2681 case Vehicle.LINEAR_MOTOR_TIMESCALE: 2681 case Vehicle.LINEAR_MOTOR_TIMESCALE:
2682 if (pValue < 0.01f) pValue = 0.01f; 2682 if (pValue < 0.1f) pValue = 0.1f;
2683 m_linearMotorTimescale = pValue; 2683 m_linearMotorTimescale = pValue;
2684 break; 2684 break;
2685 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY: 2685 case Vehicle.VERTICAL_ATTRACTION_EFFICIENCY:
@@ -2688,7 +2688,7 @@ Console.WriteLine(" JointCreateFixed");
2688 m_verticalAttractionEfficiency = pValue; 2688 m_verticalAttractionEfficiency = pValue;
2689 break; 2689 break;
2690 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE: 2690 case Vehicle.VERTICAL_ATTRACTION_TIMESCALE:
2691 if (pValue < 0.01f) pValue = 0.01f; 2691 if (pValue < 0.1f) pValue = 0.1f;
2692 m_verticalAttractionTimescale = pValue; 2692 m_verticalAttractionTimescale = pValue;
2693 break; 2693 break;
2694 2694
@@ -2704,6 +2704,7 @@ Console.WriteLine(" JointCreateFixed");
2704 UpdateAngDecay(); 2704 UpdateAngDecay();
2705 break; 2705 break;
2706 case Vehicle.LINEAR_FRICTION_TIMESCALE: 2706 case Vehicle.LINEAR_FRICTION_TIMESCALE:
2707 if (pValue < 0.1f) pValue = 0.1f;
2707 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); 2708 m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue);
2708 break; 2709 break;
2709 case Vehicle.LINEAR_MOTOR_DIRECTION: 2710 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -2743,6 +2744,9 @@ Console.WriteLine(" JointCreateFixed");
2743 UpdateAngDecay(); 2744 UpdateAngDecay();
2744 break; 2745 break;
2745 case Vehicle.LINEAR_FRICTION_TIMESCALE: 2746 case Vehicle.LINEAR_FRICTION_TIMESCALE:
2747 if (pValue.X < 0.1f) pValue.X = 0.1f;
2748 if (pValue.Y < 0.1f) pValue.Y = 0.1f;
2749 if (pValue.Z < 0.1f) pValue.Z = 0.1f;
2746 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); 2750 m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z);
2747 break; 2751 break;
2748 case Vehicle.LINEAR_MOTOR_DIRECTION: 2752 case Vehicle.LINEAR_MOTOR_DIRECTION:
@@ -2939,7 +2943,7 @@ Console.WriteLine(" JointCreateFixed");
2939 2943
2940 internal void Halt() 2944 internal void Halt()
2941 { // Kill all motions, when non-physical 2945 { // Kill all motions, when non-physical
2942 m_linearMotorDirection = Vector3.Zero; 2946 // m_linearMotorDirection = Vector3.Zero;
2943 m_lLinMotorDVel = Vector3.Zero; 2947 m_lLinMotorDVel = Vector3.Zero;
2944 m_lLinObjectVel = Vector3.Zero; 2948 m_lLinObjectVel = Vector3.Zero;
2945 m_wLinObjectVel = Vector3.Zero; 2949 m_wLinObjectVel = Vector3.Zero;
@@ -2951,16 +2955,22 @@ Console.WriteLine(" JointCreateFixed");
2951 2955
2952 private void UpdateLinDecay() 2956 private void UpdateLinDecay()
2953 { 2957 {
2954 if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X; 2958// if (Math.Abs(m_linearMotorDirection.X) > Math.Abs(m_lLinMotorDVel.X)) m_lLinMotorDVel.X = m_linearMotorDirection.X;
2955 if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y; 2959// if (Math.Abs(m_linearMotorDirection.Y) > Math.Abs(m_lLinMotorDVel.Y)) m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
2956 if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z; 2960// if (Math.Abs(m_linearMotorDirection.Z) > Math.Abs(m_lLinMotorDVel.Z)) m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
2961 m_lLinMotorDVel.X = m_linearMotorDirection.X;
2962 m_lLinMotorDVel.Y = m_linearMotorDirection.Y;
2963 m_lLinMotorDVel.Z = m_linearMotorDirection.Z;
2957 } // else let the motor decay on its own 2964 } // else let the motor decay on its own
2958 2965
2959 private void UpdateAngDecay() 2966 private void UpdateAngDecay()
2960 { 2967 {
2961 if (Math.Abs(m_angularMotorDirection.X) > Math.Abs(m_angularMotorDVel.X)) m_angularMotorDVel.X = m_angularMotorDirection.X; 2968// if (Math.Abs(m_angularMotorDirection.X) > Math.Abs(m_angularMotorDVel.X)) m_angularMotorDVel.X = m_angularMotorDirection.X;
2962 if (Math.Abs(m_angularMotorDirection.Y) > Math.Abs(m_angularMotorDVel.Y)) m_angularMotorDVel.Y = m_angularMotorDirection.Y; 2969// if (Math.Abs(m_angularMotorDirection.Y) > Math.Abs(m_angularMotorDVel.Y)) m_angularMotorDVel.Y = m_angularMotorDirection.Y;
2963 if (Math.Abs(m_angularMotorDirection.Z) > Math.Abs(m_angularMotorDVel.Z)) m_angularMotorDVel.Z = m_angularMotorDirection.Z; 2970// if (Math.Abs(m_angularMotorDirection.Z) > Math.Abs(m_angularMotorDVel.Z)) m_angularMotorDVel.Z = m_angularMotorDirection.Z;
2971 m_angularMotorDVel.X = m_angularMotorDirection.X;
2972 m_angularMotorDVel.Y = m_angularMotorDirection.Y;
2973 m_angularMotorDVel.Z = m_angularMotorDirection.Z;
2964 } // else let the motor decay on its own 2974 } // else let the motor decay on its own
2965 2975
2966 public void Move(float timestep) 2976 public void Move(float timestep)
@@ -2981,7 +2991,7 @@ Console.WriteLine(" JointCreateFixed");
2981 if (fence == 1) border_limit = 0.5f; // bounce point 2991 if (fence == 1) border_limit = 0.5f; // bounce point
2982 2992
2983 frcount++; // used to limit debug comment output 2993 frcount++; // used to limit debug comment output
2984 if (frcount > 100) 2994 if (frcount > 10)
2985 frcount = 0; 2995 frcount = 0;
2986 2996
2987 if(revcount > 0) revcount--; 2997 if(revcount > 0) revcount--;
@@ -3222,12 +3232,13 @@ Console.WriteLine(" JointCreateFixed");
3222 { 3232 {
3223 m_lLinMotorDVel = Vector3.Zero; 3233 m_lLinMotorDVel = Vector3.Zero;
3224 } 3234 }
3225 else 3235
3236 /* else
3226 { 3237 {
3227 if (Math.Abs(m_lLinMotorDVel.X) < Math.Abs(m_lLinObjectVel.X)) m_lLinObjectVel.X = m_lLinMotorDVel.X; 3238 if (Math.Abs(m_lLinMotorDVel.X) < Math.Abs(m_lLinObjectVel.X)) m_lLinObjectVel.X = m_lLinMotorDVel.X;
3228 if (Math.Abs(m_lLinMotorDVel.Y) < Math.Abs(m_lLinObjectVel.Y)) m_lLinObjectVel.Y = m_lLinMotorDVel.Y; 3239 if (Math.Abs(m_lLinMotorDVel.Y) < Math.Abs(m_lLinObjectVel.Y)) m_lLinObjectVel.Y = m_lLinMotorDVel.Y;
3229 if (Math.Abs(m_lLinMotorDVel.Z) < Math.Abs(m_lLinObjectVel.Z)) m_lLinObjectVel.Z = m_lLinMotorDVel.Z; 3240 if (Math.Abs(m_lLinMotorDVel.Z) < Math.Abs(m_lLinObjectVel.Z)) m_lLinObjectVel.Z = m_lLinMotorDVel.Z;
3230 } 3241 } */
3231 } // end linear motor decay 3242 } // end linear motor decay
3232 3243
3233 if ( (! m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! m_lLinObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) ) 3244 if ( (! m_lLinMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! m_lLinObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) )
@@ -3255,7 +3266,6 @@ Console.WriteLine(" JointCreateFixed");
3255 if (m_linearFrictionTimescale.Z < 300.0f) 3266 if (m_linearFrictionTimescale.Z < 300.0f)
3256 { 3267 {
3257 float fricfactor = m_linearFrictionTimescale.Z / timestep; 3268 float fricfactor = m_linearFrictionTimescale.Z / timestep;
3258//if(frcount == 0) Console.WriteLine("Zfric={0}", fricfactor);
3259 float fricZ = m_lLinObjectVel.Z / fricfactor; 3269 float fricZ = m_lLinObjectVel.Z / fricfactor;
3260 m_lLinObjectVel.Z -= fricZ; 3270 m_lLinObjectVel.Z -= fricZ;
3261 } 3271 }
@@ -3316,15 +3326,17 @@ Console.WriteLine(" JointCreateFixed");
3316 } 3326 }
3317 } 3327 }
3318 else 3328 else
3319 { // not hovering, Gravity rules 3329 { // not hovering
3320 m_wLinObjectVel.Z = vel_now.Z; 3330 if (m_wLinObjectVel.Z == 0f)
3331 { // Gravity rules
3332 m_wLinObjectVel.Z = vel_now.Z;
3333 } // else the motor has it
3321 } 3334 }
3322 linvel = m_wLinObjectVel; 3335 linvel = m_wLinObjectVel;
3323 3336
3324 // Vehicle Linear Motion done ======================================= 3337 // Vehicle Linear Motion done =======================================
3325 // Apply velocity 3338 // Apply velocity
3326//if(frcount == 0) Console.WriteLine("LV {0}", linvel); 3339 d.BodySetLinearVel(Body, linvel.X, linvel.Y, linvel.Z);
3327 d.BodySetLinearVel(Body, linvel.X, linvel.Y, linvel.Z);
3328 // apply gravity force 3340 // apply gravity force
3329 d.BodyAddForce(Body, grav.X, grav.Y, grav.Z); 3341 d.BodyAddForce(Body, grav.X, grav.Y, grav.Z);
3330//if(frcount == 0) Console.WriteLine("Grav {0}", grav); 3342//if(frcount == 0) Console.WriteLine("Grav {0}", grav);