diff options
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Meshmerizer.cs')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index 85c526b..7b3f8f2 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs | |||
@@ -92,40 +92,40 @@ namespace OpenSim.Region.Physics.Meshing | |||
92 | private static Mesh CreateSimpleBoxMesh(float minX, float maxX, float minY, float maxY, float minZ, float maxZ) | 92 | private static Mesh CreateSimpleBoxMesh(float minX, float maxX, float minY, float maxY, float minZ, float maxZ) |
93 | { | 93 | { |
94 | Mesh box = new Mesh(); | 94 | Mesh box = new Mesh(); |
95 | 95 | List<Vertex> vertices = new List<Vertex>(); | |
96 | // bottom | 96 | // bottom |
97 | 97 | ||
98 | box.Add(new Vertex(minX, maxY, minZ)); | 98 | vertices.Add(new Vertex(minX, maxY, minZ)); |
99 | box.Add(new Vertex(maxX, maxY, minZ)); | 99 | vertices.Add(new Vertex(maxX, maxY, minZ)); |
100 | box.Add(new Vertex(maxX, minY, minZ)); | 100 | vertices.Add(new Vertex(maxX, minY, minZ)); |
101 | box.Add(new Vertex(minX, minY, minZ)); | 101 | vertices.Add(new Vertex(minX, minY, minZ)); |
102 | 102 | ||
103 | box.Add(new Triangle(box.vertices[0], box.vertices[1], box.vertices[2])); | 103 | box.Add(new Triangle(vertices[0], vertices[1], vertices[2])); |
104 | box.Add(new Triangle(box.vertices[0], box.vertices[2], box.vertices[3])); | 104 | box.Add(new Triangle(vertices[0], vertices[2], vertices[3])); |
105 | 105 | ||
106 | // top | 106 | // top |
107 | 107 | ||
108 | box.Add(new Vertex(maxX, maxY, maxZ)); | 108 | vertices.Add(new Vertex(maxX, maxY, maxZ)); |
109 | box.Add(new Vertex(minX, maxY, maxZ)); | 109 | vertices.Add(new Vertex(minX, maxY, maxZ)); |
110 | box.Add(new Vertex(minX, minY, maxZ)); | 110 | vertices.Add(new Vertex(minX, minY, maxZ)); |
111 | box.Add(new Vertex(maxX, minY, maxZ)); | 111 | vertices.Add(new Vertex(maxX, minY, maxZ)); |
112 | 112 | ||
113 | box.Add(new Triangle(box.vertices[4], box.vertices[5], box.vertices[6])); | 113 | box.Add(new Triangle(vertices[4], vertices[5], vertices[6])); |
114 | box.Add(new Triangle(box.vertices[4], box.vertices[6], box.vertices[7])); | 114 | box.Add(new Triangle(vertices[4], vertices[6], vertices[7])); |
115 | 115 | ||
116 | // sides | 116 | // sides |
117 | 117 | ||
118 | box.Add(new Triangle(box.vertices[5], box.vertices[0], box.vertices[3])); | 118 | box.Add(new Triangle(vertices[5], vertices[0], vertices[3])); |
119 | box.Add(new Triangle(box.vertices[5], box.vertices[3], box.vertices[6])); | 119 | box.Add(new Triangle(vertices[5], vertices[3], vertices[6])); |
120 | 120 | ||
121 | box.Add(new Triangle(box.vertices[1], box.vertices[0], box.vertices[5])); | 121 | box.Add(new Triangle(vertices[1], vertices[0], vertices[5])); |
122 | box.Add(new Triangle(box.vertices[1], box.vertices[5], box.vertices[4])); | 122 | box.Add(new Triangle(vertices[1], vertices[5], vertices[4])); |
123 | 123 | ||
124 | box.Add(new Triangle(box.vertices[7], box.vertices[1], box.vertices[4])); | 124 | box.Add(new Triangle(vertices[7], vertices[1], vertices[4])); |
125 | box.Add(new Triangle(box.vertices[7], box.vertices[2], box.vertices[1])); | 125 | box.Add(new Triangle(vertices[7], vertices[2], vertices[1])); |
126 | 126 | ||
127 | box.Add(new Triangle(box.vertices[3], box.vertices[2], box.vertices[7])); | 127 | box.Add(new Triangle(vertices[3], vertices[2], vertices[7])); |
128 | box.Add(new Triangle(box.vertices[3], box.vertices[7], box.vertices[6])); | 128 | box.Add(new Triangle(vertices[3], vertices[7], vertices[6])); |
129 | 129 | ||
130 | return box; | 130 | return box; |
131 | } | 131 | } |
@@ -145,7 +145,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
145 | float minZ = float.MaxValue; | 145 | float minZ = float.MaxValue; |
146 | float maxZ = float.MinValue; | 146 | float maxZ = float.MinValue; |
147 | 147 | ||
148 | foreach (Vertex v in meshIn.vertices) | 148 | foreach (Vertex v in meshIn.getVertexList()) |
149 | { | 149 | { |
150 | if (v != null) | 150 | if (v != null) |
151 | { | 151 | { |
@@ -394,17 +394,19 @@ namespace OpenSim.Region.Physics.Meshing | |||
394 | int numCoords = coords.Count; | 394 | int numCoords = coords.Count; |
395 | int numFaces = faces.Count; | 395 | int numFaces = faces.Count; |
396 | 396 | ||
397 | // Create the list of vertices | ||
398 | List<Vertex> vertices = new List<Vertex>(); | ||
397 | for (int i = 0; i < numCoords; i++) | 399 | for (int i = 0; i < numCoords; i++) |
398 | { | 400 | { |
399 | Coord c = coords[i]; | 401 | Coord c = coords[i]; |
400 | mesh.vertices.Add(new Vertex(c.X, c.Y, c.Z)); | 402 | vertices.Add(new Vertex(c.X, c.Y, c.Z)); |
401 | } | 403 | } |
402 | 404 | ||
403 | List<Vertex> vertices = mesh.vertices; | 405 | // Add the corresponding triangles to the mesh |
404 | for (int i = 0; i < numFaces; i++) | 406 | for (int i = 0; i < numFaces; i++) |
405 | { | 407 | { |
406 | Face f = faces[i]; | 408 | Face f = faces[i]; |
407 | mesh.triangles.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); | 409 | mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); |
408 | } | 410 | } |
409 | 411 | ||
410 | return mesh; | 412 | return mesh; |
@@ -438,8 +440,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
438 | } | 440 | } |
439 | 441 | ||
440 | // trim the vertex and triangle lists to free up memory | 442 | // trim the vertex and triangle lists to free up memory |
441 | mesh.vertices.TrimExcess(); | 443 | mesh.TrimExcess(); |
442 | mesh.triangles.TrimExcess(); | ||
443 | } | 444 | } |
444 | 445 | ||
445 | return mesh; | 446 | return mesh; |