From 694bab9513460c03b5d4fce2a40d832767769d12 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 18 Nov 2007 20:45:47 +0000 Subject: * Copy/SpaceBorder Fix attempt number 3, hopefully the last --- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin/OdePlugin.cs') diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index 2e28a81..4f8ec7f 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -421,10 +421,16 @@ namespace OpenSim.Region.Physics.OdePlugin //If there are no more geometries in the sub-space, we don't need it in the main space anymore if (d.SpaceGetNumGeoms(((OdePrim)prim).m_targetSpace) == 0) { - d.SpaceRemove(space, ((OdePrim)prim).m_targetSpace); - // free up memory used by the space. - d.SpaceDestroy(((OdePrim)prim).m_targetSpace); - resetSpaceArrayItemToZero(calculateSpaceArrayItemFromPos(((OdePrim)prim).Position)); + if (!(((OdePrim)prim).m_targetSpace.Equals(null))) + { + if (d.GeomIsSpace(((OdePrim)prim).m_targetSpace)) + { + d.SpaceRemove(space, ((OdePrim)prim).m_targetSpace); + // free up memory used by the space. + d.SpaceDestroy(((OdePrim)prim).m_targetSpace); + resetSpaceArrayItemToZero(calculateSpaceArrayItemFromPos(((OdePrim)prim).Position)); + } + } } } @@ -461,8 +467,8 @@ namespace OpenSim.Region.Physics.OdePlugin { if (d.SpaceQuery(currentspace, geom) && currentspace != (IntPtr)0) { - - d.SpaceRemove(currentspace, geom); + if (d.GeomIsSpace(currentspace)) + d.SpaceRemove(currentspace, geom); } else { @@ -481,10 +487,13 @@ namespace OpenSim.Region.Physics.OdePlugin { if (currentspace != (IntPtr)0) { - d.SpaceRemove(space, currentspace); - // free up memory used by the space. - d.SpaceDestroy(currentspace); - resetSpaceArrayItemToZero(currentspace); + if (d.GeomIsSpace(currentspace)) + { + d.SpaceRemove(space, currentspace); + // free up memory used by the space. + d.SpaceDestroy(currentspace); + resetSpaceArrayItemToZero(currentspace); + } } } } @@ -503,7 +512,8 @@ namespace OpenSim.Region.Physics.OdePlugin { if (sGeomIsIn != (IntPtr)0) { - d.SpaceRemove(sGeomIsIn, geom); + if (d.GeomIsSpace(sGeomIsIn)) + d.SpaceRemove(sGeomIsIn, geom); } } } -- cgit v1.1