From b326b55bcd7b794cb90c0df9337cc817db58f9a2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Tue, 7 Apr 2009 16:41:07 +0000 Subject: [PATCH] * Added finite testing to the character and object constructor --- .../Region/Physics/OdePlugin/ODECharacter.cs | 21 +++++++++++++++---- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 18 ++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index c37b632cb0..c160cda532 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -133,11 +133,24 @@ namespace OpenSim.Region.Physics.OdePlugin // ode = dode; _velocity = new PhysicsVector(); _target_velocity = new PhysicsVector(); - _position = pos; - m_taintPosition.X = pos.X; - m_taintPosition.Y = pos.Y; - m_taintPosition.Z = pos.Z; + + if (PhysicsVector.isFinite(pos)) + { + _position = pos; + m_taintPosition.X = pos.X; + m_taintPosition.Y = pos.Y; + m_taintPosition.Z = pos.Z; + } + else + { + _position = new PhysicsVector(128,128,parent_scene.GetTerrainHeightAtXY(128,128) + 10); + m_taintPosition.X = _position.X; + m_taintPosition.Y = _position.Y; + m_taintPosition.Z = _position.Z; + m_log.Warn("[PHYSICS]: Got NaN Position on Character Create"); + } + _acceleration = new PhysicsVector(); _parent_scene = parent_scene; diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index a55ae769ee..5e7ec37c77 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -173,6 +173,11 @@ namespace OpenSim.Region.Physics.OdePlugin //gc = GCHandle.Alloc(prim_geom, GCHandleType.Pinned); ode = dode; _velocity = new PhysicsVector(); + if (!PhysicsVector.isFinite(pos)) + { + pos = new PhysicsVector(128, 128, parent_scene.GetTerrainHeightAtXY(128, 128) + 0.5f); + m_log.Warn("[PHYSICS]: Got nonFinite Object create Position"); + } _position = pos; m_taintposition = pos; PID_D = parent_scene.bodyPIDD; @@ -185,6 +190,12 @@ namespace OpenSim.Region.Physics.OdePlugin prim_geom = IntPtr.Zero; prev_geom = IntPtr.Zero; + if (!PhysicsVector.isFinite(pos)) + { + size = new PhysicsVector(0.5f, 0.5f, 0.5f); + m_log.Warn("[PHYSICS]: Got nonFinite Object create Size"); + } + if (size.X <= 0) size.X = 0.01f; if (size.Y <= 0) size.Y = 0.01f; if (size.Z <= 0) size.Z = 0.01f; @@ -193,6 +204,13 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintsize = _size; _acceleration = new PhysicsVector(); m_rotationalVelocity = PhysicsVector.Zero; + + if (!QuaternionIsFinite(rotation)) + { + rotation = Quaternion.Identity; + m_log.Warn("[PHYSICS]: Got nonFinite Object create Rotation"); + } + _orientation = rotation; m_taintrot = _orientation; _mesh = mesh;