diff options
author | Teravus Ovares | 2009-04-07 16:13:17 +0000 |
---|---|---|
committer | Teravus Ovares | 2009-04-07 16:13:17 +0000 |
commit | 9bbc7e8bf690800affd4d5767959932ad033dd7c (patch) | |
tree | 555c666a712aa4de209c6ccf84107c53a743e308 /OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |
parent | * Tweak the BulletDotNETPlugin character controller so it feels more finished. (diff) | |
download | opensim-SC_OLD-9bbc7e8bf690800affd4d5767959932ad033dd7c.zip opensim-SC_OLD-9bbc7e8bf690800affd4d5767959932ad033dd7c.tar.gz opensim-SC_OLD-9bbc7e8bf690800affd4d5767959932ad033dd7c.tar.bz2 opensim-SC_OLD-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/ODEPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 134 |
1 files changed, 114 insertions, 20 deletions
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 | ||