aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/Meshing')
-rw-r--r--OpenSim/Region/Physics/Meshing/HelperTypes.cs14
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs64
-rw-r--r--OpenSim/Region/Physics/Meshing/SimpleHull.cs2
3 files changed, 40 insertions, 40 deletions
diff --git a/OpenSim/Region/Physics/Meshing/HelperTypes.cs b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
index efc5968..584133c 100644
--- a/OpenSim/Region/Physics/Meshing/HelperTypes.cs
+++ b/OpenSim/Region/Physics/Meshing/HelperTypes.cs
@@ -49,7 +49,7 @@ public class Quaternion
49 } 49 }
50 public Quaternion(Vertex axis, float angle) 50 public Quaternion(Vertex axis, float angle)
51 { 51 {
52 // using (* 0.5) instead of (/2) 52 // using (* 0.5) instead of (/2)
53 w = (float)Math.Cos(angle * 0.5f); 53 w = (float)Math.Cos(angle * 0.5f);
54 x = axis.X * (float)Math.Sin(angle * 0.5f); 54 x = axis.X * (float)Math.Sin(angle * 0.5f);
55 y = axis.Y * (float)Math.Sin(angle * 0.5f); 55 y = axis.Y * (float)Math.Sin(angle * 0.5f);
@@ -65,8 +65,8 @@ public class Quaternion
65 c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z; 65 c.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z;
66 return c; 66 return c;
67 } 67 }
68 68
69 69
70 public Matrix4 computeMatrix() 70 public Matrix4 computeMatrix()
71 { 71 {
72 return new Matrix4(this); 72 return new Matrix4(this);
@@ -74,7 +74,7 @@ public class Quaternion
74 public void normalize() 74 public void normalize()
75 { 75 {
76 float mag = length(); 76 float mag = length();
77 77
78 w /= mag; 78 w /= mag;
79 x /= mag; 79 x /= mag;
80 y /= mag; 80 y /= mag;
@@ -367,7 +367,7 @@ public class Triangle
367 // It is assumed, that the triangles vertices are already set correctly 367 // It is assumed, that the triangles vertices are already set correctly
368 double p1x, p2x, p1y, p2y, p3x, p3y; 368 double p1x, p2x, p1y, p2y, p3x, p3y;
369 369
370 // Deviation of this routine: 370 // Deviation of this routine:
371 // A circle has the general equation (M-p)^2=r^2, where M and p are vectors 371 // A circle has the general equation (M-p)^2=r^2, where M and p are vectors
372 // this gives us three equations f(p)=r^2, each for one point p1, p2, p3 372 // this gives us three equations f(p)=r^2, each for one point p1, p2, p3
373 // putting respectively two equations together gives two equations 373 // putting respectively two equations together gives two equations
@@ -378,7 +378,7 @@ public class Triangle
378 // Now using the equations that are formed by the components of the vectors 378 // Now using the equations that are formed by the components of the vectors
379 // and isolate Mx lets you make one equation that only holds My 379 // and isolate Mx lets you make one equation that only holds My
380 // The rest is straight forward and eaasy :-) 380 // The rest is straight forward and eaasy :-)
381 // 381 //
382 382
383 /* helping variables for temporary results */ 383 /* helping variables for temporary results */
384 double c1, c2; 384 double c1, c2;
@@ -496,7 +496,7 @@ public class Triangle
496 v2 = vt; 496 v2 = vt;
497 } 497 }
498 498
499 // Dumps a triangle in the "raw faces" format, blender can import. This is for visualisation and 499 // Dumps a triangle in the "raw faces" format, blender can import. This is for visualisation and
500 // debugging purposes 500 // debugging purposes
501 public String ToStringRaw() 501 public String ToStringRaw()
502 { 502 {
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 2e7ec15..4bf12c9 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -115,7 +115,7 @@ namespace OpenSim.Region.Physics.Meshing
115 for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++) 115 for (iCurrentVertex = usedForSeed; iCurrentVertex < iMaxVertex; iCurrentVertex++)
116 { 116 {
117 // Background: A triangle mesh fulfills the delaunay condition if (iff!) 117 // Background: A triangle mesh fulfills the delaunay condition if (iff!)
118 // each circumlocutory circle (i.e. the circle that touches all three corners) 118 // each circumlocutory circle (i.e. the circle that touches all three corners)
119 // of each triangle is empty of other vertices. 119 // of each triangle is empty of other vertices.
120 // Obviously a single (seeding) triangle fulfills this condition. 120 // Obviously a single (seeding) triangle fulfills this condition.
121 // If we now add one vertex, we need to reconstruct all triangles, that 121 // If we now add one vertex, we need to reconstruct all triangles, that
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Physics.Meshing
132 // Reconstruction phase. First step, dissolve each triangle into it's simplices, 132 // Reconstruction phase. First step, dissolve each triangle into it's simplices,
133 // i.e. it's "border lines" 133 // i.e. it's "border lines"
134 // Goal is to find "inner" borders and delete them, while the hull gets conserved. 134 // Goal is to find "inner" borders and delete them, while the hull gets conserved.
135 // Inner borders are special in the way that they always come twice, which is how we detect them 135 // Inner borders are special in the way that they always come twice, which is how we detect them
136 foreach (Triangle t in influencedTriangles) 136 foreach (Triangle t in influencedTriangles)
137 { 137 {
138 List<Simplex> newSimplices = t.GetSimplices(); 138 List<Simplex> newSimplices = t.GetSimplices();
@@ -142,8 +142,8 @@ namespace OpenSim.Region.Physics.Meshing
142 // Now sort the simplices. That will make identical ones reside side by side in the list 142 // Now sort the simplices. That will make identical ones reside side by side in the list
143 simplices.Sort(); 143 simplices.Sort();
144 144
145 // Look for duplicate simplices here. 145 // Look for duplicate simplices here.
146 // Remember, they are directly side by side in the list right now, 146 // Remember, they are directly side by side in the list right now,
147 // So we only check directly neighbours 147 // So we only check directly neighbours
148 int iSimplex; 148 int iSimplex;
149 List<Simplex> innerSimplices = new List<Simplex>(); 149 List<Simplex> innerSimplices = new List<Simplex>();
@@ -162,7 +162,7 @@ namespace OpenSim.Region.Physics.Meshing
162 } 162 }
163 163
164 // each simplex still in the list belongs to the hull of the region in question 164 // each simplex still in the list belongs to the hull of the region in question
165 // The new vertex (yes, we still deal with verices here :-)) forms a triangle 165 // The new vertex (yes, we still deal with verices here :-)) forms a triangle
166 // with each of these simplices. Build the new triangles and add them to the list 166 // with each of these simplices. Build the new triangles and add them to the list
167 foreach (Simplex s in simplices) 167 foreach (Simplex s in simplices)
168 { 168 {
@@ -206,14 +206,14 @@ namespace OpenSim.Region.Physics.Meshing
206 } 206 }
207 break; 207 break;
208 208
209 209
210 default: 210 default:
211 if (hshape == HollowShape.Same) 211 if (hshape == HollowShape.Same)
212 hshape= HollowShape.Square; 212 hshape= HollowShape.Square;
213 break; 213 break;
214 } 214 }
215 215
216 216
217 SimpleHull holeHull = null; 217 SimpleHull holeHull = null;
218 218
219 if (hshape == HollowShape.Square) 219 if (hshape == HollowShape.Square)
@@ -428,13 +428,13 @@ namespace OpenSim.Region.Physics.Meshing
428 UInt16 pathShearY = primShape.PathShearY; 428 UInt16 pathShearY = primShape.PathShearY;
429 Int16 twistTop = primShape.PathTwistBegin; 429 Int16 twistTop = primShape.PathTwistBegin;
430 Int16 twistBot = primShape.PathTwist; 430 Int16 twistBot = primShape.PathTwist;
431 431
432 432
433 //m_log.Error("pathShear:" + primShape.PathShearX.ToString() + "," + primShape.PathShearY.ToString()); 433 //m_log.Error("pathShear:" + primShape.PathShearX.ToString() + "," + primShape.PathShearY.ToString());
434 //m_log.Error("pathTaper:" + primShape.PathTaperX.ToString() + "," + primShape.PathTaperY.ToString()); 434 //m_log.Error("pathTaper:" + primShape.PathTaperX.ToString() + "," + primShape.PathTaperY.ToString());
435 //m_log.Error("ProfileBegin:" + primShape.ProfileBegin.ToString() + "," + primShape.ProfileBegin.ToString()); 435 //m_log.Error("ProfileBegin:" + primShape.ProfileBegin.ToString() + "," + primShape.ProfileBegin.ToString());
436 //m_log.Error("PathScale:" + primShape.PathScaleX.ToString() + "," + primShape.PathScaleY.ToString()); 436 //m_log.Error("PathScale:" + primShape.PathScaleX.ToString() + "," + primShape.PathScaleY.ToString());
437 437
438 // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface 438 // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface
439 // of a block are basically the same 439 // of a block are basically the same
440 // They may be warped differently but the shape is identical 440 // They may be warped differently but the shape is identical
@@ -469,7 +469,7 @@ namespace OpenSim.Region.Physics.Meshing
469 if (fProfileBeginAngle < fProfileEndAngle) 469 if (fProfileBeginAngle < fProfileEndAngle)
470 fProfileEndAngle -= 360.0; 470 fProfileEndAngle -= 360.0;
471 471
472 // Note, that we don't want to cut out a triangle, even if this is a 472 // Note, that we don't want to cut out a triangle, even if this is a
473 // good approximation for small cuts. Indeed we want to cut out an arc 473 // good approximation for small cuts. Indeed we want to cut out an arc
474 // and we approximate this arc by a polygon chain 474 // and we approximate this arc by a polygon chain
475 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space 475 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
@@ -559,7 +559,7 @@ namespace OpenSim.Region.Physics.Meshing
559 extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100); 559 extr.taperBotFactorX = 1.0f - ((100 - (float)taperX) / 100);
560 //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString()); 560 //m_log.Warn("taperBotFactorX: " + extr.taperBotFactorX.ToString());
561 } 561 }
562 562
563 } 563 }
564 564
565 if (taperY != 100) 565 if (taperY != 100)
@@ -575,8 +575,8 @@ namespace OpenSim.Region.Physics.Meshing
575 //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString()); 575 //m_log.Warn("taperBotFactorY: " + extr.taperBotFactorY.ToString());
576 } 576 }
577 } 577 }
578 578
579 579
580 if (pathShearX != 0) 580 if (pathShearX != 0)
581 { 581 {
582 if (pathShearX > 50) 582 if (pathShearX > 50)
@@ -585,7 +585,7 @@ namespace OpenSim.Region.Physics.Meshing
585 extr.pushX = (((float)(256 - pathShearX) / 100) * -1f); 585 extr.pushX = (((float)(256 - pathShearX) / 100) * -1f);
586 // m_log.Warn("pushX: " + extr.pushX); 586 // m_log.Warn("pushX: " + extr.pushX);
587 } 587 }
588 else 588 else
589 { 589 {
590 extr.pushX = (float)pathShearX / 100; 590 extr.pushX = (float)pathShearX / 100;
591 // m_log.Warn("pushX: " + extr.pushX); 591 // m_log.Warn("pushX: " + extr.pushX);
@@ -600,7 +600,7 @@ namespace OpenSim.Region.Physics.Meshing
600 extr.pushY = (((float)(256 - pathShearY) / 100) * -1f); 600 extr.pushY = (((float)(256 - pathShearY) / 100) * -1f);
601 //m_log.Warn("pushY: " + extr.pushY); 601 //m_log.Warn("pushY: " + extr.pushY);
602 } 602 }
603 else 603 else
604 { 604 {
605 extr.pushY = (float)pathShearY / 100; 605 extr.pushY = (float)pathShearY / 100;
606 //m_log.Warn("pushY: " + extr.pushY); 606 //m_log.Warn("pushY: " + extr.pushY);
@@ -615,7 +615,7 @@ namespace OpenSim.Region.Physics.Meshing
615 extr.twistTop = 360 - (-1 * extr.twistTop); 615 extr.twistTop = 360 - (-1 * extr.twistTop);
616 616
617 } 617 }
618 618
619 619
620 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); 620 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD);
621 } 621 }
@@ -660,7 +660,7 @@ namespace OpenSim.Region.Physics.Meshing
660 UInt16 pathShearY = primShape.PathShearY; 660 UInt16 pathShearY = primShape.PathShearY;
661 Int16 twistBot = primShape.PathTwist; 661 Int16 twistBot = primShape.PathTwist;
662 Int16 twistTop = primShape.PathTwistBegin; 662 Int16 twistTop = primShape.PathTwistBegin;
663 663
664 664
665 // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface 665 // Procedure: This is based on the fact that the upper (plus) and lower (minus) Z-surface
666 // of a block are basically the same 666 // of a block are basically the same
@@ -715,7 +715,7 @@ namespace OpenSim.Region.Physics.Meshing
715 //Vertex Q1Q12 = new Vertex(-0.46f, -0.18f, 0.0f); 715 //Vertex Q1Q12 = new Vertex(-0.46f, -0.18f, 0.0f);
716 //Vertex Q1Q13 = new Vertex(-0.43f, -0.24f, 0.0f); 716 //Vertex Q1Q13 = new Vertex(-0.43f, -0.24f, 0.0f);
717 //Vertex Q1Q14 = new Vertex(-0.40f, -0.30f, 0.0f); 717 //Vertex Q1Q14 = new Vertex(-0.40f, -0.30f, 0.0f);
718 718
719 SimpleHull outerHull = new SimpleHull(); 719 SimpleHull outerHull = new SimpleHull();
720 //Clockwise around the quadrants 720 //Clockwise around the quadrants
721 //outerHull.AddVertex(Q1Q15); 721 //outerHull.AddVertex(Q1Q15);
@@ -803,7 +803,7 @@ namespace OpenSim.Region.Physics.Meshing
803 if (fProfileBeginAngle < fProfileEndAngle) 803 if (fProfileBeginAngle < fProfileEndAngle)
804 fProfileEndAngle -= 360.0; 804 fProfileEndAngle -= 360.0;
805 805
806 // Note, that we don't want to cut out a triangle, even if this is a 806 // Note, that we don't want to cut out a triangle, even if this is a
807 // good approximation for small cuts. Indeed we want to cut out an arc 807 // good approximation for small cuts. Indeed we want to cut out an arc
808 // and we approximate this arc by a polygon chain 808 // and we approximate this arc by a polygon chain
809 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space 809 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
@@ -940,7 +940,7 @@ namespace OpenSim.Region.Physics.Meshing
940 extr.pushY = (float)pathShearY / 100; 940 extr.pushY = (float)pathShearY / 100;
941 //m_log.Warn("pushY: " + extr.pushY); 941 //m_log.Warn("pushY: " + extr.pushY);
942 } 942 }
943 943
944 } 944 }
945 945
946 if (twistTop != 0) 946 if (twistTop != 0)
@@ -949,9 +949,9 @@ namespace OpenSim.Region.Physics.Meshing
949 if (extr.twistTop > 0) 949 if (extr.twistTop > 0)
950 { 950 {
951 extr.twistTop = 360 - (-1 * extr.twistTop); 951 extr.twistTop = 360 - (-1 * extr.twistTop);
952 952
953 } 953 }
954 954
955 955
956 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); 956 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD);
957 } 957 }
@@ -967,7 +967,7 @@ namespace OpenSim.Region.Physics.Meshing
967 } 967 }
968 extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD); 968 extr.twistMid = (float)(extr.twistMid * DEG_TO_RAD);
969 } 969 }
970 970
971 if (twistBot != 0) 971 if (twistBot != 0)
972 { 972 {
973 extr.twistBot = 180 * ((float)twistBot / 100); 973 extr.twistBot = 180 * ((float)twistBot / 100);
@@ -1013,7 +1013,7 @@ namespace OpenSim.Region.Physics.Meshing
1013 Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f); 1013 Vertex MM = new Vertex(-0.25f, -0.45f, 0.0f);
1014 Vertex PM = new Vertex(+0.5f, 0f, 0.0f); 1014 Vertex PM = new Vertex(+0.5f, 0f, 0.0f);
1015 Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f); 1015 Vertex PP = new Vertex(-0.25f, +0.45f, 0.0f);
1016 1016
1017 1017
1018 SimpleHull outerHull = new SimpleHull(); 1018 SimpleHull outerHull = new SimpleHull();
1019 //outerHull.AddVertex(MM); 1019 //outerHull.AddVertex(MM);
@@ -1022,7 +1022,7 @@ namespace OpenSim.Region.Physics.Meshing
1022 outerHull.AddVertex(PP); 1022 outerHull.AddVertex(PP);
1023 outerHull.AddVertex(MM); 1023 outerHull.AddVertex(MM);
1024 outerHull.AddVertex(PM); 1024 outerHull.AddVertex(PM);
1025 1025
1026 // Deal with cuts now 1026 // Deal with cuts now
1027 if ((profileBegin != 0) || (profileEnd != 0)) 1027 if ((profileBegin != 0) || (profileEnd != 0))
1028 { 1028 {
@@ -1034,7 +1034,7 @@ namespace OpenSim.Region.Physics.Meshing
1034 if (fProfileBeginAngle < fProfileEndAngle) 1034 if (fProfileBeginAngle < fProfileEndAngle)
1035 fProfileEndAngle -= 360.0; 1035 fProfileEndAngle -= 360.0;
1036 1036
1037 // Note, that we don't want to cut out a triangle, even if this is a 1037 // Note, that we don't want to cut out a triangle, even if this is a
1038 // good approximation for small cuts. Indeed we want to cut out an arc 1038 // good approximation for small cuts. Indeed we want to cut out an arc
1039 // and we approximate this arc by a polygon chain 1039 // and we approximate this arc by a polygon chain
1040 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space 1040 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
@@ -1177,7 +1177,7 @@ namespace OpenSim.Region.Physics.Meshing
1177 extr.twistTop = 360 - (-1 * extr.twistTop); 1177 extr.twistTop = 360 - (-1 * extr.twistTop);
1178 1178
1179 } 1179 }
1180 1180
1181 1181
1182 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD); 1182 extr.twistTop = (float)(extr.twistTop * DEG_TO_RAD);
1183 } 1183 }
@@ -1255,7 +1255,7 @@ namespace OpenSim.Region.Physics.Meshing
1255 1255
1256 1256
1257 // Base Faces of the Icosahedron (20) 1257 // Base Faces of the Icosahedron (20)
1258 SphereLODTriangle(v1, v2, v3, diameter, LOD, m); 1258 SphereLODTriangle(v1, v2, v3, diameter, LOD, m);
1259 SphereLODTriangle(v4, v3, v2, diameter, LOD, m); 1259 SphereLODTriangle(v4, v3, v2, diameter, LOD, m);
1260 SphereLODTriangle(v4, v5, v6, diameter, LOD, m); 1260 SphereLODTriangle(v4, v5, v6, diameter, LOD, m);
1261 SphereLODTriangle(v4, v9, v5, diameter, LOD, m); 1261 SphereLODTriangle(v4, v9, v5, diameter, LOD, m);
@@ -1284,7 +1284,7 @@ namespace OpenSim.Region.Physics.Meshing
1284 v.Z *= size.Z; 1284 v.Z *= size.Z;
1285 } 1285 }
1286 1286
1287 // This was built with the normals pointing inside.. 1287 // This was built with the normals pointing inside..
1288 // therefore we have to invert the normals 1288 // therefore we have to invert the normals
1289 foreach (Triangle t in m.triangles) 1289 foreach (Triangle t in m.triangles)
1290 { 1290 {
@@ -1308,7 +1308,7 @@ namespace OpenSim.Region.Physics.Meshing
1308 v.Y *= size.Y; 1308 v.Y *= size.Y;
1309 v.Z *= size.Z; 1309 v.Z *= size.Z;
1310 } 1310 }
1311 // This was built with the normals pointing inside.. 1311 // This was built with the normals pointing inside..
1312 // therefore we have to invert the normals 1312 // therefore we have to invert the normals
1313 foreach (Triangle t in sm.triangles) 1313 foreach (Triangle t in sm.triangles)
1314 { 1314 {
@@ -1462,7 +1462,7 @@ namespace OpenSim.Region.Physics.Meshing
1462 default: 1462 default:
1463 mesh = CreateBoxMesh(primName, primShape, size); 1463 mesh = CreateBoxMesh(primName, primShape, size);
1464 CalcNormals(mesh); 1464 CalcNormals(mesh);
1465 //Set default mesh to cube otherwise it'll return 1465 //Set default mesh to cube otherwise it'll return
1466 // null and crash on the 'setMesh' method in the physics plugins. 1466 // null and crash on the 'setMesh' method in the physics plugins.
1467 //mesh = null; 1467 //mesh = null;
1468 break; 1468 break;
@@ -1472,6 +1472,6 @@ namespace OpenSim.Region.Physics.Meshing
1472 return mesh; 1472 return mesh;
1473 } 1473 }
1474 1474
1475 1475
1476 } 1476 }
1477} 1477}
diff --git a/OpenSim/Region/Physics/Meshing/SimpleHull.cs b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
index 2896d3b..5eeadae 100644
--- a/OpenSim/Region/Physics/Meshing/SimpleHull.cs
+++ b/OpenSim/Region/Physics/Meshing/SimpleHull.cs
@@ -337,7 +337,7 @@ namespace OpenSim.Region.Physics.Meshing
337 } 337 }
338 338
339 339
340 if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition. 340 if (baseStartVertex == null) // i.e. no simplex fulfilled the "outside" condition.
341 // In otherwords, subtractHull completely embraces baseHull 341 // In otherwords, subtractHull completely embraces baseHull
342 { 342 {
343 return result; 343 return result;