aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/OdePlugin
diff options
context:
space:
mode:
authorTeravus Ovares2009-04-07 16:13:17 +0000
committerTeravus Ovares2009-04-07 16:13:17 +0000
commit9bbc7e8bf690800affd4d5767959932ad033dd7c (patch)
tree555c666a712aa4de209c6ccf84107c53a743e308 /OpenSim/Region/Physics/OdePlugin
parent* Tweak the BulletDotNETPlugin character controller so it feels more finished. (diff)
downloadopensim-SC-9bbc7e8bf690800affd4d5767959932ad033dd7c.zip
opensim-SC-9bbc7e8bf690800affd4d5767959932ad033dd7c.tar.gz
opensim-SC-9bbc7e8bf690800affd4d5767959932ad033dd7c.tar.bz2
opensim-SC-9bbc7e8bf690800affd4d5767959932ad033dd7c.tar.xz
* Added a routine to check if a PhysicsVector and Quaternion is finite
* Now validating input to the Physics scene and warning when something is awry. * This should help nail down that Non Finite Avatar Position Detected issue.
Diffstat (limited to 'OpenSim/Region/Physics/OdePlugin')
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODECharacter.cs90
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs134
2 files changed, 179 insertions, 45 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
index bf8ca0e..c37b632 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs
@@ -380,10 +380,23 @@ namespace OpenSim.Region.Physics.OdePlugin
380 set 380 set
381 { 381 {
382 if (Body == IntPtr.Zero || Shell == IntPtr.Zero) 382 if (Body == IntPtr.Zero || Shell == IntPtr.Zero)
383 _position.X = value.X; _position.Y = value.Y; _position.Z = value.Z; 383 {
384 384 if (PhysicsVector.isFinite(value))
385 m_taintPosition.X = value.X; m_taintPosition.Y = value.Y; m_taintPosition.Z = value.Z; 385 {
386 _parent_scene.AddPhysicsActorTaint(this); 386 _position.X = value.X;
387 _position.Y = value.Y;
388 _position.Z = value.Z;
389
390 m_taintPosition.X = value.X;
391 m_taintPosition.Y = value.Y;
392 m_taintPosition.Z = value.Z;
393 _parent_scene.AddPhysicsActorTaint(this);
394 }
395 else
396 {
397 m_log.Warn("[PHYSICS]: Got a NaN Position from Scene on a Character");
398 }
399 }
387 } 400 }
388 } 401 }
389 402
@@ -402,15 +415,22 @@ namespace OpenSim.Region.Physics.OdePlugin
402 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); } 415 get { return new PhysicsVector(CAPSULE_RADIUS*2, CAPSULE_RADIUS*2, CAPSULE_LENGTH); }
403 set 416 set
404 { 417 {
405 m_pidControllerActive = true; 418 if (PhysicsVector.isFinite(value))
406 419 {
420 m_pidControllerActive = true;
421
407 PhysicsVector SetSize = value; 422 PhysicsVector SetSize = value;
408 m_tainted_CAPSULE_LENGTH = (SetSize.Z * 1.15f) - CAPSULE_RADIUS * 2.0f; 423 m_tainted_CAPSULE_LENGTH = (SetSize.Z*1.15f) - CAPSULE_RADIUS*2.0f;
409 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); 424 //m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString());
410 425
411 Velocity = new PhysicsVector(0f, 0f, 0f); 426 Velocity = new PhysicsVector(0f, 0f, 0f);
412 427
413 _parent_scene.AddPhysicsActorTaint(this); 428 _parent_scene.AddPhysicsActorTaint(this);
429 }
430 else
431 {
432 m_log.Warn("[PHYSICS]: Got a NaN Size from Scene on a Character");
433 }
414 } 434 }
415 } 435 }
416 436
@@ -616,8 +636,15 @@ namespace OpenSim.Region.Physics.OdePlugin
616 } 636 }
617 set 637 set
618 { 638 {
619 m_pidControllerActive = true; 639 if (PhysicsVector.isFinite(value))
620 _target_velocity = value; 640 {
641 m_pidControllerActive = true;
642 _target_velocity = value;
643 }
644 else
645 {
646 m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character");
647 }
621 } 648 }
622 } 649 }
623 650
@@ -667,22 +694,29 @@ namespace OpenSim.Region.Physics.OdePlugin
667 /// <param name="force"></param> 694 /// <param name="force"></param>
668 public override void AddForce(PhysicsVector force, bool pushforce) 695 public override void AddForce(PhysicsVector force, bool pushforce)
669 { 696 {
670 if (pushforce) 697 if (PhysicsVector.isFinite(force))
671 { 698 {
672 m_pidControllerActive = false; 699 if (pushforce)
673 force *= 100f; 700 {
674 doForce(force); 701 m_pidControllerActive = false;
675 //m_log.Debug("Push!"); 702 force *= 100f;
676 //_target_velocity.X += force.X; 703 doForce(force);
677 // _target_velocity.Y += force.Y; 704 //m_log.Debug("Push!");
678 //_target_velocity.Z += force.Z; 705 //_target_velocity.X += force.X;
706 // _target_velocity.Y += force.Y;
707 //_target_velocity.Z += force.Z;
708 }
709 else
710 {
711 m_pidControllerActive = true;
712 _target_velocity.X += force.X;
713 _target_velocity.Y += force.Y;
714 _target_velocity.Z += force.Z;
715 }
679 } 716 }
680 else 717 else
681 { 718 {
682 m_pidControllerActive = true; 719 m_log.Warn("[PHYSICS]: Got a NaN force applied to a Character");
683 _target_velocity.X += force.X;
684 _target_velocity.Y += force.Y;
685 _target_velocity.Z += force.Z;
686 } 720 }
687 //m_lastUpdateSent = false; 721 //m_lastUpdateSent = false;
688 } 722 }
@@ -847,8 +881,14 @@ namespace OpenSim.Region.Physics.OdePlugin
847 // end add Kitto Flora 881 // end add Kitto Flora
848 882
849 } 883 }
850 884 if (PhysicsVector.isFinite(vec))
851 doForce(vec); 885 {
886 doForce(vec);
887 }
888 else
889 {
890 m_log.Warn("[PHYSICS]: Got a NaN force vector in Move()");
891 }
852 } 892 }
853 893
854 /// <summary> 894 /// <summary>
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 56bd289..a55ae76 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -2325,7 +2325,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2325 public override PhysicsVector Size 2325 public override PhysicsVector Size
2326 { 2326 {
2327 get { return _size; } 2327 get { return _size; }
2328 set { _size = value; } 2328 set
2329 {
2330 if (PhysicsVector.isFinite(value))
2331 {
2332 _size = value;
2333 }
2334 else
2335 {
2336 m_log.Warn("[PHYSICS]: Got NaN Size on object");
2337 }
2338 }
2329 } 2339 }
2330 2340
2331 public override float Mass 2341 public override float Mass
@@ -2337,7 +2347,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2337 { 2347 {
2338 //get { return PhysicsVector.Zero; } 2348 //get { return PhysicsVector.Zero; }
2339 get { return m_force; } 2349 get { return m_force; }
2340 set { m_force = value; } 2350 set
2351 {
2352 if (PhysicsVector.isFinite(value))
2353 {
2354 m_force = value;
2355 }
2356 else
2357 {
2358 m_log.Warn("[PHYSICS]: NaN in Force Applied to an Object");
2359 }
2360 }
2341 } 2361 }
2342 2362
2343 public override int VehicleType 2363 public override int VehicleType
@@ -2402,10 +2422,18 @@ namespace OpenSim.Region.Physics.OdePlugin
2402 } 2422 }
2403 set 2423 set
2404 { 2424 {
2405 _velocity = value; 2425 if (PhysicsVector.isFinite(value))
2426 {
2427 _velocity = value;
2428
2429 m_taintVelocity = value;
2430 _parent_scene.AddPhysicsActorTaint(this);
2431 }
2432 else
2433 {
2434 m_log.Warn("[PHYSICS]: Got NaN Velocity in Object");
2435 }
2406 2436
2407 m_taintVelocity = value;
2408 _parent_scene.AddPhysicsActorTaint(this);
2409 } 2437 }
2410 } 2438 }
2411 2439
@@ -2421,8 +2449,15 @@ namespace OpenSim.Region.Physics.OdePlugin
2421 2449
2422 set 2450 set
2423 { 2451 {
2424 m_taintTorque = value; 2452 if (PhysicsVector.isFinite(value))
2425 _parent_scene.AddPhysicsActorTaint(this); 2453 {
2454 m_taintTorque = value;
2455 _parent_scene.AddPhysicsActorTaint(this);
2456 }
2457 else
2458 {
2459 m_log.Warn("[PHYSICS]: Got NaN Torque in Object");
2460 }
2426 } 2461 }
2427 } 2462 }
2428 2463
@@ -2441,7 +2476,27 @@ namespace OpenSim.Region.Physics.OdePlugin
2441 public override Quaternion Orientation 2476 public override Quaternion Orientation
2442 { 2477 {
2443 get { return _orientation; } 2478 get { return _orientation; }
2444 set { _orientation = value; } 2479 set
2480 {
2481 if (QuaternionIsFinite(value))
2482 _orientation = value;
2483 else
2484 m_log.Warn("[PHYSICS]: Got NaN quaternion Orientation from Scene in Object");
2485
2486 }
2487 }
2488
2489 internal static bool QuaternionIsFinite(Quaternion q)
2490 {
2491 if (Single.IsNaN(q.X) || Single.IsInfinity(q.X))
2492 return false;
2493 if (Single.IsNaN(q.Y) || Single.IsInfinity(q.Y))
2494 return false;
2495 if (Single.IsNaN(q.Z) || Single.IsInfinity(q.Z))
2496 return false;
2497 if (Single.IsNaN(q.W) || Single.IsInfinity(q.W))
2498 return false;
2499 return true;
2445 } 2500 }
2446 2501
2447 public override PhysicsVector Acceleration 2502 public override PhysicsVector Acceleration
@@ -2457,15 +2512,29 @@ namespace OpenSim.Region.Physics.OdePlugin
2457 2512
2458 public override void AddForce(PhysicsVector force, bool pushforce) 2513 public override void AddForce(PhysicsVector force, bool pushforce)
2459 { 2514 {
2460 m_forcelist.Add(force); 2515 if (PhysicsVector.isFinite(force))
2461 m_taintforce = true; 2516 {
2517 m_forcelist.Add(force);
2518 m_taintforce = true;
2519 }
2520 else
2521 {
2522 m_log.Warn("[PHYSICS]: Got Invalid linear force vector from Scene in Object");
2523 }
2462 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); 2524 //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString());
2463 } 2525 }
2464 2526
2465 public override void AddAngularForce(PhysicsVector force, bool pushforce) 2527 public override void AddAngularForce(PhysicsVector force, bool pushforce)
2466 { 2528 {
2467 m_angularforcelist.Add(force); 2529 if (PhysicsVector.isFinite(force))
2468 m_taintaddangularforce = true; 2530 {
2531 m_angularforcelist.Add(force);
2532 m_taintaddangularforce = true;
2533 }
2534 else
2535 {
2536 m_log.Warn("[PHYSICS]: Got Invalid Angular force vector from Scene in Object");
2537 }
2469 } 2538 }
2470 2539
2471 public override PhysicsVector RotationalVelocity 2540 public override PhysicsVector RotationalVelocity
@@ -2482,7 +2551,17 @@ namespace OpenSim.Region.Physics.OdePlugin
2482 2551
2483 return m_rotationalVelocity; 2552 return m_rotationalVelocity;
2484 } 2553 }
2485 set { m_rotationalVelocity = value; } 2554 set
2555 {
2556 if (PhysicsVector.isFinite(value))
2557 {
2558 m_rotationalVelocity = value;
2559 }
2560 else
2561 {
2562 m_log.Warn("[PHYSICS]: Got NaN RotationalVelocity in Object");
2563 }
2564 }
2486 } 2565 }
2487 2566
2488 public override void CrossingFailure() 2567 public override void CrossingFailure()
@@ -2518,12 +2597,18 @@ namespace OpenSim.Region.Physics.OdePlugin
2518 public override void LockAngularMotion(PhysicsVector axis) 2597 public override void LockAngularMotion(PhysicsVector axis)
2519 { 2598 {
2520 // reverse the zero/non zero values for ODE. 2599 // reverse the zero/non zero values for ODE.
2521 2600 if (PhysicsVector.isFinite(axis))
2522 axis.X = (axis.X > 0) ? 1f : 0f; 2601 {
2523 axis.Y = (axis.Y > 0) ? 1f : 0f; 2602 axis.X = (axis.X > 0) ? 1f : 0f;
2524 axis.Z = (axis.Z > 0) ? 1f : 0f; 2603 axis.Y = (axis.Y > 0) ? 1f : 0f;
2525 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z); 2604 axis.Z = (axis.Z > 0) ? 1f : 0f;
2526 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z); ; 2605 m_log.DebugFormat("[axislock]: <{0},{1},{2}>", axis.X, axis.Y, axis.Z);
2606 m_taintAngularLock = new PhysicsVector(axis.X, axis.Y, axis.Z);
2607 }
2608 else
2609 {
2610 m_log.Warn("[PHYSICS]: Got NaN locking axis from Scene on Object");
2611 }
2527 } 2612 }
2528 2613
2529 public void UpdatePositionAndVelocity() 2614 public void UpdatePositionAndVelocity()
@@ -2734,7 +2819,16 @@ namespace OpenSim.Region.Physics.OdePlugin
2734 { 2819 {
2735 } 2820 }
2736 2821
2737 public override PhysicsVector PIDTarget { set { m_PIDTarget = value; ; } } 2822 public override PhysicsVector PIDTarget
2823 {
2824 set
2825 {
2826 if (PhysicsVector.isFinite(value))
2827 m_PIDTarget = value;
2828 else
2829 m_log.Warn("[PHYSICS]: Got NaN PIDTarget from Scene on Object");
2830 }
2831 }
2738 public override bool PIDActive { set { m_usePID = value; } } 2832 public override bool PIDActive { set { m_usePID = value; } }
2739 public override float PIDTau { set { m_PIDTau = value; } } 2833 public override float PIDTau { set { m_PIDTau = value; } }
2740 2834