From e33a0c5fc0b107a99b34ff3c9016f8de178d0d47 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 17 Feb 2008 11:50:15 +0000 Subject: * Fixed the Ghost physical hull on deleting a physical Prim * Fixed a deadlock when there is an exception in the collision and stepping parts of Simulate. --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 136 ++++++++++++++------------ 1 file changed, 75 insertions(+), 61 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index d7d9ab1..0fd4f4d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -755,74 +755,77 @@ namespace OpenSim.Region.Physics.OdePlugin prim.disableBody(); } // we don't want to remove the main space - if (prim.m_targetSpace != space && prim.IsPhysical == false) - { - // If the geometry is in the targetspace, remove it from the target space - //m_log.Warn(prim.m_targetSpace); + + // If the geometry is in the targetspace, remove it from the target space + //m_log.Warn(prim.m_targetSpace); - if (prim.m_targetSpace != (IntPtr)0) + if (prim.m_targetSpace != (IntPtr)0) + { + if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) { - if (d.SpaceQuery(prim.m_targetSpace, prim.prim_geom)) - { - - if (d.GeomIsSpace(prim.m_targetSpace)) - { - waitForSpaceUnlock(prim.m_targetSpace); - d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); - prim.m_targetSpace = space; - } - else - { - m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + - ((OdePrim)prim).m_targetSpace.ToString()); - } + if (d.GeomIsSpace(prim.m_targetSpace)) + { + waitForSpaceUnlock(prim.m_targetSpace); + d.SpaceRemove(prim.m_targetSpace, prim.prim_geom); + prim.m_targetSpace = space; } - } - //m_log.Warn(prim.prim_geom); - try - { - if (prim.prim_geom != (IntPtr)0) + else { - d.GeomDestroy(prim.prim_geom); - prim.prim_geom = (IntPtr)0; + m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim)prim).m_targetSpace.ToString()); } } - catch (System.AccessViolationException) + } + //m_log.Warn(prim.prim_geom); + try + { + if (prim.prim_geom != (IntPtr)0) { - m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed."); + d.GeomDestroy(prim.prim_geom); + prim.prim_geom = (IntPtr)0; + } + else + { + m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); } - _prims.Remove(prim); - //If there are no more geometries in the sub-space, we don't need it in the main space anymore - //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) - //{ - //if (!(prim.m_targetSpace.Equals(null))) - //{ - //if (d.GeomIsSpace(prim.m_targetSpace)) - //{ - //waitForSpaceUnlock(prim.m_targetSpace); - //d.SpaceRemove(space, prim.m_targetSpace); - // free up memory used by the space. - //d.SpaceDestroy(prim.m_targetSpace); - //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position); - //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]); - //} - //else - //{ - //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + - //((OdePrim) prim).m_targetSpace.ToString()); - //} - //} - //} } + catch (System.AccessViolationException) + { + m_log.Info("[PHYSICS]: Couldn't remove prim from physics scene, it was already be removed."); + } + _prims.Remove(prim); + + //If there are no more geometries in the sub-space, we don't need it in the main space anymore + //if (d.SpaceGetNumGeoms(prim.m_targetSpace) == 0) + //{ + //if (!(prim.m_targetSpace.Equals(null))) + //{ + //if (d.GeomIsSpace(prim.m_targetSpace)) + //{ + //waitForSpaceUnlock(prim.m_targetSpace); + //d.SpaceRemove(space, prim.m_targetSpace); + // free up memory used by the space. + //d.SpaceDestroy(prim.m_targetSpace); + //int[] xyspace = calculateSpaceArrayItemFromPos(prim.Position); + //resetSpaceArrayItemToZero(xyspace[0], xyspace[1]); + //} + //else + //{ + //m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + + //((OdePrim) prim).m_targetSpace.ToString()); + //} + //} + //} + } - ode.dunlock(world); - } + ode.dunlock(world); + } } /// @@ -1261,19 +1264,30 @@ namespace OpenSim.Region.Physics.OdePlugin if (!ode.lockquery()) { ode.dlock(world); - foreach (OdeCharacter actor in _characters) + try { - actor.Move(timeStep); - - } - + foreach (OdeCharacter actor in _characters) + { + actor.Move(timeStep); + + } + - collision_optimized(timeStep); + collision_optimized(timeStep); - d.WorldQuickStep(world, ODE_STEPSIZE); + d.WorldQuickStep(world, ODE_STEPSIZE); - d.JointGroupEmpty(contactgroup); - ode.dunlock(world); + d.JointGroupEmpty(contactgroup); + ode.dunlock(world); + } + catch (Exception e) + { + m_log.Error("[PHYSICS]: " + e.Message.ToString() + e.TargetSite.ToString()); + ode.dunlock(world); + } + + + step_time -= ODE_STEPSIZE; i++; -- cgit v1.1