Trim out nulls from mesh vertex and triangle lists to try and save more memory

0.6.0-stable
Dahlia Trimble 2008-07-11 20:32:58 +00:00
parent da68f18a6b
commit b42770bf7a
1 changed files with 22 additions and 6 deletions

View File

@ -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;
}