From 118986f15078a1df5561a64355e6f4777ae74fe1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 26 Feb 2012 17:51:43 +0000 Subject: added in chODE GeomTriMeshDataDestroy to explicity release internal trimesh data. --- OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs | 33 +++++++++++++++++++++++-- OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs | 11 ++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Physics') diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs index 636039b..86ab58d 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODEPrim.cs @@ -704,6 +704,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_isphysical) m_targetSpace = _parent_scene.space; + _triMeshData = IntPtr.Zero; + m_primName = primName; m_taintserial = null; m_taintadd = true; @@ -773,6 +775,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_targetSpace = _parent_scene.space; } + _triMeshData = IntPtr.Zero; + m_taintserial = null; m_primName = primName; m_taintadd = true; @@ -1785,6 +1789,15 @@ namespace OpenSim.Region.Physics.OdePlugin disableBody(); } } + +// do it on caller instead +/* + if (_triMeshData != IntPtr.Zero) + { + d.GeomTriMeshDataDestroy(_triMeshData); + _triMeshData = IntPtr.Zero; + } +*/ IntPtr vertices, indices; int vertexCount, indexCount; int vertexStride, triStride; @@ -1801,14 +1814,17 @@ namespace OpenSim.Region.Physics.OdePlugin } -/* + // warning this destroys the mesh for eventual future use. Only pinned float arrays stay valid mesh.releaseSourceMeshData(); // free up the original mesh data to save memory +/* if (m_MeshToTriMeshMap.ContainsKey(mesh)) { _triMeshData = m_MeshToTriMeshMap[mesh]; } else - */ +*/ + + { _triMeshData = d.GeomTriMeshDataCreate(); @@ -1829,6 +1845,13 @@ namespace OpenSim.Region.Physics.OdePlugin catch (AccessViolationException) { m_log.Error("[PHYSICS]: MESH LOCKED"); + + if (_triMeshData != IntPtr.Zero) + { + d.GeomTriMeshDataDestroy(_triMeshData); + _triMeshData = IntPtr.Zero; + } + return false; } @@ -2302,6 +2325,12 @@ namespace OpenSim.Region.Physics.OdePlugin { bool gottrimesh = false; + if (_triMeshData != IntPtr.Zero) + { + d.GeomTriMeshDataDestroy(_triMeshData); + _triMeshData = IntPtr.Zero; + } + if (_mesh != null) // Special - make mesh { gottrimesh = setMesh(_parent_scene, _mesh); diff --git a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs index 61fb2d0..f84918c 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/OdePlugin.cs @@ -2174,6 +2174,16 @@ namespace OpenSim.Region.Physics.OdePlugin { prim.ResetTaints(); + try + { + if (prim._triMeshData != IntPtr.Zero) + { + d.GeomTriMeshDataDestroy(prim._triMeshData); + prim._triMeshData = IntPtr.Zero; + } + } + catch { }; + if (prim.IsPhysical) { prim.disableBody(); @@ -2185,7 +2195,6 @@ namespace OpenSim.Region.Physics.OdePlugin prim.IsPhysical = false; } - } // we don't want to remove the main space -- cgit v1.1