From 35ad484b6b2d0e47d16eaf3e846b4982e86fe050 Mon Sep 17 00:00:00 2001 From: Dahlia Trimble Date: Fri, 29 Aug 2008 08:19:47 +0000 Subject: fixed some ugliness in the conversion from the new mesher format to the old that should speed up region startup a little and maybe even use less memory if the GC decides to play friendly with the other kids. --- OpenSim/Region/Physics/Meshing/Mesh.cs | 22 +++++++++------ OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 40 +++++++++++++++++++-------- 2 files changed, 42 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index 4630d98..16ac453 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -179,13 +179,14 @@ namespace OpenSim.Region.Physics.Meshing for (int i = 0; i < count; i++) { Coord c = primMesh.coords[i]; - int resultIndex = 3 * i; - result[resultIndex++] = c.X; - result[resultIndex++] = c.Y; - result[resultIndex] = c.Z; + { + int resultIndex = 3 * i; + result[resultIndex] = c.X; + result[resultIndex + 1] = c.Y; + result[resultIndex + 2] = c.Z; + } } - //primMesh.coords = null; pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned); } return result; @@ -213,12 +214,15 @@ namespace OpenSim.Region.Physics.Meshing for (int i = 0; i < numFaces; i++) { Face f = primMesh.faces[i]; + Coord c1 = primMesh.coords[f.v1]; + Coord c2 = primMesh.coords[f.v2]; + Coord c3 = primMesh.coords[f.v3]; + int resultIndex = i * 3; - result[resultIndex++] = f.v1; - result[resultIndex++] = f.v2; - result[resultIndex] = f.v3; + result[resultIndex] = f.v1; + result[resultIndex + 1] = f.v2; + result[resultIndex + 2] = f.v3; } - //primMesh.faces = null; } return result; } diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 7cf8b76..ecde92a 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -1971,21 +1971,39 @@ namespace OpenSim.Region.Physics.Meshing primMesh.Scale(size.X, size.Y, size.Z); + int numCoords = primMesh.coords.Count; int numFaces = primMesh.faces.Count; + + List coords = primMesh.coords; + for (int i = 0; i < numCoords; i++) + { + Coord c = coords[i]; + mesh.vertices.Add(new Vertex(c.X, c.Y, c.Z)); + } + + List faces = primMesh.faces; + List vertices = mesh.vertices; + for (int i = 0; i < numFaces; i++) { - Face f = primMesh.faces[i]; - Coord vert = primMesh.coords[f.v1]; - Vertex v1 = new Vertex(vert.X, vert.Y, vert.Z); - mesh.vertices.Add(v1); - vert = primMesh.coords[f.v2]; - Vertex v2 = new Vertex(vert.X, vert.Y, vert.Z); - mesh.vertices.Add(v2); - vert = primMesh.coords[f.v3]; - Vertex v3 = new Vertex(vert.X, vert.Y, vert.Z); - mesh.vertices.Add(v3); - mesh.triangles.Add(new Triangle(v1, v2, v3)); + Face f = faces[i]; + mesh.triangles.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); } + + //for (int i = 0; i < numFaces; i++) + //{ + // Face f = primMesh.faces[i]; + // Coord vert = primMesh.coords[f.v1]; + // Vertex v1 = new Vertex(vert.X, vert.Y, vert.Z); + // mesh.vertices.Add(v1); + // vert = primMesh.coords[f.v2]; + // Vertex v2 = new Vertex(vert.X, vert.Y, vert.Z); + // mesh.vertices.Add(v2); + // vert = primMesh.coords[f.v3]; + // Vertex v3 = new Vertex(vert.X, vert.Y, vert.Z); + // mesh.vertices.Add(v3); + // mesh.triangles.Add(new Triangle(v1, v2, v3)); + //} //mesh.DumpRaw(baseDir, primName, "Mesh"); -- cgit v1.1