aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDan Lake2009-10-26 13:57:27 -0700
committerJohn Hurliman2009-10-26 15:14:19 -0700
commit428bd7a74bd9e1df3af29dd285fe385e5c4d526d (patch)
tree0bf9916c8850605028f6656e93d830a43a57bfc0
parentParcelObjectOwnersReplyPacket has null DataBlock when a client requests a lis... (diff)
downloadopensim-SC-428bd7a74bd9e1df3af29dd285fe385e5c4d526d.zip
opensim-SC-428bd7a74bd9e1df3af29dd285fe385e5c4d526d.tar.gz
opensim-SC-428bd7a74bd9e1df3af29dd285fe385e5c4d526d.tar.bz2
opensim-SC-428bd7a74bd9e1df3af29dd285fe385e5c4d526d.tar.xz
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.
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs20
1 files changed, 14 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index 412f84d..09c8582 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -801,6 +801,8 @@ namespace OpenSim.Region.Physics.OdePlugin
801 m_collisionscore = 0; 801 m_collisionscore = 0;
802 } 802 }
803 803
804 private static Dictionary<IMesh, IntPtr> m_MeshToTriMeshMap = new Dictionary<IMesh, IntPtr>();
805
804 public void setMesh(OdeScene parent_scene, IMesh mesh) 806 public void setMesh(OdeScene parent_scene, IMesh mesh)
805 { 807 {
806 // This sleeper is there to moderate how long it takes between 808 // This sleeper is there to moderate how long it takes between
@@ -832,19 +834,24 @@ namespace OpenSim.Region.Physics.OdePlugin
832 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage 834 mesh.getIndexListAsPtrToIntArray(out indices, out triStride, out indexCount); // Also fixed, needs release after usage
833 835
834 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory 836 mesh.releaseSourceMeshData(); // free up the original mesh data to save memory
837 if (m_MeshToTriMeshMap.ContainsKey(mesh))
838 {
839 _triMeshData = m_MeshToTriMeshMap[mesh];
840 }
841 else
842 {
843 _triMeshData = d.GeomTriMeshDataCreate();
835 844
836 _triMeshData = d.GeomTriMeshDataCreate(); 845 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride);
837 846 d.GeomTriMeshDataPreprocess(_triMeshData);
838 d.GeomTriMeshDataBuildSimple(_triMeshData, vertices, vertexStride, vertexCount, indices, indexCount, triStride); 847 m_MeshToTriMeshMap[mesh] = _triMeshData;
839 d.GeomTriMeshDataPreprocess(_triMeshData); 848 }
840 849
841 _parent_scene.waitForSpaceUnlock(m_targetSpace); 850 _parent_scene.waitForSpaceUnlock(m_targetSpace);
842
843 try 851 try
844 { 852 {
845 if (prim_geom == IntPtr.Zero) 853 if (prim_geom == IntPtr.Zero)
846 { 854 {
847//Console.WriteLine(" setMesh 1");
848 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null)); 855 SetGeom(d.CreateTriMesh(m_targetSpace, _triMeshData, parent_scene.triCallback, null, null));
849 } 856 }
850 } 857 }
@@ -854,6 +861,7 @@ namespace OpenSim.Region.Physics.OdePlugin
854 return; 861 return;
855 } 862 }
856 863
864
857 // if (IsPhysical && Body == (IntPtr) 0) 865 // if (IsPhysical && Body == (IntPtr) 0)
858 // { 866 // {
859 // Recreate the body 867 // Recreate the body