aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs9
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs28
-rw-r--r--OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs407
3 files changed, 234 insertions, 210 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
index e5c2432..5b1510f 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Mesh.cs
@@ -234,9 +234,12 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
234 triangle.v3.Y = (float)Math.Round(triangle.v3.Y, 6); 234 triangle.v3.Y = (float)Math.Round(triangle.v3.Y, 6);
235 triangle.v3.Z = (float)Math.Round(triangle.v3.Z, 6); 235 triangle.v3.Z = (float)Math.Round(triangle.v3.Z, 6);
236 236
237 if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z == triangle.v2.Z) 237 if ((triangle.v1.X == triangle.v2.X && triangle.v1.Y == triangle.v2.Y && triangle.v1.Z ==
238 || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z == triangle.v3.Z) 238 triangle.v2.Z)
239 || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z == triangle.v3.Z) 239 || (triangle.v1.X == triangle.v3.X && triangle.v1.Y == triangle.v3.Y && triangle.v1.Z ==
240 triangle.v3.Z)
241 || (triangle.v2.X == triangle.v3.X && triangle.v2.Y == triangle.v3.Y && triangle.v2.Z ==
242 triangle.v3.Z)
240 ) 243 )
241 { 244 {
242 return; 245 return;
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
index a6e303a..bcf8e2b 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/Meshmerizer.cs
@@ -121,6 +121,22 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
121 121
122 CacheExpire = TimeSpan.FromHours(fcache); 122 CacheExpire = TimeSpan.FromHours(fcache);
123 123
124 if(doMeshFileCache && cachePath != "")
125 {
126 lock (diskLock)
127 {
128 try
129 {
130 if (!Directory.Exists(cachePath))
131 Directory.CreateDirectory(cachePath);
132 }
133 catch
134 {
135 doMeshFileCache = false;
136 doCacheExpire = false;
137 }
138 }
139 }
124 } 140 }
125 } 141 }
126 142
@@ -347,8 +363,8 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
347 { 363 {
348 Face f = faces[i]; 364 Face f = faces[i];
349 mesh.Add(new Triangle(coords[f.v1].X, coords[f.v1].Y, coords[f.v1].Z, 365 mesh.Add(new Triangle(coords[f.v1].X, coords[f.v1].Y, coords[f.v1].Z,
350 coords[f.v2].X, coords[f.v2].Y, coords[f.v2].Z, 366 coords[f.v2].X, coords[f.v2].Y, coords[f.v2].Z,
351 coords[f.v3].X, coords[f.v3].Y, coords[f.v3].Z)); 367 coords[f.v3].X, coords[f.v3].Y, coords[f.v3].Z));
352 } 368 }
353 369
354 coords.Clear(); 370 coords.Clear();
@@ -972,6 +988,14 @@ namespace OpenSim.Region.PhysicsModule.ubODEMeshing
972 primMesh.taperX = primShape.PathTaperX * 0.01f; 988 primMesh.taperX = primShape.PathTaperX * 0.01f;
973 primMesh.taperY = primShape.PathTaperY * 0.01f; 989 primMesh.taperY = primShape.PathTaperY * 0.01f;
974 990
991 if(profshape == (byte)ProfileShape.HalfCircle)
992 {
993 if(primMesh.holeSizeY < 0.01f)
994 primMesh.holeSizeY = 0.01f;
995 else if(primMesh.holeSizeY > 1.0f)
996 primMesh.holeSizeY = 1.0f;
997 }
998
975#if SPAM 999#if SPAM
976 m_log.Debug("****** PrimMesh Parameters (Circular) ******\n" + primMesh.ParamsToDisplayString()); 1000 m_log.Debug("****** PrimMesh Parameters (Circular) ******\n" + primMesh.ParamsToDisplayString());
977#endif 1001#endif
diff --git a/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs b/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
index 9c081b9..2f97caf 100644
--- a/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
+++ b/OpenSim/Region/PhysicsModules/ubOdeMeshing/PrimMesher.cs
@@ -241,7 +241,6 @@ namespace PrimMesher
241 this.v1 = v1; 241 this.v1 = v1;
242 this.v2 = v2; 242 this.v2 = v2;
243 this.v3 = v3; 243 this.v3 = v3;
244
245 } 244 }
246 245
247 public Coord SurfaceNormal(List<Coord> coordList) 246 public Coord SurfaceNormal(List<Coord> coordList)
@@ -516,16 +515,16 @@ namespace PrimMesher
516 515
517 public Profile() 516 public Profile()
518 { 517 {
519 this.coords = new List<Coord>(); 518 coords = new List<Coord>();
520 this.faces = new List<Face>(); 519 faces = new List<Face>();
521 } 520 }
522 521
523 public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool hasProfileCut, bool createFaces) 522 public Profile(int sides, float profileStart, float profileEnd, float hollow, int hollowSides, bool hasProfileCut, bool createFaces)
524 { 523 {
525 const float halfSqr2 = 0.7071067811866f; 524 const float halfSqr2 = 0.7071067811866f;
526 525
527 this.coords = new List<Coord>(); 526 coords = new List<Coord>();
528 this.faces = new List<Face>(); 527 faces = new List<Face>();
529 528
530 List<Coord> hollowCoords = new List<Coord>(); 529 List<Coord> hollowCoords = new List<Coord>();
531 530
@@ -555,7 +554,7 @@ namespace PrimMesher
555 return; 554 return;
556 } 555 }
557 556
558 this.numOuterVerts = angles.angles.Count; 557 numOuterVerts = angles.angles.Count;
559 558
560 Angle angle; 559 Angle angle;
561 Coord newVert = new Coord(); 560 Coord newVert = new Coord();
@@ -589,7 +588,7 @@ namespace PrimMesher
589 hollowCoords.Add(newVert); 588 hollowCoords.Add(newVert);
590 } 589 }
591 } 590 }
592 this.numHollowVerts = hollowAngles.angles.Count; 591 numHollowVerts = hollowAngles.angles.Count;
593 } 592 }
594 else if (!simpleFace) 593 else if (!simpleFace)
595 { 594 {
@@ -606,7 +605,7 @@ namespace PrimMesher
606 newVert.X = angle.X * xScale; 605 newVert.X = angle.X * xScale;
607 newVert.Y = angle.Y * yScale; 606 newVert.Y = angle.Y * yScale;
608 newVert.Z = 0.0f; 607 newVert.Z = 0.0f;
609 this.coords.Add(newVert); 608 coords.Add(newVert);
610 if (hollowsame) 609 if (hollowsame)
611 { 610 {
612 newVert.X *= hollow; 611 newVert.X *= hollow;
@@ -618,49 +617,49 @@ namespace PrimMesher
618 if (hasHollow) 617 if (hasHollow)
619 { 618 {
620 hollowCoords.Reverse(); 619 hollowCoords.Reverse();
621 this.coords.AddRange(hollowCoords); 620 coords.AddRange(hollowCoords);
622 621
623 if (createFaces) 622 if (createFaces)
624 { 623 {
625 int numTotalVerts = this.numOuterVerts + this.numHollowVerts; 624 int numTotalVerts = numOuterVerts + numHollowVerts;
626 625
627 if (this.numOuterVerts == this.numHollowVerts) 626 if (numOuterVerts == numHollowVerts)
628 { 627 {
629 Face newFace = new Face(); 628 Face newFace = new Face();
630 629
631 for (int coordIndex = 0; coordIndex < this.numOuterVerts - 1; coordIndex++) 630 for (int coordIndex = 0; coordIndex < numOuterVerts - 1; coordIndex++)
632 { 631 {
633 newFace.v1 = coordIndex; 632 newFace.v1 = coordIndex;
634 newFace.v2 = coordIndex + 1; 633 newFace.v2 = coordIndex + 1;
635 newFace.v3 = numTotalVerts - coordIndex - 1; 634 newFace.v3 = numTotalVerts - coordIndex - 1;
636 this.faces.Add(newFace); 635 faces.Add(newFace);
637 636
638 newFace.v1 = coordIndex + 1; 637 newFace.v1 = coordIndex + 1;
639 newFace.v2 = numTotalVerts - coordIndex - 2; 638 newFace.v2 = numTotalVerts - coordIndex - 2;
640 newFace.v3 = numTotalVerts - coordIndex - 1; 639 newFace.v3 = numTotalVerts - coordIndex - 1;
641 this.faces.Add(newFace); 640 faces.Add(newFace);
642 } 641 }
643 if (!hasProfileCut) 642 if (!hasProfileCut)
644 { 643 {
645 newFace.v1 = this.numOuterVerts - 1; 644 newFace.v1 = numOuterVerts - 1;
646 newFace.v2 = 0; 645 newFace.v2 = 0;
647 newFace.v3 = this.numOuterVerts; 646 newFace.v3 = numOuterVerts;
648 this.faces.Add(newFace); 647 faces.Add(newFace);
649 648
650 newFace.v1 = 0; 649 newFace.v1 = 0;
651 newFace.v2 = numTotalVerts - 1; 650 newFace.v2 = numTotalVerts - 1;
652 newFace.v3 = this.numOuterVerts; 651 newFace.v3 = numOuterVerts;
653 this.faces.Add(newFace); 652 faces.Add(newFace);
654 } 653 }
655 } 654 }
656 else if (this.numOuterVerts < this.numHollowVerts) 655 else if (numOuterVerts < numHollowVerts)
657 { 656 {
658 Face newFace = new Face(); 657 Face newFace = new Face();
659 int j = 0; // j is the index for outer vertices 658 int j = 0; // j is the index for outer vertices
660 int i; 659 int i;
661 int maxJ = this.numOuterVerts - 1; 660 int maxJ = numOuterVerts - 1;
662 float curHollowAngle = 0; 661 float curHollowAngle = 0;
663 for (i = 0; i < this.numHollowVerts; i++) // i is the index for inner vertices 662 for (i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
664 { 663 {
665 curHollowAngle = hollowAngles.angles[i].angle; 664 curHollowAngle = hollowAngles.angles[i].angle;
666 if (j < maxJ) 665 if (j < maxJ)
@@ -670,7 +669,7 @@ namespace PrimMesher
670 newFace.v1 = numTotalVerts - i - 1; 669 newFace.v1 = numTotalVerts - i - 1;
671 newFace.v2 = j; 670 newFace.v2 = j;
672 newFace.v3 = j + 1; 671 newFace.v3 = j + 1;
673 this.faces.Add(newFace); 672 faces.Add(newFace);
674 j++; 673 j++;
675 } 674 }
676 } 675 }
@@ -684,18 +683,18 @@ namespace PrimMesher
684 newFace.v2 = numTotalVerts - i - 2; 683 newFace.v2 = numTotalVerts - i - 2;
685 newFace.v3 = numTotalVerts - i - 1; 684 newFace.v3 = numTotalVerts - i - 1;
686 685
687 this.faces.Add(newFace); 686 faces.Add(newFace);
688 } 687 }
689 688
690 if (!hasProfileCut) 689 if (!hasProfileCut)
691 { 690 {
692 if (i == this.numHollowVerts) 691 if (i == numHollowVerts)
693 { 692 {
694 newFace.v1 = numTotalVerts - this.numHollowVerts; 693 newFace.v1 = numTotalVerts - numHollowVerts;
695 newFace.v2 = maxJ; 694 newFace.v2 = maxJ;
696 newFace.v3 = 0; 695 newFace.v3 = 0;
697 696
698 this.faces.Add(newFace); 697 faces.Add(newFace);
699 } 698 }
700 else 699 else
701 { 700 {
@@ -705,31 +704,31 @@ namespace PrimMesher
705 newFace.v2 = maxJ; 704 newFace.v2 = maxJ;
706 newFace.v3 = 0; 705 newFace.v3 = 0;
707 706
708 this.faces.Add(newFace); 707 faces.Add(newFace);
709 } 708 }
710 709
711 for (; i < this.numHollowVerts - 1; i++) 710 for (; i < numHollowVerts - 1; i++)
712 { 711 {
713 newFace.v1 = 0; 712 newFace.v1 = 0;
714 newFace.v2 = numTotalVerts - i - 2; 713 newFace.v2 = numTotalVerts - i - 2;
715 newFace.v3 = numTotalVerts - i - 1; 714 newFace.v3 = numTotalVerts - i - 1;
716 715
717 this.faces.Add(newFace); 716 faces.Add(newFace);
718 } 717 }
719 } 718 }
720 719
721 newFace.v1 = 0; 720 newFace.v1 = 0;
722 newFace.v2 = numTotalVerts - this.numHollowVerts; 721 newFace.v2 = numTotalVerts - numHollowVerts;
723 newFace.v3 = numTotalVerts - 1; 722 newFace.v3 = numTotalVerts - 1;
724 this.faces.Add(newFace); 723 faces.Add(newFace);
725 } 724 }
726 } 725 }
727 else // numHollowVerts < numOuterVerts 726 else // numHollowVerts < numOuterVerts
728 { 727 {
729 Face newFace = new Face(); 728 Face newFace = new Face();
730 int j = 0; // j is the index for inner vertices 729 int j = 0; // j is the index for inner vertices
731 int maxJ = this.numHollowVerts - 1; 730 int maxJ = numHollowVerts - 1;
732 for (int i = 0; i < this.numOuterVerts; i++) 731 for (int i = 0; i < numOuterVerts; i++)
733 { 732 {
734 if (j < maxJ) 733 if (j < maxJ)
735 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f) 734 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f)
@@ -738,7 +737,7 @@ namespace PrimMesher
738 newFace.v2 = numTotalVerts - j - 2; 737 newFace.v2 = numTotalVerts - j - 2;
739 newFace.v3 = numTotalVerts - j - 1; 738 newFace.v3 = numTotalVerts - j - 1;
740 739
741 this.faces.Add(newFace); 740 faces.Add(newFace);
742 j += 1; 741 j += 1;
743 } 742 }
744 743
@@ -746,12 +745,12 @@ namespace PrimMesher
746 newFace.v2 = i; 745 newFace.v2 = i;
747 newFace.v3 = i + 1; 746 newFace.v3 = i + 1;
748 747
749 this.faces.Add(newFace); 748 faces.Add(newFace);
750 } 749 }
751 750
752 if (!hasProfileCut) 751 if (!hasProfileCut)
753 { 752 {
754 int i = this.numOuterVerts - 1; 753 int i = numOuterVerts - 1;
755 754
756 if (hollowAngles.angles[0].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[maxJ].angle + 0.000001f) 755 if (hollowAngles.angles[0].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[maxJ].angle + 0.000001f)
757 { 756 {
@@ -759,14 +758,14 @@ namespace PrimMesher
759 newFace.v2 = numTotalVerts - maxJ - 1; 758 newFace.v2 = numTotalVerts - maxJ - 1;
760 newFace.v3 = numTotalVerts - 1; 759 newFace.v3 = numTotalVerts - 1;
761 760
762 this.faces.Add(newFace); 761 faces.Add(newFace);
763 } 762 }
764 763
765 newFace.v1 = numTotalVerts - maxJ - 1; 764 newFace.v1 = numTotalVerts - maxJ - 1;
766 newFace.v2 = i; 765 newFace.v2 = i;
767 newFace.v3 = 0; 766 newFace.v3 = 0;
768 767
769 this.faces.Add(newFace); 768 faces.Add(newFace);
770 } 769 }
771 } 770 }
772 } 771 }
@@ -778,11 +777,11 @@ namespace PrimMesher
778 if (simpleFace) 777 if (simpleFace)
779 { 778 {
780 if (sides == 3) 779 if (sides == 3)
781 this.faces.Add(new Face(0, 1, 2)); 780 faces.Add(new Face(0, 1, 2));
782 else if (sides == 4) 781 else if (sides == 4)
783 { 782 {
784 this.faces.Add(new Face(0, 1, 2)); 783 faces.Add(new Face(0, 1, 2));
785 this.faces.Add(new Face(0, 2, 3)); 784 faces.Add(new Face(0, 2, 3));
786 } 785 }
787 } 786 }
788 else 787 else
@@ -793,7 +792,7 @@ namespace PrimMesher
793 newFace.v1 = 0; 792 newFace.v1 = 0;
794 newFace.v2 = i; 793 newFace.v2 = i;
795 newFace.v3 = i + 1; 794 newFace.v3 = i + 1;
796 this.faces.Add(newFace); 795 faces.Add(newFace);
797 } 796 }
798 if (!hasProfileCut) 797 if (!hasProfileCut)
799 { 798 {
@@ -801,7 +800,7 @@ namespace PrimMesher
801 newFace.v1 = 0; 800 newFace.v1 = 0;
802 newFace.v2 = numAngles; 801 newFace.v2 = numAngles;
803 newFace.v3 = 1; 802 newFace.v3 = 1;
804 this.faces.Add(newFace); 803 faces.Add(newFace);
805 } 804 }
806 } 805 }
807 } 806 }
@@ -813,20 +812,20 @@ namespace PrimMesher
813 812
814 public Profile Copy() 813 public Profile Copy()
815 { 814 {
816 return this.Copy(true); 815 return Copy(true);
817 } 816 }
818 817
819 public Profile Copy(bool needFaces) 818 public Profile Copy(bool needFaces)
820 { 819 {
821 Profile copy = new Profile(); 820 Profile copy = new Profile();
822 821
823 copy.coords.AddRange(this.coords); 822 copy.coords.AddRange(coords);
824 823
825 if (needFaces) 824 if (needFaces)
826 copy.faces.AddRange(this.faces); 825 copy.faces.AddRange(faces);
827 826
828 copy.numOuterVerts = this.numOuterVerts; 827 copy.numOuterVerts = numOuterVerts;
829 copy.numHollowVerts = this.numHollowVerts; 828 copy.numHollowVerts = numHollowVerts;
830 829
831 return copy; 830 return copy;
832 } 831 }
@@ -839,12 +838,12 @@ namespace PrimMesher
839 public void AddPos(float x, float y, float z) 838 public void AddPos(float x, float y, float z)
840 { 839 {
841 int i; 840 int i;
842 int numVerts = this.coords.Count; 841 int numVerts = coords.Count;
843 Coord vert; 842 Coord vert;
844 843
845 for (i = 0; i < numVerts; i++) 844 for (i = 0; i < numVerts; i++)
846 { 845 {
847 vert = this.coords[i]; 846 vert = coords[i];
848 vert.X += x; 847 vert.X += x;
849 vert.Y += y; 848 vert.Y += y;
850 vert.Z += z; 849 vert.Z += z;
@@ -855,25 +854,30 @@ namespace PrimMesher
855 public void AddRot(Quat q) 854 public void AddRot(Quat q)
856 { 855 {
857 int i; 856 int i;
858 int numVerts = this.coords.Count; 857 int numVerts = coords.Count;
859 858
860 for (i = 0; i < numVerts; i++) 859 for (i = 0; i < numVerts; i++)
861 this.coords[i] *= q; 860 coords[i] *= q;
862 } 861 }
863 862
864 public void Scale(float x, float y) 863 public void Scale(float x, float y)
865 { 864 {
866 int i; 865 int i;
867 int numVerts = this.coords.Count; 866 int numVerts = coords.Count;
868 Coord vert; 867 Coord vert;
869 868
870 for (i = 0; i < numVerts; i++) 869 for (i = 0; i < numVerts; i++)
871 { 870 {
872 vert = this.coords[i]; 871 vert = coords[i];
873 vert.X *= x; 872 vert.X *= x;
873 vert.X = (float)Math.Round(vert.X,5);
874 vert.Y *= y; 874 vert.Y *= y;
875 this.coords[i] = vert; 875 vert.Y = (float)Math.Round(vert.Y,5);
876 coords[i] = vert;
876 } 877 }
878
879 if(x == 0f || y == 0f)
880 faces = new List<Face>();
877 } 881 }
878 882
879 /// <summary> 883 /// <summary>
@@ -881,33 +885,40 @@ namespace PrimMesher
881 /// </summary> 885 /// </summary>
882 public void FlipNormals() 886 public void FlipNormals()
883 { 887 {
888 int numFaces = faces.Count;
889 if(numFaces == 0)
890 return;
891
884 int i; 892 int i;
885 int numFaces = this.faces.Count;
886 Face tmpFace; 893 Face tmpFace;
887 int tmp; 894 int tmp;
888 895
889 for (i = 0; i < numFaces; i++) 896 for (i = 0; i < numFaces; i++)
890 { 897 {
891 tmpFace = this.faces[i]; 898 tmpFace = faces[i];
892 tmp = tmpFace.v3; 899 tmp = tmpFace.v3;
893 tmpFace.v3 = tmpFace.v1; 900 tmpFace.v3 = tmpFace.v1;
894 tmpFace.v1 = tmp; 901 tmpFace.v1 = tmp;
895 this.faces[i] = tmpFace; 902 faces[i] = tmpFace;
896 } 903 }
897 } 904 }
898 905
899 public void AddValue2FaceVertexIndices(int num) 906 public void AddValue2FaceVertexIndices(int num)
900 { 907 {
901 int numFaces = this.faces.Count; 908 int numFaces = faces.Count;
909 if(numFaces == 0)
910 return;
911
902 Face tmpFace; 912 Face tmpFace;
913
903 for (int i = 0; i < numFaces; i++) 914 for (int i = 0; i < numFaces; i++)
904 { 915 {
905 tmpFace = this.faces[i]; 916 tmpFace = faces[i];
906 tmpFace.v1 += num; 917 tmpFace.v1 += num;
907 tmpFace.v2 += num; 918 tmpFace.v2 += num;
908 tmpFace.v3 += num; 919 tmpFace.v3 += num;
909 920
910 this.faces[i] = tmpFace; 921 faces[i] = tmpFace;
911 } 922 }
912 } 923 }
913 924
@@ -919,11 +930,11 @@ namespace PrimMesher
919 String completePath = System.IO.Path.Combine(path, fileName); 930 String completePath = System.IO.Path.Combine(path, fileName);
920 StreamWriter sw = new StreamWriter(completePath); 931 StreamWriter sw = new StreamWriter(completePath);
921 932
922 for (int i = 0; i < this.faces.Count; i++) 933 for (int i = 0; i < faces.Count; i++)
923 { 934 {
924 string s = this.coords[this.faces[i].v1].ToString(); 935 string s = coords[faces[i].v1].ToString();
925 s += " " + this.coords[this.faces[i].v2].ToString(); 936 s += " " + coords[faces[i].v2].ToString();
926 s += " " + this.coords[this.faces[i].v3].ToString(); 937 s += " " + coords[faces[i].v3].ToString();
927 938
928 sw.WriteLine(s); 939 sw.WriteLine(s);
929 } 940 }
@@ -968,20 +979,20 @@ namespace PrimMesher
968 979
969 public void Create(PathType pathType, int steps) 980 public void Create(PathType pathType, int steps)
970 { 981 {
971 if (this.taperX > 0.999f) 982 if (taperX > .9999f)
972 this.taperX = 0.999f; 983 taperX = 1.0f;
973 if (this.taperX < -0.999f) 984 else if (taperX < -.9999f)
974 this.taperX = -0.999f; 985 taperX = -1.0f;
975 if (this.taperY > 0.999f) 986 if (taperY > .9999f)
976 this.taperY = 0.999f; 987 taperY = 1.0f;
977 if (this.taperY < -0.999f) 988 else if (taperY < -.9999f)
978 this.taperY = -0.999f; 989 taperY = -1.0f;
979 990
980 if (pathType == PathType.Linear || pathType == PathType.Flexible) 991 if (pathType == PathType.Linear || pathType == PathType.Flexible)
981 { 992 {
982 int step = 0; 993 int step = 0;
983 994
984 float length = this.pathCutEnd - this.pathCutBegin; 995 float length = pathCutEnd - pathCutBegin;
985 float twistTotal = twistEnd - twistBegin; 996 float twistTotal = twistEnd - twistBegin;
986 float twistTotalAbs = Math.Abs(twistTotal); 997 float twistTotalAbs = Math.Abs(twistTotal);
987 if (twistTotalAbs > 0.01f) 998 if (twistTotalAbs > 0.01f)
@@ -990,13 +1001,13 @@ namespace PrimMesher
990 float start = -0.5f; 1001 float start = -0.5f;
991 float stepSize = length / (float)steps; 1002 float stepSize = length / (float)steps;
992 float percentOfPathMultiplier = stepSize * 0.999999f; 1003 float percentOfPathMultiplier = stepSize * 0.999999f;
993 float xOffset = this.topShearX * this.pathCutBegin; 1004 float xOffset = topShearX * pathCutBegin;
994 float yOffset = this.topShearY * this.pathCutBegin; 1005 float yOffset = topShearY * pathCutBegin;
995 float zOffset = start; 1006 float zOffset = start;
996 float xOffsetStepIncrement = this.topShearX * length / steps; 1007 float xOffsetStepIncrement = topShearX * length / steps;
997 float yOffsetStepIncrement = this.topShearY * length / steps; 1008 float yOffsetStepIncrement = topShearY * length / steps;
998 1009
999 float percentOfPath = this.pathCutBegin; 1010 float percentOfPath = pathCutBegin;
1000 zOffset += percentOfPath; 1011 zOffset += percentOfPath;
1001 1012
1002 // sanity checks 1013 // sanity checks
@@ -1008,18 +1019,16 @@ namespace PrimMesher
1008 PathNode newNode = new PathNode(); 1019 PathNode newNode = new PathNode();
1009 1020
1010 newNode.xScale = 1.0f; 1021 newNode.xScale = 1.0f;
1011 if (this.taperX == 0.0f) 1022 if (taperX > 0.0f)
1012 newNode.xScale = 1.0f; 1023 newNode.xScale -= percentOfPath * taperX;
1013 else if (this.taperX > 0.0f) 1024 else if(taperX < 0.0f)
1014 newNode.xScale = 1.0f - percentOfPath * this.taperX; 1025 newNode.xScale += (1.0f - percentOfPath) * taperX;
1015 else newNode.xScale = 1.0f + (1.0f - percentOfPath) * this.taperX;
1016 1026
1017 newNode.yScale = 1.0f; 1027 newNode.yScale = 1.0f;
1018 if (this.taperY == 0.0f) 1028 if (taperY > 0.0f)
1019 newNode.yScale = 1.0f; 1029 newNode.yScale -= percentOfPath * taperY;
1020 else if (this.taperY > 0.0f) 1030 else if(taperY < 0.0f)
1021 newNode.yScale = 1.0f - percentOfPath * this.taperY; 1031 newNode.yScale += (1.0f - percentOfPath) * taperY;
1022 else newNode.yScale = 1.0f + (1.0f - percentOfPath) * this.taperY;
1023 1032
1024 float twist = twistBegin + twistTotal * percentOfPath; 1033 float twist = twistBegin + twistTotal * percentOfPath;
1025 1034
@@ -1036,7 +1045,7 @@ namespace PrimMesher
1036 xOffset += xOffsetStepIncrement; 1045 xOffset += xOffsetStepIncrement;
1037 yOffset += yOffsetStepIncrement; 1046 yOffset += yOffsetStepIncrement;
1038 zOffset += stepSize; 1047 zOffset += stepSize;
1039 if (percentOfPath > this.pathCutEnd) 1048 if (percentOfPath > pathCutEnd)
1040 done = true; 1049 done = true;
1041 } 1050 }
1042 else done = true; 1051 else done = true;
@@ -1059,12 +1068,12 @@ namespace PrimMesher
1059 steps *= 2; 1068 steps *= 2;
1060 } 1069 }
1061 1070
1062 float yPathScale = this.holeSizeY * 0.5f; 1071 float yPathScale = holeSizeY * 0.5f;
1063 float pathLength = this.pathCutEnd - this.pathCutBegin; 1072 float pathLength = pathCutEnd - pathCutBegin;
1064 float totalSkew = this.skew * 2.0f * pathLength; 1073 float totalSkew = skew * 2.0f * pathLength;
1065 float skewStart = this.pathCutBegin * 2.0f * this.skew - this.skew; 1074 float skewStart = pathCutBegin * 2.0f * skew - skew;
1066 float xOffsetTopShearXFactor = this.topShearX * (0.25f + 0.5f * (0.5f - this.holeSizeY)); 1075 float xOffsetTopShearXFactor = topShearX * (0.25f + 0.5f * (0.5f - holeSizeY));
1067 float yShearCompensation = 1.0f + Math.Abs(this.topShearY) * 0.25f; 1076 float yShearCompensation = 1.0f + Math.Abs(topShearY) * 0.25f;
1068 1077
1069 // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end 1078 // It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end
1070 // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used 1079 // angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used
@@ -1074,9 +1083,9 @@ namespace PrimMesher
1074 // the meshes generated with this technique appear nearly identical in shape to the same prims when 1083 // the meshes generated with this technique appear nearly identical in shape to the same prims when
1075 // displayed by the viewer. 1084 // displayed by the viewer.
1076 1085
1077 float startAngle = (twoPi * this.pathCutBegin * this.revolutions) - this.topShearY * 0.9f; 1086 float startAngle = (twoPi * pathCutBegin * revolutions) - topShearY * 0.9f;
1078 float endAngle = (twoPi * this.pathCutEnd * this.revolutions) - this.topShearY * 0.9f; 1087 float endAngle = (twoPi * pathCutEnd * revolutions) - topShearY * 0.9f;
1079 float stepSize = twoPi / this.stepsPerRevolution; 1088 float stepSize = twoPi / stepsPerRevolution;
1080 1089
1081 int step = (int)(startAngle / stepSize); 1090 int step = (int)(startAngle / stepSize);
1082 float angle = startAngle; 1091 float angle = startAngle;
@@ -1086,30 +1095,30 @@ namespace PrimMesher
1086 { 1095 {
1087 PathNode newNode = new PathNode(); 1096 PathNode newNode = new PathNode();
1088 1097
1089 float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX; 1098 float xProfileScale = (1.0f - Math.Abs(skew)) * holeSizeX;
1090 float yProfileScale = this.holeSizeY; 1099 float yProfileScale = holeSizeY;
1091 1100
1092 float percentOfPath = angle / (twoPi * this.revolutions); 1101 float percentOfPath = angle / (twoPi * revolutions);
1093 float percentOfAngles = (angle - startAngle) / (endAngle - startAngle); 1102 float percentOfAngles = (angle - startAngle) / (endAngle - startAngle);
1094 1103
1095 if (this.taperX > 0.01f) 1104 if (taperX > 0.01f)
1096 xProfileScale *= 1.0f - percentOfPath * this.taperX; 1105 xProfileScale *= 1.0f - percentOfPath * taperX;
1097 else if (this.taperX < -0.01f) 1106 else if (taperX < -0.01f)
1098 xProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperX; 1107 xProfileScale *= 1.0f + (1.0f - percentOfPath) * taperX;
1099 1108
1100 if (this.taperY > 0.01f) 1109 if (taperY > 0.01f)
1101 yProfileScale *= 1.0f - percentOfPath * this.taperY; 1110 yProfileScale *= 1.0f - percentOfPath * taperY;
1102 else if (this.taperY < -0.01f) 1111 else if (taperY < -0.01f)
1103 yProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperY; 1112 yProfileScale *= 1.0f + (1.0f - percentOfPath) * taperY;
1104 1113
1105 newNode.xScale = xProfileScale; 1114 newNode.xScale = xProfileScale;
1106 newNode.yScale = yProfileScale; 1115 newNode.yScale = yProfileScale;
1107 1116
1108 float radiusScale = 1.0f; 1117 float radiusScale = 1.0f;
1109 if (this.radius > 0.001f) 1118 if (radius > 0.001f)
1110 radiusScale = 1.0f - this.radius * percentOfPath; 1119 radiusScale = 1.0f - radius * percentOfPath;
1111 else if (this.radius < 0.001f) 1120 else if (radius < 0.001f)
1112 radiusScale = 1.0f + this.radius * (1.0f - percentOfPath); 1121 radiusScale = 1.0f + radius * (1.0f - percentOfPath);
1113 1122
1114 float twist = twistBegin + twistTotal * percentOfPath; 1123 float twist = twistBegin + twistTotal * percentOfPath;
1115 1124
@@ -1118,14 +1127,14 @@ namespace PrimMesher
1118 1127
1119 float yOffset = yShearCompensation * (float)Math.Cos(angle) * (0.5f - yPathScale) * radiusScale; 1128 float yOffset = yShearCompensation * (float)Math.Cos(angle) * (0.5f - yPathScale) * radiusScale;
1120 1129
1121 float zOffset = (float)Math.Sin(angle + this.topShearY) * (0.5f - yPathScale) * radiusScale; 1130 float zOffset = (float)Math.Sin(angle + topShearY) * (0.5f - yPathScale) * radiusScale;
1122 1131
1123 newNode.position = new Coord(xOffset, yOffset, zOffset); 1132 newNode.position = new Coord(xOffset, yOffset, zOffset);
1124 1133
1125 // now orient the rotation of the profile layer relative to it's position on the path 1134 // now orient the rotation of the profile layer relative to it's position on the path
1126 // adding taperY to the angle used to generate the quat appears to approximate the viewer 1135 // adding taperY to the angle used to generate the quat appears to approximate the viewer
1127 1136
1128 newNode.rotation = new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + this.topShearY); 1137 newNode.rotation = new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + topShearY);
1129 1138
1130 // next apply twist rotation to the profile layer 1139 // next apply twist rotation to the profile layer
1131 if (twistTotal != 0.0f || twistBegin != 0.0f) 1140 if (twistTotal != 0.0f || twistBegin != 0.0f)
@@ -1243,33 +1252,33 @@ namespace PrimMesher
1243 /// <param name="hollow"></param> 1252 /// <param name="hollow"></param>
1244 /// <param name="hollowSides"></param> 1253 /// <param name="hollowSides"></param>
1245 /// <param name="sphereMode"></param> 1254 /// <param name="sphereMode"></param>
1246 public PrimMesh(int sides, float profileStart, float profileEnd, float hollow, int hollowSides) 1255 public PrimMesh(int _sides, float _profileStart, float _profileEnd, float _hollow, int _hollowSides)
1247 { 1256 {
1248 this.coords = new List<Coord>(); 1257 coords = new List<Coord>();
1249 this.faces = new List<Face>(); 1258 faces = new List<Face>();
1250 1259
1251 this.sides = sides; 1260 sides = _sides;
1252 this.profileStart = profileStart; 1261 profileStart = _profileStart;
1253 this.profileEnd = profileEnd; 1262 profileEnd = _profileEnd;
1254 this.hollow = hollow; 1263 hollow = _hollow;
1255 this.hollowSides = hollowSides; 1264 hollowSides = _hollowSides;
1256 1265
1257 if (sides < 3) 1266 if (sides < 3)
1258 this.sides = 3; 1267 sides = 3;
1259 if (hollowSides < 3) 1268 if (hollowSides < 3)
1260 this.hollowSides = 3; 1269 hollowSides = 3;
1261 if (profileStart < 0.0f) 1270 if (profileStart < 0.0f)
1262 this.profileStart = 0.0f; 1271 profileStart = 0.0f;
1263 if (profileEnd > 1.0f) 1272 if (profileEnd > 1.0f)
1264 this.profileEnd = 1.0f; 1273 profileEnd = 1.0f;
1265 if (profileEnd < 0.02f) 1274 if (profileEnd < 0.02f)
1266 this.profileEnd = 0.02f; 1275 profileEnd = 0.02f;
1267 if (profileStart >= profileEnd) 1276 if (profileStart >= profileEnd)
1268 this.profileStart = profileEnd - 0.02f; 1277 profileStart = profileEnd - 0.02f;
1269 if (hollow > 0.99f) 1278 if (hollow > 0.99f)
1270 this.hollow = 0.99f; 1279 hollow = 0.99f;
1271 if (hollow < 0.0f) 1280 if (hollow < 0.0f)
1272 this.hollow = 0.0f; 1281 hollow = 0.0f;
1273 } 1282 }
1274 1283
1275 /// <summary> 1284 /// <summary>
@@ -1279,16 +1288,16 @@ namespace PrimMesher
1279 { 1288 {
1280 bool needEndFaces = false; 1289 bool needEndFaces = false;
1281 1290
1282 this.coords = new List<Coord>(); 1291 coords = new List<Coord>();
1283 this.faces = new List<Face>(); 1292 faces = new List<Face>();
1284 1293
1285 int steps = 1; 1294 int steps = 1;
1286 1295
1287 float length = this.pathCutEnd - this.pathCutBegin; 1296 float length = pathCutEnd - pathCutBegin;
1288 1297
1289 this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f; 1298 hasProfileCut = this.profileEnd - this.profileStart < 0.9999f;
1290 1299
1291 this.hasHollow = (this.hollow > 0.001f); 1300 hasHollow = (this.hollow > 0.001f);
1292 1301
1293 float twistBegin = this.twistBegin / 360.0f * twoPi; 1302 float twistBegin = this.twistBegin / 360.0f * twoPi;
1294 float twistEnd = this.twistEnd / 360.0f * twoPi; 1303 float twistEnd = this.twistEnd / 360.0f * twoPi;
@@ -1298,31 +1307,30 @@ namespace PrimMesher
1298 steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number 1307 steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number
1299 1308
1300 float hollow = this.hollow; 1309 float hollow = this.hollow;
1310 float initialProfileRot = 0.0f;
1301 1311
1302 if (pathType == PathType.Circular) 1312 if (pathType == PathType.Circular)
1303 { 1313 {
1304 needEndFaces = false; 1314 needEndFaces = false;
1305 if (this.pathCutBegin != 0.0f || this.pathCutEnd != 1.0f) 1315 if (pathCutBegin != 0.0f || pathCutEnd != 1.0f)
1306 needEndFaces = true; 1316 needEndFaces = true;
1307 else if (this.taperX != 0.0f || this.taperY != 0.0f) 1317 else if (taperX != 0.0f || taperY != 0.0f)
1308 needEndFaces = true; 1318 needEndFaces = true;
1309 else if (this.skew != 0.0f) 1319 else if (skew != 0.0f)
1310 needEndFaces = true; 1320 needEndFaces = true;
1311 else if (twistTotal != 0.0f) 1321 else if (twistTotal != 0.0f)
1312 needEndFaces = true; 1322 needEndFaces = true;
1313 else if (this.radius != 0.0f) 1323 else if (radius != 0.0f)
1314 needEndFaces = true; 1324 needEndFaces = true;
1315 } 1325 }
1316 else needEndFaces = true; 1326 else needEndFaces = true;
1317 1327
1318 // sanity checks
1319 float initialProfileRot = 0.0f;
1320 if (pathType == PathType.Circular) 1328 if (pathType == PathType.Circular)
1321 { 1329 {
1322 if (this.sides == 3) 1330 if (sides == 3)
1323 { 1331 {
1324 initialProfileRot = (float)Math.PI; 1332 initialProfileRot = (float)Math.PI;
1325 if (this.hollowSides == 4) 1333 if (hollowSides == 4)
1326 { 1334 {
1327 if (hollow > 0.7f) 1335 if (hollow > 0.7f)
1328 hollow = 0.7f; 1336 hollow = 0.7f;
@@ -1330,16 +1338,16 @@ namespace PrimMesher
1330 } 1338 }
1331 else hollow *= 0.5f; 1339 else hollow *= 0.5f;
1332 } 1340 }
1333 else if (this.sides == 4) 1341 else if (sides == 4)
1334 { 1342 {
1335 initialProfileRot = 0.25f * (float)Math.PI; 1343 initialProfileRot = 0.25f * (float)Math.PI;
1336 if (this.hollowSides != 4) 1344 if (hollowSides != 4)
1337 hollow *= 0.707f; 1345 hollow *= 0.707f;
1338 } 1346 }
1339 else if (this.sides > 4) 1347 else if (sides > 4)
1340 { 1348 {
1341 initialProfileRot = (float)Math.PI; 1349 initialProfileRot = (float)Math.PI;
1342 if (this.hollowSides == 4) 1350 if (hollowSides == 4)
1343 { 1351 {
1344 if (hollow > 0.7f) 1352 if (hollow > 0.7f)
1345 hollow = 0.7f; 1353 hollow = 0.7f;
@@ -1349,9 +1357,9 @@ namespace PrimMesher
1349 } 1357 }
1350 else 1358 else
1351 { 1359 {
1352 if (this.sides == 3) 1360 if (sides == 3)
1353 { 1361 {
1354 if (this.hollowSides == 4) 1362 if (hollowSides == 4)
1355 { 1363 {
1356 if (hollow > 0.7f) 1364 if (hollow > 0.7f)
1357 hollow = 0.7f; 1365 hollow = 0.7f;
@@ -1359,29 +1367,27 @@ namespace PrimMesher
1359 } 1367 }
1360 else hollow *= 0.5f; 1368 else hollow *= 0.5f;
1361 } 1369 }
1362 else if (this.sides == 4) 1370 else if (sides == 4)
1363 { 1371 {
1364 initialProfileRot = 1.25f * (float)Math.PI; 1372 initialProfileRot = 1.25f * (float)Math.PI;
1365 if (this.hollowSides != 4) 1373 if (hollowSides != 4)
1366 hollow *= 0.707f; 1374 hollow *= 0.707f;
1367 } 1375 }
1368 else if (this.sides == 24 && this.hollowSides == 4) 1376 else if (sides == 24 && hollowSides == 4)
1369 hollow *= 1.414f; 1377 hollow *= 1.414f;
1370 } 1378 }
1371 1379
1372 Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, this.hasProfileCut,true); 1380 Profile profile = new Profile(sides, profileStart, profileEnd, hollow, hollowSides,
1373 this.errorMessage = profile.errorMessage; 1381 HasProfileCut,true);
1382 errorMessage = profile.errorMessage;
1374 1383
1375 this.numPrimFaces = profile.numPrimFaces; 1384 numPrimFaces = profile.numPrimFaces;
1376 1385
1377 if (initialProfileRot != 0.0f) 1386 if (initialProfileRot != 0.0f)
1378 { 1387 {
1379 profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); 1388 profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot));
1380 } 1389 }
1381 1390
1382 float thisV = 0.0f;
1383 float lastV = 0.0f;
1384
1385 Path path = new Path(); 1391 Path path = new Path();
1386 path.twistBegin = twistBegin; 1392 path.twistBegin = twistBegin;
1387 path.twistEnd = twistEnd; 1393 path.twistEnd = twistEnd;
@@ -1402,7 +1408,7 @@ namespace PrimMesher
1402 1408
1403 path.Create(pathType, steps); 1409 path.Create(pathType, steps);
1404 1410
1405 int lastNode = path.pathNodes.Count -1; 1411 int lastNode = path.pathNodes.Count - 1;
1406 1412
1407 for (int nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++) 1413 for (int nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++)
1408 { 1414 {
@@ -1413,42 +1419,29 @@ namespace PrimMesher
1413 newLayer.AddRot(node.rotation); 1419 newLayer.AddRot(node.rotation);
1414 newLayer.AddPos(node.position); 1420 newLayer.AddPos(node.position);
1415 1421
1416 if (needEndFaces && nodeIndex == 0)
1417 {
1418 newLayer.FlipNormals();
1419 } // if (nodeIndex == 0)
1420
1421 // append this layer 1422 // append this layer
1423 int coordsStart = coords.Count;
1424 coords.AddRange(newLayer.coords);
1422 1425
1423 int coordsLen = this.coords.Count; 1426 if (needEndFaces && nodeIndex == 0 && newLayer.faces.Count > 0)
1424 newLayer.AddValue2FaceVertexIndices(coordsLen);
1425
1426 this.coords.AddRange(newLayer.coords);
1427
1428 if (needEndFaces)
1429 { 1427 {
1430 if (nodeIndex == 0) 1428 newLayer.AddValue2FaceVertexIndices(coordsStart);
1431 this.faces.AddRange(newLayer.faces); 1429 newLayer.FlipNormals();
1432 else if (nodeIndex == lastNode) 1430 faces.AddRange(newLayer.faces);
1433 {
1434 if (node.xScale > 1e-6 && node.yScale > 1e-6)
1435 this.faces.AddRange(newLayer.faces);
1436 }
1437 } 1431 }
1438 1432
1439 // fill faces between layers 1433 // fill faces between layers
1440 1434
1435 List<Face> linkfaces = new List<Face>();
1441 int numVerts = newLayer.coords.Count; 1436 int numVerts = newLayer.coords.Count;
1442 Face newFace1 = new Face(); 1437 Face newFace1 = new Face();
1443 Face newFace2 = new Face(); 1438 Face newFace2 = new Face();
1444 1439
1445 thisV = 1.0f - node.percentOfPath;
1446
1447 if (nodeIndex > 0) 1440 if (nodeIndex > 0)
1448 { 1441 {
1449 int startVert = coordsLen; 1442 int startVert = coordsStart;
1450 int endVert = this.coords.Count; 1443 int endVert = coords.Count;
1451 if (!this.hasProfileCut) 1444 if (!hasProfileCut)
1452 { 1445 {
1453 if(numVerts > 5 && !hasHollow) 1446 if(numVerts > 5 && !hasHollow)
1454 startVert++; 1447 startVert++;
@@ -1458,26 +1451,26 @@ namespace PrimMesher
1458 newFace1.v1 = i; 1451 newFace1.v1 = i;
1459 newFace1.v2 = i - numVerts; 1452 newFace1.v2 = i - numVerts;
1460 newFace1.v3 = i + 1; 1453 newFace1.v3 = i + 1;
1461 this.faces.Add(newFace1); 1454 linkfaces.Add(newFace1);
1462 1455
1463 newFace2.v1 = i + 1; 1456 newFace2.v1 = i + 1;
1464 newFace2.v2 = i - numVerts; 1457 newFace2.v2 = i - numVerts;
1465 newFace2.v3 = i + 1 - numVerts; 1458 newFace2.v3 = i + 1 - numVerts;
1466 this.faces.Add(newFace2); 1459 linkfaces.Add(newFace2);
1467 i++; 1460 i++;
1468 } 1461 }
1469 1462
1470 newFace1.v1 = i; 1463 newFace1.v1 = i;
1471 newFace1.v2 = i - numVerts; 1464 newFace1.v2 = i - numVerts;
1472 newFace1.v3 = startVert; 1465 newFace1.v3 = startVert;
1473 this.faces.Add(newFace1); 1466 linkfaces.Add(newFace1);
1474 1467
1475 newFace2.v1 = startVert; 1468 newFace2.v1 = startVert;
1476 newFace2.v2 = i - numVerts; 1469 newFace2.v2 = i - numVerts;
1477 newFace2.v3 = startVert - numVerts; 1470 newFace2.v3 = startVert - numVerts;
1478 this.faces.Add(newFace2); 1471 linkfaces.Add(newFace2);
1479 1472
1480 if (this.hasHollow) 1473 if (hasHollow)
1481 { 1474 {
1482 startVert = ++i; 1475 startVert = ++i;
1483 for (int l = 0; l < profile.numHollowVerts - 1; l++) 1476 for (int l = 0; l < profile.numHollowVerts - 1; l++)
@@ -1485,27 +1478,25 @@ namespace PrimMesher
1485 newFace1.v1 = i; 1478 newFace1.v1 = i;
1486 newFace1.v2 = i - numVerts; 1479 newFace1.v2 = i - numVerts;
1487 newFace1.v3 = i + 1; 1480 newFace1.v3 = i + 1;
1488 this.faces.Add(newFace1); 1481 linkfaces.Add(newFace1);
1489 1482
1490 newFace2.v1 = i + 1; 1483 newFace2.v1 = i + 1;
1491 newFace2.v2 = i - numVerts; 1484 newFace2.v2 = i - numVerts;
1492 newFace2.v3 = i + 1 - numVerts; 1485 newFace2.v3 = i + 1 - numVerts;
1493 this.faces.Add(newFace2); 1486 linkfaces.Add(newFace2);
1494 i++; 1487 i++;
1495 } 1488 }
1496 1489
1497 newFace1.v1 = i; 1490 newFace1.v1 = i;
1498 newFace1.v2 = i - numVerts; 1491 newFace1.v2 = i - numVerts;
1499 newFace1.v3 = startVert; 1492 newFace1.v3 = startVert;
1500 this.faces.Add(newFace1); 1493 linkfaces.Add(newFace1);
1501 1494
1502 newFace2.v1 = startVert; 1495 newFace2.v1 = startVert;
1503 newFace2.v2 = i - numVerts; 1496 newFace2.v2 = i - numVerts;
1504 newFace2.v3 = startVert - numVerts; 1497 newFace2.v3 = startVert - numVerts;
1505 this.faces.Add(newFace2); 1498 linkfaces.Add(newFace2);
1506 } 1499 }
1507
1508
1509 } 1500 }
1510 else 1501 else
1511 { 1502 {
@@ -1518,21 +1509,27 @@ namespace PrimMesher
1518 newFace1.v1 = i; 1509 newFace1.v1 = i;
1519 newFace1.v2 = i - numVerts; 1510 newFace1.v2 = i - numVerts;
1520 newFace1.v3 = iNext; 1511 newFace1.v3 = iNext;
1521 this.faces.Add(newFace1); 1512 linkfaces.Add(newFace1);
1522 1513
1523 newFace2.v1 = iNext; 1514 newFace2.v1 = iNext;
1524 newFace2.v2 = i - numVerts; 1515 newFace2.v2 = i - numVerts;
1525 newFace2.v3 = iNext - numVerts; 1516 newFace2.v3 = iNext - numVerts;
1526 this.faces.Add(newFace2); 1517 linkfaces.Add(newFace2);
1527
1528 } 1518 }
1529 } 1519 }
1530 } 1520 }
1531 1521
1532 lastV = thisV; 1522 if(linkfaces.Count > 0)
1523 faces.AddRange(linkfaces);
1533 1524
1534 } // for (int nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++) 1525 if (needEndFaces && nodeIndex == lastNode && newLayer.faces.Count > 0)
1526 {
1527 newLayer.AddValue2FaceVertexIndices(coordsStart);
1528 faces.AddRange(newLayer.faces);
1529 }
1535 1530
1531 } // for (int nodeIndex = 0; nodeIndex < path.pathNodes.Count; nodeIndex++)
1532 // more cleanup will be done at Meshmerizer.cs
1536 } 1533 }
1537 1534
1538 1535
@@ -1543,7 +1540,7 @@ namespace PrimMesher
1543 /// 1540 ///
1544 public void ExtrudeLinear() 1541 public void ExtrudeLinear()
1545 { 1542 {
1546 this.Extrude(PathType.Linear); 1543 Extrude(PathType.Linear);
1547 } 1544 }
1548 1545
1549 1546
@@ -1554,7 +1551,7 @@ namespace PrimMesher
1554 /// 1551 ///
1555 public void ExtrudeCircular() 1552 public void ExtrudeCircular()
1556 { 1553 {
1557 this.Extrude(PathType.Circular); 1554 Extrude(PathType.Circular);
1558 } 1555 }
1559 1556
1560 1557