added in chODE GeomTriMeshDataDestroy to explicity release internal trimesh data.

avinationmerge
UbitUmarov 2012-02-26 17:51:43 +00:00
parent 416f39a561
commit 118986f150
2 changed files with 41 additions and 3 deletions

View File

@ -704,6 +704,8 @@ namespace OpenSim.Region.Physics.OdePlugin
if (m_isphysical) if (m_isphysical)
m_targetSpace = _parent_scene.space; m_targetSpace = _parent_scene.space;
_triMeshData = IntPtr.Zero;
m_primName = primName; m_primName = primName;
m_taintserial = null; m_taintserial = null;
m_taintadd = true; m_taintadd = true;
@ -773,6 +775,8 @@ namespace OpenSim.Region.Physics.OdePlugin
m_targetSpace = _parent_scene.space; m_targetSpace = _parent_scene.space;
} }
_triMeshData = IntPtr.Zero;
m_taintserial = null; m_taintserial = null;
m_primName = primName; m_primName = primName;
m_taintadd = true; m_taintadd = true;
@ -1785,6 +1789,15 @@ namespace OpenSim.Region.Physics.OdePlugin
disableBody(); disableBody();
} }
} }
// do it on caller instead
/*
if (_triMeshData != IntPtr.Zero)
{
d.GeomTriMeshDataDestroy(_triMeshData);
_triMeshData = IntPtr.Zero;
}
*/
IntPtr vertices, indices; IntPtr vertices, indices;
int vertexCount, indexCount; int vertexCount, indexCount;
int vertexStride, triStride; 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 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
/*
if (m_MeshToTriMeshMap.ContainsKey(mesh)) if (m_MeshToTriMeshMap.ContainsKey(mesh))
{ {
_triMeshData = m_MeshToTriMeshMap[mesh]; _triMeshData = m_MeshToTriMeshMap[mesh];
} }
else else
*/ */
{ {
_triMeshData = d.GeomTriMeshDataCreate(); _triMeshData = d.GeomTriMeshDataCreate();
@ -1829,6 +1845,13 @@ namespace OpenSim.Region.Physics.OdePlugin
catch (AccessViolationException) catch (AccessViolationException)
{ {
m_log.Error("[PHYSICS]: MESH LOCKED"); m_log.Error("[PHYSICS]: MESH LOCKED");
if (_triMeshData != IntPtr.Zero)
{
d.GeomTriMeshDataDestroy(_triMeshData);
_triMeshData = IntPtr.Zero;
}
return false; return false;
} }
@ -2302,6 +2325,12 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
bool gottrimesh = false; bool gottrimesh = false;
if (_triMeshData != IntPtr.Zero)
{
d.GeomTriMeshDataDestroy(_triMeshData);
_triMeshData = IntPtr.Zero;
}
if (_mesh != null) // Special - make mesh if (_mesh != null) // Special - make mesh
{ {
gottrimesh = setMesh(_parent_scene, _mesh); gottrimesh = setMesh(_parent_scene, _mesh);

View File

@ -2174,6 +2174,16 @@ namespace OpenSim.Region.Physics.OdePlugin
{ {
prim.ResetTaints(); prim.ResetTaints();
try
{
if (prim._triMeshData != IntPtr.Zero)
{
d.GeomTriMeshDataDestroy(prim._triMeshData);
prim._triMeshData = IntPtr.Zero;
}
}
catch { };
if (prim.IsPhysical) if (prim.IsPhysical)
{ {
prim.disableBody(); prim.disableBody();
@ -2185,7 +2195,6 @@ namespace OpenSim.Region.Physics.OdePlugin
prim.IsPhysical = false; prim.IsPhysical = false;
} }
} }
// we don't want to remove the main space // we don't want to remove the main space