From 6f7a560c04de374bc8239a662e53a806c2e07b2b Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 14 Dec 2008 06:34:05 +0000 Subject: * A Few physical prim + linkset fixes. Prevent some crashes --- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 70 +++++++++++++++++++++-------- 1 file changed, 51 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index bd28dda..eeef893 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -700,6 +700,17 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyDestroy(Body); + lock (childrenPrim) + { + if (childrenPrim.Count > 0) + { + foreach (OdePrim prm in childrenPrim) + { + _parent_scene.remActivePrim(prm); + prm.Body = IntPtr.Zero; + } + } + } Body = IntPtr.Zero; } } @@ -971,6 +982,12 @@ namespace OpenSim.Region.Physics.OdePlugin prm.m_collisionCategories |= CollisionCategories.Body; prm.m_collisionFlags |= (CollisionCategories.Land | CollisionCategories.Wind); + if (prm.prim_geom == IntPtr.Zero) + { + m_log.Warn("[PHYSICS]: Unable to link one of the linkset elements. No geom yet"); + continue; + } + d.GeomSetCategoryBits(prm.prim_geom, (int)prm.m_collisionCategories); d.GeomSetCollideBits(prm.prim_geom, (int)prm.m_collisionFlags); @@ -1345,31 +1362,46 @@ namespace OpenSim.Region.Physics.OdePlugin { if (m_isphysical) { - // This is a fallback.. May no longer be necessary. - if (Body == IntPtr.Zero) - enableBody(); - //Prim auto disable after 20 frames, - //if you move it, re-enable the prim manually. - if (_parent != null) + + if (!m_disabled && !m_taintremove && !childPrim) { - if (m_linkJoint != IntPtr.Zero) + if (Body == IntPtr.Zero) + enableBody(); + //Prim auto disable after 20 frames, + //if you move it, re-enable the prim manually. + if (_parent != null) { - d.JointDestroy(m_linkJoint); - m_linkJoint = IntPtr.Zero; + if (m_linkJoint != IntPtr.Zero) + { + d.JointDestroy(m_linkJoint); + m_linkJoint = IntPtr.Zero; + } } - } - d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); - if (_parent != null) - { - OdePrim odParent = (OdePrim)_parent; - if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body) + if (Body != IntPtr.Zero) { - m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); - d.JointAttach(m_linkJoint, Body, odParent.Body); - d.JointSetFixed(m_linkJoint); + d.BodySetPosition(Body, _position.X, _position.Y, _position.Z); + + if (_parent != null) + { + OdePrim odParent = (OdePrim)_parent; + if (Body != (IntPtr)0 && odParent.Body != (IntPtr)0 && Body != odParent.Body) + { + m_linkJoint = d.JointCreateFixed(_parent_scene.world, _linkJointGroup); + d.JointAttach(m_linkJoint, Body, odParent.Body); + d.JointSetFixed(m_linkJoint); + } + } + d.BodyEnable(Body); + } + else + { + m_log.Warn("[PHYSICS]: Body Still null after enableBody(). This is a crash scenario."); } } - d.BodyEnable(Body); + //else + // { + //m_log.Debug("[BUG]: race!"); + //} } else { -- cgit v1.1