diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 55a1bec2b7..df850a0d1f 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -1858,7 +1858,6 @@ namespace OpenSim.Region.Physics.Meshing Console.WriteLine("skew: " + skew.ToString() + " profileXComp: " + profileXComp.ToString()); #endif - foreach (Vertex v in m.vertices) if (v != null) { @@ -2173,14 +2172,31 @@ namespace OpenSim.Region.Physics.Meshing // } //} - if (mesh != null && size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh) - { + if (mesh != null) + if (size.X < minSizeForComplexMesh && size.Y < minSizeForComplexMesh && size.Z < minSizeForComplexMesh) + { #if SPAM Console.WriteLine("Meshmerizer: prim " + primName + " has a size of " + size.ToString() + " which is below threshold of " + minSizeForComplexMesh.ToString() + " - creating simple bounding box" ); #endif - mesh = CreateBoundingBoxMesh(mesh); - mesh.DumpRaw(baseDir, primName, "Z extruded"); - } + mesh = CreateBoundingBoxMesh(mesh); + mesh.DumpRaw(baseDir, primName, "Z extruded"); + + // trim the vertex and triangle lists to free up memory + //mesh.vertices.TrimExcess(); + //mesh.triangles.TrimExcess(); + + int vertCount = 0; + foreach (Vertex v in mesh.vertices) + if (v != null) + vertCount++; + mesh.vertices.Capacity = vertCount; + + int triCount = 0; + foreach (Triangle t in mesh.triangles) + if ( t != null ) + triCount++; + mesh.triangles.Capacity = triCount; + } return mesh; }