diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 84 |
2 files changed, 45 insertions, 43 deletions
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs index 8e87ad9..7a5093b 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | |||
@@ -1025,11 +1025,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1025 | // m_iscolliding includes collisions with the ground. | 1025 | // m_iscolliding includes collisions with the ground. |
1026 | 1026 | ||
1027 | // d.Vector3 pos = d.BodyGetPosition(Body); | 1027 | // d.Vector3 pos = d.BodyGetPosition(Body); |
1028 | if (_target_velocity.X > 0) | 1028 | if (Math.Abs(_target_velocity.X) > 0) |
1029 | { | 1029 | { |
1030 | vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; | 1030 | vec.X = ((_target_velocity.X - vel.X)/1.2f)*PID_D; |
1031 | } | 1031 | } |
1032 | if (_target_velocity.Y > 0) | 1032 | if (Math.Abs(_target_velocity.Y) > 0) |
1033 | { | 1033 | { |
1034 | vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; | 1034 | vec.Y = ((_target_velocity.Y - vel.Y)/1.2f)*PID_D; |
1035 | } | 1035 | } |
diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 01c3f81..fbe52c8 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | |||
@@ -3395,6 +3395,44 @@ Console.WriteLine(" JointCreateFixed"); | |||
3395 | 3395 | ||
3396 | //if(frcount == 0) Console.WriteLine("VA = {0}", angObjectVel); | 3396 | //if(frcount == 0) Console.WriteLine("VA = {0}", angObjectVel); |
3397 | 3397 | ||
3398 | if ( (! m_angularMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! angObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) ) | ||
3399 | { // if motor or object have motion | ||
3400 | if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); | ||
3401 | |||
3402 | if (m_angularMotorTimescale < 300.0f) | ||
3403 | { | ||
3404 | Vector3 attack_error = m_angularMotorDVel - angObjectVel; | ||
3405 | float angfactor = m_angularMotorTimescale/timestep; | ||
3406 | Vector3 attackAmount = (attack_error/angfactor); | ||
3407 | angObjectVel += attackAmount; | ||
3408 | //if(frcount == 0) Console.WriteLine("Accel {0} Attk {1}",FrAaccel, attackAmount); | ||
3409 | //if(frcount == 0) Console.WriteLine("V2+= {0}", angObjectVel); | ||
3410 | } | ||
3411 | |||
3412 | angObjectVel.X -= angObjectVel.X / (m_angularFrictionTimescale.X * 0.7f / timestep); | ||
3413 | angObjectVel.Y -= angObjectVel.Y / (m_angularFrictionTimescale.Y * 0.7f / timestep); | ||
3414 | angObjectVel.Z -= angObjectVel.Z / (m_angularFrictionTimescale.Z * 0.7f / timestep); | ||
3415 | } // else no signif. motion | ||
3416 | |||
3417 | //if(frcount == 0) Console.WriteLine("Dmotor {0} Obj {1}", m_angularMotorDVel, angObjectVel); | ||
3418 | // Bank section tba | ||
3419 | // Deflection section tba | ||
3420 | //if(frcount == 0) Console.WriteLine("V3 = {0}", angObjectVel); | ||
3421 | |||
3422 | |||
3423 | // Rotation Axis Disables: | ||
3424 | if (!m_angularEnable.ApproxEquals(Vector3.One, 0.003f)) | ||
3425 | { | ||
3426 | if (m_angularEnable.X == 0) | ||
3427 | angObjectVel.X = 0f; | ||
3428 | if (m_angularEnable.Y == 0) | ||
3429 | angObjectVel.Y = 0f; | ||
3430 | if (m_angularEnable.Z == 0) | ||
3431 | angObjectVel.Z = 0f; | ||
3432 | } | ||
3433 | |||
3434 | angObjectVel = angObjectVel * rotq; // ================ Converts to WORLD rotation | ||
3435 | |||
3398 | // Vertical attractor section | 3436 | // Vertical attractor section |
3399 | Vector3 vertattr = Vector3.Zero; | 3437 | Vector3 vertattr = Vector3.Zero; |
3400 | 3438 | ||
@@ -3419,8 +3457,9 @@ Console.WriteLine(" JointCreateFixed"); | |||
3419 | } | 3457 | } |
3420 | verterr *= 0.5f; | 3458 | verterr *= 0.5f; |
3421 | // verterror is 0 (no error) to +/- 1 (max error at 180-deg tilt) | 3459 | // verterror is 0 (no error) to +/- 1 (max error at 180-deg tilt) |
3422 | 3460 | Vector3 xyav = angObjectVel; | |
3423 | if ((!angObjectVel.ApproxEquals(Vector3.Zero, 0.001f)) || (verterr.Z < 0.49f)) | 3461 | xyav.Z = 0.0f; |
3462 | if ((!xyav.ApproxEquals(Vector3.Zero, 0.001f)) || (verterr.Z < 0.49f)) | ||
3424 | { | 3463 | { |
3425 | // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so | 3464 | // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so |
3426 | // Change Body angular velocity X based on Y, and Y based on X. Z is not changed. | 3465 | // Change Body angular velocity X based on Y, and Y based on X. Z is not changed. |
@@ -3452,46 +3491,9 @@ Console.WriteLine(" JointCreateFixed"); | |||
3452 | } // else vertical attractor is off | 3491 | } // else vertical attractor is off |
3453 | //if(frcount == 0) Console.WriteLine("V1 = {0}", angObjectVel); | 3492 | //if(frcount == 0) Console.WriteLine("V1 = {0}", angObjectVel); |
3454 | 3493 | ||
3455 | if ( (! m_angularMotorDVel.ApproxEquals(Vector3.Zero, 0.01f)) || (! angObjectVel.ApproxEquals(Vector3.Zero, 0.01f)) ) | 3494 | |
3456 | { // if motor or object have motion | ||
3457 | if(!d.BodyIsEnabled (Body)) d.BodyEnable (Body); | ||
3458 | |||
3459 | if (m_angularMotorTimescale < 300.0f) | ||
3460 | { | ||
3461 | Vector3 attack_error = m_angularMotorDVel - angObjectVel; | ||
3462 | float angfactor = m_angularMotorTimescale/timestep; | ||
3463 | Vector3 attackAmount = (attack_error/angfactor); | ||
3464 | angObjectVel += attackAmount; | ||
3465 | //if(frcount == 0) Console.WriteLine("Accel {0} Attk {1}",FrAaccel, attackAmount); | ||
3466 | //if(frcount == 0) Console.WriteLine("V2+= {0}", angObjectVel); | ||
3467 | } | ||
3468 | |||
3469 | angObjectVel.X -= angObjectVel.X / (m_angularFrictionTimescale.X * 0.7f / timestep); | ||
3470 | angObjectVel.Y -= angObjectVel.Y / (m_angularFrictionTimescale.Y * 0.7f / timestep); | ||
3471 | angObjectVel.Z -= angObjectVel.Z / (m_angularFrictionTimescale.Z * 0.7f / timestep); | ||
3472 | } // else no signif. motion | ||
3473 | |||
3474 | //if(frcount == 0) Console.WriteLine("Dmotor {0} Obj {1}", m_angularMotorDVel, angObjectVel); | ||
3475 | // Bank section tba | ||
3476 | // Deflection section tba | ||
3477 | //if(frcount == 0) Console.WriteLine("V3 = {0}", angObjectVel); | ||
3478 | |||
3479 | m_lastAngularVelocity = angObjectVel; | 3495 | m_lastAngularVelocity = angObjectVel; |
3480 | 3496 | // apply Angular Velocity to body | |
3481 | if (!m_angularEnable.ApproxEquals(Vector3.One, 0.003f)) | ||
3482 | { | ||
3483 | if (m_angularEnable.X == 0) | ||
3484 | m_lastAngularVelocity.X = 0f; | ||
3485 | if (m_angularEnable.Y == 0) | ||
3486 | m_lastAngularVelocity.Y = 0f; | ||
3487 | if (m_angularEnable.Z == 0) | ||
3488 | m_lastAngularVelocity.Z = 0f; | ||
3489 | } | ||
3490 | // Apply to the body | ||
3491 | // Vector3 aInc = m_lastAngularVelocity - initavel; | ||
3492 | //if(frcount == 0) Console.WriteLine("Inc {0}", aInc); | ||
3493 | m_lastAngularVelocity = m_lastAngularVelocity * rotq; // ================ Converts to WORLD rotation | ||
3494 | |||
3495 | d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); | 3497 | d.BodySetAngularVel (Body, m_lastAngularVelocity.X, m_lastAngularVelocity.Y, m_lastAngularVelocity.Z); |
3496 | //if(frcount == 0) Console.WriteLine("V4 = {0}", m_lastAngularVelocity); | 3498 | //if(frcount == 0) Console.WriteLine("V4 = {0}", m_lastAngularVelocity); |
3497 | 3499 | ||