diff options
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Extruder.cs | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index 7203aaf..3941107 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs | |||
@@ -89,7 +89,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
89 | v.X *= (size.X * taperTopFactorX); | 89 | v.X *= (size.X * taperTopFactorX); |
90 | v.Y *= (size.Y * taperTopFactorY); | 90 | v.Y *= (size.Y * taperTopFactorY); |
91 | v.Z *= size.Z; | 91 | v.Z *= size.Z; |
92 | 92 | ||
93 | //Push the top of the object over by the Top Shear amount | 93 | //Push the top of the object over by the Top Shear amount |
94 | v.X += pushX * size.X; | 94 | v.X += pushX * size.X; |
95 | v.Y += pushY * size.Y; | 95 | v.Y += pushY * size.Y; |
@@ -165,7 +165,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
165 | 165 | ||
166 | for (int i = 0; i < workingMiddle.vertices.Count; i++) | 166 | for (int i = 0; i < workingMiddle.vertices.Count; i++) |
167 | { | 167 | { |
168 | int iNext = (i + 1); | 168 | int iNext = i + 1; |
169 | 169 | ||
170 | if (workingMiddle.vertices[i] == null) // Can't make a simplex here | 170 | if (workingMiddle.vertices[i] == null) // Can't make a simplex here |
171 | { | 171 | { |
@@ -200,7 +200,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
200 | iLastNull = 0; | 200 | iLastNull = 0; |
201 | for (int i = 0; i < workingPlus.vertices.Count; i++) | 201 | for (int i = 0; i < workingPlus.vertices.Count; i++) |
202 | { | 202 | { |
203 | int iNext = (i + 1); | 203 | int iNext = i + 1; |
204 | 204 | ||
205 | if (workingPlus.vertices[i] == null) // Can't make a simplex here | 205 | if (workingPlus.vertices[i] == null) // Can't make a simplex here |
206 | { | 206 | { |
@@ -261,7 +261,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
261 | 261 | ||
262 | float twistTotal = twistTop - twistBot; | 262 | float twistTotal = twistTop - twistBot; |
263 | // if the profile has a lot of twist, add more layers otherwise the layers may overlap | 263 | // if the profile has a lot of twist, add more layers otherwise the layers may overlap |
264 | // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesnt | 264 | // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesn't |
265 | // accurately match the viewer | 265 | // accurately match the viewer |
266 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5f) steps *= 2; | 266 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5f) steps *= 2; |
267 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0f) steps *= 2; | 267 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0f) steps *= 2; |
@@ -291,7 +291,6 @@ namespace OpenSim.Region.Physics.Meshing | |||
291 | + " taperTopFactorX: " + taperTopFactorX.ToString() + " taperTopFactorY: " + taperTopFactorY.ToString()); | 291 | + " taperTopFactorX: " + taperTopFactorX.ToString() + " taperTopFactorY: " + taperTopFactorY.ToString()); |
292 | System.Console.WriteLine("Extruder: PathScaleX: " + pathScaleX.ToString() + " pathScaleY: " + pathScaleY.ToString()); | 292 | System.Console.WriteLine("Extruder: PathScaleX: " + pathScaleX.ToString() + " pathScaleY: " + pathScaleY.ToString()); |
293 | #endif | 293 | #endif |
294 | |||
295 | 294 | ||
296 | bool done = false; | 295 | bool done = false; |
297 | do // loop through the length of the path and add the layers | 296 | do // loop through the length of the path and add the layers |
@@ -319,12 +318,16 @@ namespace OpenSim.Region.Physics.Meshing | |||
319 | 318 | ||
320 | // apply the taper to the profile before any rotations | 319 | // apply the taper to the profile before any rotations |
321 | if (xProfileScale != 1.0f || yProfileScale != 1.0f) | 320 | if (xProfileScale != 1.0f || yProfileScale != 1.0f) |
321 | { | ||
322 | foreach (Vertex v in newLayer.vertices) | 322 | foreach (Vertex v in newLayer.vertices) |
323 | if ( v != null ) | 323 | { |
324 | if (v != null) | ||
324 | { | 325 | { |
325 | v.X *= xProfileScale; | 326 | v.X *= xProfileScale; |
326 | v.Y *= yProfileScale; | 327 | v.Y *= yProfileScale; |
327 | } | 328 | } |
329 | } | ||
330 | } | ||
328 | 331 | ||
329 | float radiusScale; | 332 | float radiusScale; |
330 | 333 | ||
@@ -332,8 +335,8 @@ namespace OpenSim.Region.Physics.Meshing | |||
332 | radiusScale = 1.0f - radius * percentOfPath; | 335 | radiusScale = 1.0f - radius * percentOfPath; |
333 | else if (radius < 0.001f) | 336 | else if (radius < 0.001f) |
334 | radiusScale = 1.0f + radius * (1.0f - percentOfPath); | 337 | radiusScale = 1.0f + radius * (1.0f - percentOfPath); |
335 | else radiusScale = 1.0f; | 338 | else |
336 | 339 | radiusScale = 1.0f; | |
337 | 340 | ||
338 | #if SPAM | 341 | #if SPAM |
339 | System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() | 342 | System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() |
@@ -379,10 +382,12 @@ namespace OpenSim.Region.Physics.Meshing | |||
379 | } | 382 | } |
380 | 383 | ||
381 | if (angle == startAngle) // the first layer, invert normals | 384 | if (angle == startAngle) // the first layer, invert normals |
385 | { | ||
382 | foreach (Triangle t in newLayer.triangles) | 386 | foreach (Triangle t in newLayer.triangles) |
383 | { | 387 | { |
384 | t.invertNormal(); | 388 | t.invertNormal(); |
385 | } | 389 | } |
390 | } | ||
386 | 391 | ||
387 | result.Append(newLayer); | 392 | result.Append(newLayer); |
388 | 393 | ||
@@ -397,7 +402,9 @@ namespace OpenSim.Region.Physics.Meshing | |||
397 | int iNext = (i + 1); | 402 | int iNext = (i + 1); |
398 | 403 | ||
399 | if (lastLayer.vertices[i] == null) // cant make a simplex here | 404 | if (lastLayer.vertices[i] == null) // cant make a simplex here |
405 | { | ||
400 | iLastNull = i + 1; | 406 | iLastNull = i + 1; |
407 | } | ||
401 | else | 408 | else |
402 | { | 409 | { |
403 | if (i == count - 1) // End of list | 410 | if (i == count - 1) // End of list |
@@ -413,17 +420,17 @@ namespace OpenSim.Region.Physics.Meshing | |||
413 | } | 420 | } |
414 | lastLayer = newLayer; | 421 | lastLayer = newLayer; |
415 | 422 | ||
416 | |||
417 | // calc the angle for the next interation of the loop | 423 | // calc the angle for the next interation of the loop |
418 | if (angle >= endAngle) | 424 | if (angle >= endAngle) |
425 | { | ||
419 | done = true; | 426 | done = true; |
427 | } | ||
420 | else | 428 | else |
421 | { | 429 | { |
422 | angle = stepSize * ++step; | 430 | angle = stepSize * ++step; |
423 | if (angle > endAngle) | 431 | if (angle > endAngle) |
424 | angle = endAngle; | 432 | angle = endAngle; |
425 | } | 433 | } |
426 | |||
427 | } while (!done); // loop until all the layers in the path are completed | 434 | } while (!done); // loop until all the layers in the path are completed |
428 | 435 | ||
429 | // scale the mesh to the desired size | 436 | // scale the mesh to the desired size |