aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorDahlia Trimble2008-08-27 06:29:34 +0000
committerDahlia Trimble2008-08-27 06:29:34 +0000
commitfce83731ad7a017020864c28eb6c07f9604fa5a7 (patch)
tree0b366cd33cb3404bd19ae0d8f33122ec2c405c41 /OpenSim
parentMantis#1518. Thank you kindly, Zaki for a patch that: (diff)
downloadopensim-SC_OLD-fce83731ad7a017020864c28eb6c07f9604fa5a7.zip
opensim-SC_OLD-fce83731ad7a017020864c28eb6c07f9604fa5a7.tar.gz
opensim-SC_OLD-fce83731ad7a017020864c28eb6c07f9604fa5a7.tar.bz2
opensim-SC_OLD-fce83731ad7a017020864c28eb6c07f9604fa5a7.tar.xz
Modified Mesh object to allow alternative mesher interfacing
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Physics/Meshing/Mesh.cs74
1 files changed, 59 insertions, 15 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs
index be2a019..3f82bc9 100644
--- a/OpenSim/Region/Physics/Meshing/Mesh.cs
+++ b/OpenSim/Region/Physics/Meshing/Mesh.cs
@@ -39,6 +39,7 @@ namespace OpenSim.Region.Physics.Meshing
39 public List<Triangle> triangles; 39 public List<Triangle> triangles;
40 GCHandle pinnedVirtexes; 40 GCHandle pinnedVirtexes;
41 GCHandle pinnedIndex; 41 GCHandle pinnedIndex;
42 public PrimMesh primMesh = null;
42 //public float[] normals; 43 //public float[] normals;
43 44
44 public Mesh() 45 public Mesh()
@@ -155,29 +156,69 @@ namespace OpenSim.Region.Physics.Meshing
155 156
156 public float[] getVertexListAsFloatLocked() 157 public float[] getVertexListAsFloatLocked()
157 { 158 {
158 float[] result = new float[vertices.Count*3]; 159 float[] result;
159 for (int i = 0; i < vertices.Count; i++) 160
161 if (primMesh == null)
160 { 162 {
161 Vertex v = vertices[i]; 163 result = new float[vertices.Count * 3];
162 if (v == null) 164 for (int i = 0; i < vertices.Count; i++)
163 continue; 165 {
164 result[3*i + 0] = v.X; 166 Vertex v = vertices[i];
165 result[3*i + 1] = v.Y; 167 if (v == null)
166 result[3*i + 2] = v.Z; 168 continue;
169 result[3 * i + 0] = v.X;
170 result[3 * i + 1] = v.Y;
171 result[3 * i + 2] = v.Z;
172 }
173 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
174 }
175 else
176 {
177 int count = primMesh.coords.Count;
178 result = new float[count * 3];
179 for (int i = 0; i < count; i++)
180 {
181 Coord c = primMesh.coords[i];
182 int resultIndex = 3 * i;
183 result[resultIndex++] = c.X;
184 result[resultIndex++] = c.Y;
185 result[resultIndex] = c.Z;
186
187 }
188 primMesh.coords = null;
189 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
167 } 190 }
168 pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned);
169 return result; 191 return result;
170 } 192 }
171 193
172 public int[] getIndexListAsInt() 194 public int[] getIndexListAsInt()
173 { 195 {
174 int[] result = new int[triangles.Count*3]; 196 int[] result;
175 for (int i = 0; i < triangles.Count; i++) 197
198 if (primMesh == null)
176 { 199 {
177 Triangle t = triangles[i]; 200 result = new int[triangles.Count * 3];
178 result[3*i + 0] = vertices.IndexOf(t.v1); 201 for (int i = 0; i < triangles.Count; i++)
179 result[3*i + 1] = vertices.IndexOf(t.v2); 202 {
180 result[3*i + 2] = vertices.IndexOf(t.v3); 203 Triangle t = triangles[i];
204 result[3 * i + 0] = vertices.IndexOf(t.v1);
205 result[3 * i + 1] = vertices.IndexOf(t.v2);
206 result[3 * i + 2] = vertices.IndexOf(t.v3);
207 }
208 }
209 else
210 {
211 int numFaces = primMesh.faces.Count;
212 result = new int[numFaces * 3];
213 for (int i = 0; i < numFaces; i++)
214 {
215 Face f = primMesh.faces[i];
216 int resultIndex = i * 3;
217 result[resultIndex++] = f.v1;
218 result[resultIndex++] = f.v2;
219 result[resultIndex] = f.v3;
220 }
221 primMesh.faces = null;
181 } 222 }
182 return result; 223 return result;
183 } 224 }
@@ -186,6 +227,9 @@ namespace OpenSim.Region.Physics.Meshing
186 { 227 {
187 int[] result = getIndexListAsInt(); 228 int[] result = getIndexListAsInt();
188 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); 229 pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned);
230 //triangles = null;
231 //vertices = null;
232 //primMesh = null;
189 return result; 233 return result;
190 } 234 }
191 235