aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorDahlia Trimble2008-12-22 06:07:51 +0000
committerDahlia Trimble2008-12-22 06:07:51 +0000
commitc66cfb51f7a83737cf2e48b1bab6f91e7c6f3a6f (patch)
treeef73f38b46da1275cc92710d97d733d007a1e49c /OpenSim/Region/Physics
parentOn closing EQs, make sure to wait for the viewer to fetch the last events. (diff)
downloadopensim-SC-c66cfb51f7a83737cf2e48b1bab6f91e7c6f3a6f.zip
opensim-SC-c66cfb51f7a83737cf2e48b1bab6f91e7c6f3a6f.tar.gz
opensim-SC-c66cfb51f7a83737cf2e48b1bab6f91e7c6f3a6f.tar.bz2
opensim-SC-c66cfb51f7a83737cf2e48b1bab6f91e7c6f3a6f.tar.xz
Fix a floating point comparison that was causing some misshaped triangles on some prim faces
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/Meshing/PrimMesher.cs27
1 files changed, 19 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
index f00a05c..9b20275 100644
--- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs
+++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs
@@ -651,7 +651,8 @@ namespace PrimMesher
651 this.numOuterVerts = angles.angles.Count; 651 this.numOuterVerts = angles.angles.Count;
652 652
653 // flag to create as few triangles as possible for 3 or 4 side profile 653 // flag to create as few triangles as possible for 3 or 4 side profile
654 bool simpleFace = (sides < 5 && !(hasHollow || hasProfileCut)); 654 //bool simpleFace = (sides < 5 && !(hasHollow || hasProfileCut));
655 bool simpleFace = (sides < 5 && !hasHollow && !hasProfileCut);
655 656
656 if (hasHollow) 657 if (hasHollow)
657 { 658 {
@@ -709,7 +710,7 @@ namespace PrimMesher
709 710
710 for (int i = 0; i < numAngles; i++) 711 for (int i = 0; i < numAngles; i++)
711 { 712 {
712 // int iNext = i == numAngles ? i + 1 : 0; 713 //int iNext = i == numAngles ? i + 1 : 0;
713 angle = angles.angles[i]; 714 angle = angles.angles[i];
714 newVert.X = angle.X * xScale; 715 newVert.X = angle.X * xScale;
715 newVert.Y = angle.Y * yScale; 716 newVert.Y = angle.Y * yScale;
@@ -717,7 +718,6 @@ namespace PrimMesher
717 this.coords.Add(newVert); 718 this.coords.Add(newVert);
718 if (this.calcVertexNormals) 719 if (this.calcVertexNormals)
719 { 720 {
720
721 if (sides < 5) 721 if (sides < 5)
722 { 722 {
723 this.vertexNormals.Add(angles.normals[i]); 723 this.vertexNormals.Add(angles.normals[i]);
@@ -731,7 +731,7 @@ namespace PrimMesher
731 } 731 }
732 } 732 }
733 733
734 if (hollow > 0.0f) 734 if (hasHollow)
735 { 735 {
736 if (hollowSides == sides) 736 if (hollowSides == sides)
737 { 737 {
@@ -807,7 +807,7 @@ namespace PrimMesher
807 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices 807 for (int i = 0; i < numHollowVerts; i++) // i is the index for inner vertices
808 { 808 {
809 if (j < maxJ) 809 if (j < maxJ)
810 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle <= hollowAngles.angles[i].angle - angles.angles[j].angle) 810 if (angles.angles[j + 1].angle - hollowAngles.angles[i].angle < hollowAngles.angles[i].angle - angles.angles[j].angle + 0.000001f)
811 { 811 {
812 newFace.v1 = numTotalVerts - i - 1; 812 newFace.v1 = numTotalVerts - i - 1;
813 newFace.v2 = j; 813 newFace.v2 = j;
@@ -832,7 +832,7 @@ namespace PrimMesher
832 for (int i = 0; i < numOuterVerts; i++) 832 for (int i = 0; i < numOuterVerts; i++)
833 { 833 {
834 if (j < maxJ) 834 if (j < maxJ)
835 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle <= angles.angles[i].angle - hollowAngles.angles[j].angle) 835 if (hollowAngles.angles[j + 1].angle - angles.angles[i].angle < angles.angles[i].angle - hollowAngles.angles[j].angle + 0.000001f)
836 { 836 {
837 newFace.v1 = i; 837 newFace.v1 = i;
838 newFace.v2 = numTotalVerts - j - 2; 838 newFace.v2 = numTotalVerts - j - 2;
@@ -853,6 +853,7 @@ namespace PrimMesher
853 } 853 }
854 854
855 this.coords.AddRange(hollowCoords); 855 this.coords.AddRange(hollowCoords);
856
856 if (this.calcVertexNormals) 857 if (this.calcVertexNormals)
857 { 858 {
858 this.vertexNormals.AddRange(hollowNormals); 859 this.vertexNormals.AddRange(hollowNormals);
@@ -1327,6 +1328,8 @@ namespace PrimMesher
1327 profile.MakeFaceUVs(); 1328 profile.MakeFaceUVs();
1328 } 1329 }
1329 1330
1331 if (this.sides == 4 && this.hollowSides == 3)
1332 profile.DumpRaw("d:\\", "primProfile", "");
1330 1333
1331 Coord lastCutNormal1 = new Coord(); 1334 Coord lastCutNormal1 = new Coord();
1332 Coord lastCutNormal2 = new Coord(); 1335 Coord lastCutNormal2 = new Coord();
@@ -1367,8 +1370,12 @@ namespace PrimMesher
1367 { 1370 {
1368 Coord faceNormal = newLayer.faceNormal; 1371 Coord faceNormal = newLayer.faceNormal;
1369 ViewerFace newViewerFace = new ViewerFace(0); 1372 ViewerFace newViewerFace = new ViewerFace(0);
1370 foreach (Face face in newLayer.faces) 1373 int numFaces = newLayer.faces.Count;
1374 List<Face> faces = newLayer.faces;
1375
1376 for (int i = 0; i < numFaces; i++)
1371 { 1377 {
1378 Face face = faces[i];
1372 newViewerFace.v1 = newLayer.coords[face.v1]; 1379 newViewerFace.v1 = newLayer.coords[face.v1];
1373 newViewerFace.v2 = newLayer.coords[face.v2]; 1380 newViewerFace.v2 = newLayer.coords[face.v2];
1374 newViewerFace.v3 = newLayer.coords[face.v3]; 1381 newViewerFace.v3 = newLayer.coords[face.v3];
@@ -1558,8 +1565,12 @@ namespace PrimMesher
1558 Coord faceNormal = newLayer.faceNormal; 1565 Coord faceNormal = newLayer.faceNormal;
1559 ViewerFace newViewerFace = new ViewerFace(); 1566 ViewerFace newViewerFace = new ViewerFace();
1560 newViewerFace.primFaceNumber = newLayer.bottomFaceNumber; 1567 newViewerFace.primFaceNumber = newLayer.bottomFaceNumber;
1561 foreach (Face face in newLayer.faces) 1568 int numFaces = newLayer.faces.Count;
1569 List<Face> faces = newLayer.faces;
1570
1571 for (int i = 0; i < numFaces; i++)
1562 { 1572 {
1573 Face face = faces[i];
1563 newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen]; 1574 newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen];
1564 newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen]; 1575 newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen];
1565 newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen]; 1576 newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen];