aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Mesh.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs42
1 files changed, 18 insertions, 24 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index 2ebfa1c..9c2667e 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -26,14 +26,11 @@
26* 26*
27*/ 27*/
28 28
29
29using System; 30using System;
30using System.IO;
31using System.Collections.Generic; 31using System.Collections.Generic;
32using System.Text; 32using System.IO;
33
34using System.Runtime.InteropServices; 33using System.Runtime.InteropServices;
35
36
37using OpenSim.Region.Physics.Manager; 34using OpenSim.Region.Physics.Manager;
38 35
39namespace OpenSim.Region.Physics.Meshing 36namespace OpenSim.Region.Physics.Meshing
@@ -66,9 +63,9 @@ namespace OpenSim.Region.Physics.Meshing
66 foreach (Triangle t in triangles) 63 foreach (Triangle t in triangles)
67 { 64 {
68 int iV1, iV2, iV3; 65 int iV1, iV2, iV3;
69 iV1 = this.vertices.IndexOf(t.v1); 66 iV1 = vertices.IndexOf(t.v1);
70 iV2 = this.vertices.IndexOf(t.v2); 67 iV2 = vertices.IndexOf(t.v2);
71 iV3 = this.vertices.IndexOf(t.v3); 68 iV3 = vertices.IndexOf(t.v3);
72 69
73 Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]); 70 Triangle newT = new Triangle(result.vertices[iV1], result.vertices[iV2], result.vertices[iV3]);
74 result.Add(newT); 71 result.Add(newT);
@@ -77,8 +74,7 @@ namespace OpenSim.Region.Physics.Meshing
77 return result; 74 return result;
78 } 75 }
79 76
80 77
81
82 public void Add(Triangle triangle) 78 public void Add(Triangle triangle)
83 { 79 {
84 int i; 80 int i;
@@ -160,15 +156,15 @@ namespace OpenSim.Region.Physics.Meshing
160 156
161 public float[] getVertexListAsFloatLocked() 157 public float[] getVertexListAsFloatLocked()
162 { 158 {
163 float[] result = new float[vertices.Count * 3]; 159 float[] result = new float[vertices.Count*3];
164 for (int i = 0; i < vertices.Count; i++) 160 for (int i = 0; i < vertices.Count; i++)
165 { 161 {
166 Vertex v = vertices[i]; 162 Vertex v = vertices[i];
167 if (v == null) 163 if (v == null)
168 continue; 164 continue;
169 result[3 * i + 0] = v.X; 165 result[3*i + 0] = v.X;
170 result[3 * i + 1] = v.Y; 166 result[3*i + 1] = v.Y;
171 result[3 * i + 2] = v.Z; 167 result[3*i + 2] = v.Z;
172 } 168 }
173 GCHandle.Alloc(result, GCHandleType.Pinned); 169 GCHandle.Alloc(result, GCHandleType.Pinned);
174 return result; 170 return result;
@@ -176,13 +172,13 @@ namespace OpenSim.Region.Physics.Meshing
176 172
177 public int[] getIndexListAsInt() 173 public int[] getIndexListAsInt()
178 { 174 {
179 int[] result = new int[triangles.Count * 3]; 175 int[] result = new int[triangles.Count*3];
180 for (int i = 0; i < triangles.Count; i++) 176 for (int i = 0; i < triangles.Count; i++)
181 { 177 {
182 Triangle t = triangles[i]; 178 Triangle t = triangles[i];
183 result[3 * i + 0] = vertices.IndexOf(t.v1); 179 result[3*i + 0] = vertices.IndexOf(t.v1);
184 result[3 * i + 1] = vertices.IndexOf(t.v2); 180 result[3*i + 1] = vertices.IndexOf(t.v2);
185 result[3 * i + 2] = vertices.IndexOf(t.v3); 181 result[3*i + 2] = vertices.IndexOf(t.v3);
186 } 182 }
187 return result; 183 return result;
188 } 184 }
@@ -202,7 +198,6 @@ namespace OpenSim.Region.Physics.Meshing
202 198
203 foreach (Triangle t in newMesh.triangles) 199 foreach (Triangle t in newMesh.triangles)
204 Add(t); 200 Add(t);
205
206 } 201 }
207 202
208 // Do a linear transformation of mesh. 203 // Do a linear transformation of mesh.
@@ -213,9 +208,9 @@ namespace OpenSim.Region.Physics.Meshing
213 if (v == null) 208 if (v == null)
214 continue; 209 continue;
215 float x, y, z; 210 float x, y, z;
216 x = v.X * matrix[0, 0] + v.Y * matrix[1, 0] + v.Z * matrix[2, 0]; 211 x = v.X*matrix[0, 0] + v.Y*matrix[1, 0] + v.Z*matrix[2, 0];
217 y = v.X * matrix[0, 1] + v.Y * matrix[1, 1] + v.Z * matrix[2, 1]; 212 y = v.X*matrix[0, 1] + v.Y*matrix[1, 1] + v.Z*matrix[2, 1];
218 z = v.X * matrix[0, 2] + v.Y * matrix[1, 2] + v.Z * matrix[2, 2]; 213 z = v.X*matrix[0, 2] + v.Y*matrix[1, 2] + v.Z*matrix[2, 2];
219 v.X = x + offset[0]; 214 v.X = x + offset[0];
220 v.Y = y + offset[1]; 215 v.Y = y + offset[1];
221 v.Z = z + offset[2]; 216 v.Z = z + offset[2];
@@ -237,5 +232,4 @@ namespace OpenSim.Region.Physics.Meshing
237 sw.Close(); 232 sw.Close();
238 } 233 }
239 } 234 }
240 235} \ No newline at end of file
241}