aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/PrimMesher.cs
diff options
context:
space:
mode:
authorDahlia Trimble2008-09-13 10:22:17 +0000
committerDahlia Trimble2008-09-13 10:22:17 +0000
commit8a8b01d1b83dd2b847626792c558092c553e11d5 (patch)
treeb9efc37ff4f3ce1cbeef2443bea88f9deeec1678 /OpenSim/Region/Physics/Meshing/PrimMesher.cs
parentwrap log4net configure in try block so that it will run if you don't have a (diff)
downloadopensim-SC_OLD-8a8b01d1b83dd2b847626792c558092c553e11d5.zip
opensim-SC_OLD-8a8b01d1b83dd2b847626792c558092c553e11d5.tar.gz
opensim-SC_OLD-8a8b01d1b83dd2b847626792c558092c553e11d5.tar.bz2
opensim-SC_OLD-8a8b01d1b83dd2b847626792c558092c553e11d5.tar.xz
Circular path prim meshes are now joined where the path ends meet if they match. This may have a minor improvement in memory and speed performance, but it's mainly for viewer applications and it also syncs the c# version of PrimMesher with my python sandbox version.
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs157
1 files changed, 90 insertions, 67 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index c495d71..0e6cbad 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -336,7 +336,7 @@ angles24 = [
336 this.faces = new List<Face>(); 336 this.faces = new List<Face>();
337 } 337 }
338 338
339 public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) 339 public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool createFaces)
340 { 340 {
341 this.coords = new List<Coord>(); 341 this.coords = new List<Coord>();
342 this.faces = new List<Face>(); 342 this.faces = new List<Face>();
@@ -422,7 +422,7 @@ angles24 = [
422 hollowCoords.Add(newVert); 422 hollowCoords.Add(newVert);
423 } 423 }
424 } 424 }
425 else if (angle.angle > 0.0001f) 425 else if (createFaces && angle.angle > 0.0001f)
426 { 426 {
427 Face newFace = new Face(); 427 Face newFace = new Face();
428 newFace.v1 = 0; 428 newFace.v1 = 0;
@@ -437,77 +437,80 @@ angles24 = [
437 { 437 {
438 hollowCoords.Reverse(); 438 hollowCoords.Reverse();
439 439
440 int numOuterVerts = this.coords.Count; 440 if (createFaces)
441 int numHollowVerts = hollowCoords.Count;
442 int numTotalVerts = numOuterVerts + numHollowVerts;
443
444 if (numOuterVerts == numHollowVerts)
445 { 441 {
446 Face newFace = new Face(); 442 int numOuterVerts = this.coords.Count;
443 int numHollowVerts = hollowCoords.Count;
444 int numTotalVerts = numOuterVerts + numHollowVerts;
447 445
448 for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++) 446 if (numOuterVerts == numHollowVerts)
449 {
450 newFace.v1 = coordIndex;
451 newFace.v2 = coordIndex + 1;
452 newFace.v3 = numTotalVerts - coordIndex - 1;
453 this.faces.Add(newFace);
454
455 newFace.v1 = coordIndex + 1;
456 newFace.v2 = numTotalVerts - coordIndex - 2;
457 newFace.v3 = numTotalVerts - coordIndex - 1;
458 this.faces.Add(newFace);
459 }
460 }
461 else
462 {
463 if (numOuterVerts < numHollowVerts)
464 { 447 {
465 Face newFace = new Face(); 448 Face newFace = new Face();
466 int j = 0; // j is the index for outer vertices
467 int maxJ = numOuterVerts - 1;
468 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
469 {
470 if (j < maxJ)
471 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle)
472 {
473 newFace.v1 = numTotalVerts - i - 1;
474 newFace.v2 = j;
475 newFace.v3 = j + 1;
476
477 this.faces.Add(newFace);
478 j += 1;
479 }
480 449
481 newFace.v1 = j; 450 for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
482 newFace.v2 = numTotalVerts - i - 2; 451 {
483 newFace.v3 = numTotalVerts - i - 1; 452 newFace.v1 = coordIndex;
453 newFace.v2 = coordIndex + 1;
454 newFace.v3 = numTotalVerts - coordIndex - 1;
455 this.faces.Add(newFace);
484 456
457 newFace.v1 = coordIndex + 1;
458 newFace.v2 = numTotalVerts - coordIndex - 2;
459 newFace.v3 = numTotalVerts - coordIndex - 1;
485 this.faces.Add(newFace); 460 this.faces.Add(newFace);
486 } 461 }
487 } 462 }
488 else // numHollowVerts < numOuterVerts 463 else
489 { 464 {
490 Face newFace = new Face(); 465 if (numOuterVerts < numHollowVerts)
491 int j = 0; // j is the index for inner vertices
492 int maxJ = numHollowVerts - 1;
493 for (int i = 0; i < numOuterVerts; i++)
494 { 466 {
495 if (j < maxJ) 467 Face newFace = new Face();
496 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle) 468 int j = 0; // j is the index for outer vertices
497 { 469 int maxJ = numOuterVerts - 1;
498 newFace.v1 = i; 470 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
499 newFace.v2 = numTotalVerts - j - 2; 471 {
500 newFace.v3 = numTotalVerts - j - 1; 472 if (j < maxJ)
501 473 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle)
502 this.faces.Add(newFace); 474 {
503 j += 1; 475 newFace.v1 = numTotalVerts - i - 1;
504 } 476 newFace.v2 = j;
505 477 newFace.v3 = j + 1;
506 newFace.v1 = numTotalVerts - j - 1; 478
507 newFace.v2 = i; 479 this.faces.Add(newFace);
508 newFace.v3 = i + 1; 480 j += 1;
509 481 }
510 this.faces.Add(newFace); 482
483 newFace.v1 = j;
484 newFace.v2 = numTotalVerts - i - 2;
485 newFace.v3 = numTotalVerts - i - 1;
486
487 this.faces.Add(newFace);
488 }
489 }
490 else // numHollowVerts < numOuterVerts
491 {
492 Face newFace = new Face();
493 int j = 0; // j is the index for inner vertices
494 int maxJ = numHollowVerts - 1;
495 for (int i = 0; i < numOuterVerts; i++)
496 {
497 if (j < maxJ)
498 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle)
499 {
500 newFace.v1 = i;
501 newFace.v2 = numTotalVerts - j - 2;
502 newFace.v3 = numTotalVerts - j - 1;
503
504 this.faces.Add(newFace);
505 j += 1;
506 }
507
508 newFace.v1 = numTotalVerts - j - 1;
509 newFace.v2 = i;
510 newFace.v3 = i + 1;
511
512 this.faces.Add(newFace);
513 }
511 } 514 }
512 } 515 }
513 } 516 }
@@ -518,10 +521,16 @@ angles24 = [
518 521
519 public Profile Clone() 522 public Profile Clone()
520 { 523 {
524 return this.Clone(true);
525 }
526
527 public Profile Clone(bool needFaces)
528 {
521 Profile clone = new Profile(); 529 Profile clone = new Profile();
522 530
523 clone.coords.AddRange(this.coords); 531 clone.coords.AddRange(this.coords);
524 clone.faces.AddRange(this.faces); 532 if (needFaces)
533 clone.faces.AddRange(this.faces);
525 534
526 return clone; 535 return clone;
527 } 536 }
@@ -781,7 +790,7 @@ angles24 = [
781 hollow *= 0.707f; 790 hollow *= 0.707f;
782 } 791 }
783 792
784 Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); 793 Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true);
785 794
786 if (initialProfileRot != 0.0f) 795 if (initialProfileRot != 0.0f)
787 profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); 796 profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot));
@@ -948,7 +957,17 @@ angles24 = [
948 } 957 }
949 } 958 }
950 959
951 Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides); 960 bool needEndFaces = false;
961 if (this.pathCutBegin != 0.0 || this.pathCutEnd != 1.0)
962 needEndFaces = true;
963 else if (this.taperX != 0.0 || this.taperY != 0.0)
964 needEndFaces = true;
965 else if (this.skew != 0.0)
966 needEndFaces = true;
967 else if (twistTotal != 0.0)
968 needEndFaces = true;
969
970 Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces);
952 971
953 if (initialProfileRot != 0.0f) 972 if (initialProfileRot != 0.0f)
954 profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot)); 973 profile.AddRot(Quaternion.CreateFromAxisAngle(new Vector3(0.0f, 0.0f, 1.0f), initialProfileRot));
@@ -956,7 +975,11 @@ angles24 = [
956 bool done = false; 975 bool done = false;
957 while (!done) // loop through the length of the path and add the layers 976 while (!done) // loop through the length of the path and add the layers
958 { 977 {
959 Profile newLayer = profile.Clone(); 978 bool isEndLayer = false;
979 if (angle == startAngle || angle >= endAngle)
980 isEndLayer = true;
981
982 Profile newLayer = profile.Clone(isEndLayer && needEndFaces);
960 983
961 float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; 984 float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX;
962 float yProfileScale = this.holeSizeY; 985 float yProfileScale = this.holeSizeY;
@@ -1012,7 +1035,7 @@ angles24 = [
1012 1035
1013 this.coords.AddRange(newLayer.coords); 1036 this.coords.AddRange(newLayer.coords);
1014 1037
1015 if (angle <= startAngle || angle >= endAngle) 1038 if (isEndLayer)
1016 this.faces.AddRange(newLayer.faces); 1039 this.faces.AddRange(newLayer.faces);
1017 1040
1018 // fill faces between layers 1041 // fill faces between layers