No need to create dupe TriMeshData for ODE. A previous patch created a dictionary to store unique meshes in Meshmerizer based on creation params. This patch contains a dictionary to map each of those unique meshes to its ODE TriMeshData. This eliminated hundreds of megabytes of memory consumption in the unmanaged heap when there are lots of the same prim (roof tiles, bricks, siding, decks, chairs, etc). The objects do not need to be physical to benefit from this patch.
parent
ad624f703d
commit
428bd7a74b
|
@ -801,6 +801,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
m_collisionscore = 0;
|
m_collisionscore = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
|
||||||
|
|
||||||
public void setMesh(OdeScene parent_scene, IMesh mesh)
|
public void setMesh(OdeScene parent_scene, IMesh mesh)
|
||||||
{
|
{
|
||||||
// This sleeper is there to moderate how long it takes between
|
// This sleeper is there to moderate how long it takes between
|
||||||
|
@ -832,19 +834,24 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
|
mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
|
||||||
|
|
||||||
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))
|
||||||
|
{
|
||||||
|
_triMeshData = m_MeshToTriMeshMap[mesh];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_triMeshData = d.GeomTriMeshDataCreate();
|
||||||
|
|
||||||
_triMeshData = d.GeomTriMeshDataCreate();
|
d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
|
||||||
|
d.GeomTriMeshDataPreprocess(_triMeshData);
|
||||||
d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
|
m_MeshToTriMeshMap[mesh] = _triMeshData;
|
||||||
d.GeomTriMeshDataPreprocess(_triMeshData);
|
}
|
||||||
|
|
||||||
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
_parent_scene.waitForSpaceUnlock(m_targetSpace);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (prim_geom == IntPtr.Zero)
|
if (prim_geom == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
//Console.WriteLine(" setMesh 1");
|
|
||||||
SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
|
SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -854,6 +861,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// if (IsPhysical && Body == (IntPtr) 0)
|
// if (IsPhysical && Body == (IntPtr) 0)
|
||||||
// {
|
// {
|
||||||
// Recreate the body
|
// Recreate the body
|
||||||
|
|
Loading…
Reference in New Issue