diff options
author | Teravus Ovares | 2008-06-02 08:31:34 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-06-02 08:31:34 +0000 |
commit | 832d609b44c2461752b0a130bddeb2e21579f6ad (patch) | |
tree | ac67751a2b2a38924255afe595835ec5c3a972f1 /OpenSim/Region/Physics/Meshing/Extruder.cs | |
parent | * While I couldn't reproduce it, I was able to see how it *might* happen, so ... (diff) | |
download | opensim-SC_OLD-832d609b44c2461752b0a130bddeb2e21579f6ad.zip opensim-SC_OLD-832d609b44c2461752b0a130bddeb2e21579f6ad.tar.gz opensim-SC_OLD-832d609b44c2461752b0a130bddeb2e21579f6ad.tar.bz2 opensim-SC_OLD-832d609b44c2461752b0a130bddeb2e21579f6ad.tar.xz |
PATCH : 0001431: corrections to torus physical mesh for default hollow shape and taper orientation along path.
--------- From Dahlia! Thanks Dahlia!!!
the attached patch reinstates the default hollow shape of the physics mesh of the torus prim type and corrects the orientation of the effects of taper on the profile along the path.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/Extruder.cs | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Extruder.cs b/OpenSim/Region/Physics/Meshing/Extruder.cs index 54ef4ce..7203aaf 100644 --- a/OpenSim/Region/Physics/Meshing/Extruder.cs +++ b/OpenSim/Region/Physics/Meshing/Extruder.cs | |||
@@ -260,8 +260,11 @@ namespace OpenSim.Region.Physics.Meshing | |||
260 | int steps = 24; | 260 | int steps = 24; |
261 | 261 | ||
262 | float twistTotal = twistTop - twistBot; | 262 | float twistTotal = twistTop - twistBot; |
263 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 1.5) steps *= 2; | 263 | // if the profile has a lot of twist, add more layers otherwise the layers may overlap |
264 | if (System.Math.Abs(twistTotal) > (float)System.Math.PI * 3.0) steps *= 2; | 264 | // and the resulting mesh may be quite inaccurate. This method is arbitrary and doesnt |
265 | // accurately match the viewer | ||
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; | ||
265 | 268 | ||
266 | double percentOfPathMultiplier = 1.0 / steps; | 269 | double percentOfPathMultiplier = 1.0 / steps; |
267 | double angleStepMultiplier = System.Math.PI * 2.0 / steps; | 270 | double angleStepMultiplier = System.Math.PI * 2.0 / steps; |
@@ -271,10 +274,10 @@ namespace OpenSim.Region.Physics.Meshing | |||
271 | float totalSkew = skew * 2.0f * pathLength; | 274 | float totalSkew = skew * 2.0f * pathLength; |
272 | float skewStart = (-skew) + pathCutBegin * 2.0f * skew; | 275 | float skewStart = (-skew) + pathCutBegin * 2.0f * skew; |
273 | 276 | ||
274 | |||
275 | float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions); | 277 | float startAngle = (float)(System.Math.PI * 2.0 * pathCutBegin * revolutions); |
276 | float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions); | 278 | float endAngle = (float)(System.Math.PI * 2.0 * pathCutEnd * revolutions); |
277 | float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution | 279 | float stepSize = (float)0.2617993878; // 2*PI / 24 segments per revolution |
280 | |||
278 | step = (int)(startAngle / stepSize); | 281 | step = (int)(startAngle / stepSize); |
279 | float angle = startAngle; | 282 | float angle = startAngle; |
280 | 283 | ||
@@ -291,11 +294,11 @@ namespace OpenSim.Region.Physics.Meshing | |||
291 | 294 | ||
292 | 295 | ||
293 | bool done = false; | 296 | bool done = false; |
294 | do | 297 | do // loop through the length of the path and add the layers |
295 | { | 298 | { |
296 | float percentOfPath = 1.0f; | 299 | newLayer = m.Clone(); |
297 | 300 | ||
298 | percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle | 301 | float percentOfPath = (angle - startAngle) / (endAngle - startAngle); // endAngle should always be larger than startAngle |
299 | 302 | ||
300 | if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero | 303 | if (pathTaperX > 0.001f) // can't really compare to 0.0f as the value passed is never exactly zero |
301 | xProfileScale = 1.0f - percentOfPath * pathTaperX; | 304 | xProfileScale = 1.0f - percentOfPath * pathTaperX; |
@@ -309,6 +312,20 @@ namespace OpenSim.Region.Physics.Meshing | |||
309 | yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY; | 312 | yProfileScale = 1.0f + (1.0f - percentOfPath) * pathTaperY; |
310 | else yProfileScale = 1.0f; | 313 | else yProfileScale = 1.0f; |
311 | 314 | ||
315 | #if SPAM | ||
316 | //System.Console.WriteLine("xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString()); | ||
317 | #endif | ||
318 | Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f); | ||
319 | |||
320 | // apply the taper to the profile before any rotations | ||
321 | if (xProfileScale != 1.0f || yProfileScale != 1.0f) | ||
322 | foreach (Vertex v in newLayer.vertices) | ||
323 | if ( v != null ) | ||
324 | { | ||
325 | v.X *= xProfileScale; | ||
326 | v.Y *= yProfileScale; | ||
327 | } | ||
328 | |||
312 | float radiusScale; | 329 | float radiusScale; |
313 | 330 | ||
314 | if (radius > 0.001f) | 331 | if (radius > 0.001f) |
@@ -317,11 +334,11 @@ namespace OpenSim.Region.Physics.Meshing | |||
317 | radiusScale = 1.0f + radius * (1.0f - percentOfPath); | 334 | radiusScale = 1.0f + radius * (1.0f - percentOfPath); |
318 | else radiusScale = 1.0f; | 335 | else radiusScale = 1.0f; |
319 | 336 | ||
320 | //radiusScale = 1.0f; | ||
321 | 337 | ||
322 | #if SPAM | 338 | #if SPAM |
323 | System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() | 339 | System.Console.WriteLine("Extruder: angle: " + angle.ToString() + " percentOfPath: " + percentOfPath.ToString() |
324 | + " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString()); | 340 | + " radius: " + radius.ToString() + " radiusScale: " + radiusScale.ToString() |
341 | + " xProfileScale: " + xProfileScale.ToString() + " yProfileScale: " + yProfileScale.ToString()); | ||
325 | #endif | 342 | #endif |
326 | 343 | ||
327 | float twist = twistBot + (twistTotal * (float)percentOfPath); | 344 | float twist = twistBot + (twistTotal * (float)percentOfPath); |
@@ -330,10 +347,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
330 | float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale; | 347 | float yOffset = (float)(System.Math.Cos(angle) * (0.5f - yPathScale)) * radiusScale; |
331 | float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath); | 348 | float xOffset = 0.5f * (skewStart + totalSkew * (float)percentOfPath); |
332 | 349 | ||
333 | newLayer = m.Clone(); | 350 | // next apply twist rotation to the profile |
334 | |||
335 | Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f); | ||
336 | |||
337 | if (twistTotal != 0.0f || twistBot != 0.0f) | 351 | if (twistTotal != 0.0f || twistBot != 0.0f) |
338 | { | 352 | { |
339 | Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); | 353 | Quaternion profileRot = new Quaternion(new Vertex(0.0f, 0.0f, -1.0f), twist); |
@@ -349,19 +363,22 @@ namespace OpenSim.Region.Physics.Meshing | |||
349 | } | 363 | } |
350 | } | 364 | } |
351 | 365 | ||
366 | // now orient the rotation of the profile relative to it's position on the path | ||
352 | Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle); | 367 | Quaternion layerRot = new Quaternion(new Vertex(-1.0f, 0.0f, 0.0f), (float)angle); |
353 | foreach (Vertex v in newLayer.vertices) | 368 | foreach (Vertex v in newLayer.vertices) |
354 | { | 369 | { |
355 | if (v != null) | 370 | if (v != null) |
356 | { | 371 | { |
357 | vTemp = v * layerRot; | 372 | vTemp = v * layerRot; |
358 | v.X = xProfileScale * vTemp.X + xOffset; | 373 | //v.X = xProfileScale * vTemp.X + xOffset; |
359 | v.Y = yProfileScale * vTemp.Y + yOffset; | 374 | //v.Y = yProfileScale * vTemp.Y + yOffset; |
375 | v.X = vTemp.X + xOffset; | ||
376 | v.Y = vTemp.Y + yOffset; | ||
360 | v.Z = vTemp.Z + zOffset; | 377 | v.Z = vTemp.Z + zOffset; |
361 | } | 378 | } |
362 | } | 379 | } |
363 | 380 | ||
364 | if (angle == startAngle) // last layer, invert normals | 381 | if (angle == startAngle) // the first layer, invert normals |
365 | foreach (Triangle t in newLayer.triangles) | 382 | foreach (Triangle t in newLayer.triangles) |
366 | { | 383 | { |
367 | t.invertNormal(); | 384 | t.invertNormal(); |
@@ -407,7 +424,7 @@ namespace OpenSim.Region.Physics.Meshing | |||
407 | angle = endAngle; | 424 | angle = endAngle; |
408 | } | 425 | } |
409 | 426 | ||
410 | } while (!done); | 427 | } while (!done); // loop until all the layers in the path are completed |
411 | 428 | ||
412 | // scale the mesh to the desired size | 429 | // scale the mesh to the desired size |
413 | float xScale = size.X; | 430 | float xScale = size.X; |