diff options
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 103 |
1 files changed, 93 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 932943c..53022ad 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -257,7 +257,6 @@ namespace PrimMesher | |||
257 | public int uv2; | 257 | public int uv2; |
258 | public int uv3; | 258 | public int uv3; |
259 | 259 | ||
260 | |||
261 | public Face(int v1, int v2, int v3) | 260 | public Face(int v1, int v2, int v3) |
262 | { | 261 | { |
263 | primFace = 0; | 262 | primFace = 0; |
@@ -630,6 +629,9 @@ namespace PrimMesher | |||
630 | internal int numOuterVerts = 0; | 629 | internal int numOuterVerts = 0; |
631 | internal int numHollowVerts = 0; | 630 | internal int numHollowVerts = 0; |
632 | 631 | ||
632 | internal int outerFaceNumber = -1; | ||
633 | internal int hollowFaceNumber = -1; | ||
634 | |||
633 | internal bool calcVertexNormals = false; | 635 | internal bool calcVertexNormals = false; |
634 | internal int bottomFaceNumber = 0; | 636 | internal int bottomFaceNumber = 0; |
635 | internal int numPrimFaces = 0; | 637 | internal int numPrimFaces = 0; |
@@ -936,10 +938,10 @@ namespace PrimMesher | |||
936 | 938 | ||
937 | if (calcVertexNormals && hasProfileCut) | 939 | if (calcVertexNormals && hasProfileCut) |
938 | { | 940 | { |
941 | int lastOuterVertIndex = this.numOuterVerts - 1; | ||
942 | |||
939 | if (hasHollow) | 943 | if (hasHollow) |
940 | { | 944 | { |
941 | int lastOuterVertIndex = this.numOuterVerts - 1; | ||
942 | |||
943 | this.cut1CoordIndices.Add(0); | 945 | this.cut1CoordIndices.Add(0); |
944 | this.cut1CoordIndices.Add(this.coords.Count - 1); | 946 | this.cut1CoordIndices.Add(this.coords.Count - 1); |
945 | 947 | ||
@@ -955,6 +957,12 @@ namespace PrimMesher | |||
955 | 957 | ||
956 | else | 958 | else |
957 | { | 959 | { |
960 | this.cut1CoordIndices.Add(0); | ||
961 | this.cut1CoordIndices.Add(1); | ||
962 | |||
963 | this.cut2CoordIndices.Add(lastOuterVertIndex); | ||
964 | this.cut2CoordIndices.Add(0); | ||
965 | |||
958 | this.cutNormal1.X = this.vertexNormals[1].Y; | 966 | this.cutNormal1.X = this.vertexNormals[1].Y; |
959 | this.cutNormal1.Y = -this.vertexNormals[1].X; | 967 | this.cutNormal1.Y = -this.vertexNormals[1].X; |
960 | 968 | ||
@@ -979,11 +987,14 @@ namespace PrimMesher | |||
979 | // I know it's ugly but so is the whole concept of prim face numbers | 987 | // I know it's ugly but so is the whole concept of prim face numbers |
980 | 988 | ||
981 | int faceNum = 1; // start with outer faces | 989 | int faceNum = 1; // start with outer faces |
990 | this.outerFaceNumber = faceNum; | ||
991 | |||
982 | int startVert = hasProfileCut && !hasHollow ? 1 : 0; | 992 | int startVert = hasProfileCut && !hasHollow ? 1 : 0; |
983 | if (startVert > 0) | 993 | if (startVert > 0) |
984 | this.faceNumbers.Add(-1); | 994 | this.faceNumbers.Add(-1); |
985 | for (int i = 0; i < this.numOuterVerts - 1; i++) | 995 | for (int i = 0; i < this.numOuterVerts - 1; i++) |
986 | this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); | 996 | //this.faceNumbers.Add(sides < 5 ? faceNum++ : faceNum); |
997 | this.faceNumbers.Add(sides < 5 && i < sides ? faceNum++ : faceNum); | ||
987 | 998 | ||
988 | //if (!hasHollow && !hasProfileCut) | 999 | //if (!hasHollow && !hasProfileCut) |
989 | // this.bottomFaceNumber = faceNum++; | 1000 | // this.bottomFaceNumber = faceNum++; |
@@ -993,12 +1004,15 @@ namespace PrimMesher | |||
993 | if (sides > 4 && (hasHollow || hasProfileCut)) | 1004 | if (sides > 4 && (hasHollow || hasProfileCut)) |
994 | faceNum++; | 1005 | faceNum++; |
995 | 1006 | ||
1007 | if (sides < 5 && (hasHollow || hasProfileCut) && this.numOuterVerts < sides) | ||
1008 | faceNum++; | ||
1009 | |||
996 | if (hasHollow) | 1010 | if (hasHollow) |
997 | { | 1011 | { |
998 | for (int i = 0; i < this.numHollowVerts; i++) | 1012 | for (int i = 0; i < this.numHollowVerts; i++) |
999 | this.faceNumbers.Add(faceNum); | 1013 | this.faceNumbers.Add(faceNum); |
1000 | 1014 | ||
1001 | faceNum++; | 1015 | this.hollowFaceNumber = faceNum++; |
1002 | } | 1016 | } |
1003 | //if (hasProfileCut || hasHollow) | 1017 | //if (hasProfileCut || hasHollow) |
1004 | // this.bottomFaceNumber = faceNum++; | 1018 | // this.bottomFaceNumber = faceNum++; |
@@ -1006,11 +1020,11 @@ namespace PrimMesher | |||
1006 | 1020 | ||
1007 | if (hasHollow && hasProfileCut) | 1021 | if (hasHollow && hasProfileCut) |
1008 | this.faceNumbers.Add(faceNum++); | 1022 | this.faceNumbers.Add(faceNum++); |
1023 | |||
1009 | for (int i = 0; i < this.faceNumbers.Count; i++) | 1024 | for (int i = 0; i < this.faceNumbers.Count; i++) |
1010 | if (this.faceNumbers[i] == -1) | 1025 | if (this.faceNumbers[i] == -1) |
1011 | this.faceNumbers[i] = faceNum++; | 1026 | this.faceNumbers[i] = faceNum++; |
1012 | 1027 | ||
1013 | |||
1014 | this.numPrimFaces = faceNum; | 1028 | this.numPrimFaces = faceNum; |
1015 | } | 1029 | } |
1016 | 1030 | ||
@@ -1455,11 +1469,15 @@ namespace PrimMesher | |||
1455 | public float revolutions = 1.0f; | 1469 | public float revolutions = 1.0f; |
1456 | public int stepsPerRevolution = 24; | 1470 | public int stepsPerRevolution = 24; |
1457 | 1471 | ||
1472 | private int profileOuterFaceNumber = -1; | ||
1473 | private int profileHollowFaceNumber = -1; | ||
1474 | |||
1458 | private bool hasProfileCut = false; | 1475 | private bool hasProfileCut = false; |
1459 | private bool hasHollow = false; | 1476 | private bool hasHollow = false; |
1460 | public bool calcVertexNormals = false; | 1477 | public bool calcVertexNormals = false; |
1461 | private bool normalsProcessed = false; | 1478 | private bool normalsProcessed = false; |
1462 | public bool viewerMode = false; | 1479 | public bool viewerMode = false; |
1480 | public bool sphereMode = false; | ||
1463 | 1481 | ||
1464 | public int numPrimFaces = 0; | 1482 | public int numPrimFaces = 0; |
1465 | 1483 | ||
@@ -1491,10 +1509,35 @@ namespace PrimMesher | |||
1491 | s += "\nradius...............: " + this.radius.ToString(); | 1509 | s += "\nradius...............: " + this.radius.ToString(); |
1492 | s += "\nrevolutions..........: " + this.revolutions.ToString(); | 1510 | s += "\nrevolutions..........: " + this.revolutions.ToString(); |
1493 | s += "\nstepsPerRevolution...: " + this.stepsPerRevolution.ToString(); | 1511 | s += "\nstepsPerRevolution...: " + this.stepsPerRevolution.ToString(); |
1512 | s += "\nsphereMode...........: " + this.sphereMode.ToString(); | ||
1513 | s += "\nhasProfileCut........: " + this.hasProfileCut.ToString(); | ||
1514 | s += "\nhasHollow............: " + this.hasHollow.ToString(); | ||
1515 | s += "\nviewerMode...........: " + this.viewerMode.ToString(); | ||
1494 | 1516 | ||
1495 | return s; | 1517 | return s; |
1496 | } | 1518 | } |
1497 | 1519 | ||
1520 | public int ProfileOuterFaceNumber | ||
1521 | { | ||
1522 | get { return profileOuterFaceNumber; } | ||
1523 | } | ||
1524 | |||
1525 | public int ProfileHollowFaceNumber | ||
1526 | { | ||
1527 | get { return profileHollowFaceNumber; } | ||
1528 | } | ||
1529 | |||
1530 | public bool HasProfileCut | ||
1531 | { | ||
1532 | get { return hasProfileCut; } | ||
1533 | } | ||
1534 | |||
1535 | public bool HasHollow | ||
1536 | { | ||
1537 | get { return hasHollow; } | ||
1538 | } | ||
1539 | |||
1540 | |||
1498 | /// <summary> | 1541 | /// <summary> |
1499 | /// Constructs a PrimMesh object and creates the profile for extrusion. | 1542 | /// Constructs a PrimMesh object and creates the profile for extrusion. |
1500 | /// </summary> | 1543 | /// </summary> |
@@ -1531,8 +1574,12 @@ namespace PrimMesher | |||
1531 | if (hollow < 0.0f) | 1574 | if (hollow < 0.0f) |
1532 | this.hollow = 0.0f; | 1575 | this.hollow = 0.0f; |
1533 | 1576 | ||
1534 | this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); | 1577 | //if (sphereMode) |
1535 | this.hasHollow = (this.hollow > 0.001f); | 1578 | // this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f; |
1579 | //else | ||
1580 | // //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); | ||
1581 | // this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f; | ||
1582 | //this.hasHollow = (this.hollow > 0.001f); | ||
1536 | } | 1583 | } |
1537 | 1584 | ||
1538 | /// <summary> | 1585 | /// <summary> |
@@ -1540,6 +1587,8 @@ namespace PrimMesher | |||
1540 | /// </summary> | 1587 | /// </summary> |
1541 | public void Extrude(PathType pathType) | 1588 | public void Extrude(PathType pathType) |
1542 | { | 1589 | { |
1590 | bool needEndFaces = false; | ||
1591 | |||
1543 | this.coords = new List<Coord>(); | 1592 | this.coords = new List<Coord>(); |
1544 | this.faces = new List<Face>(); | 1593 | this.faces = new List<Face>(); |
1545 | 1594 | ||
@@ -1565,6 +1614,12 @@ namespace PrimMesher | |||
1565 | steps = (int)(steps * 4.5 * length); | 1614 | steps = (int)(steps * 4.5 * length); |
1566 | } | 1615 | } |
1567 | 1616 | ||
1617 | if (sphereMode) | ||
1618 | this.hasProfileCut = this.profileEnd - this.profileStart < 0.4999f; | ||
1619 | else | ||
1620 | //this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); | ||
1621 | this.hasProfileCut = this.profileEnd - this.profileStart < 0.9999f; | ||
1622 | this.hasHollow = (this.hollow > 0.001f); | ||
1568 | 1623 | ||
1569 | float twistBegin = this.twistBegin / 360.0f * twoPi; | 1624 | float twistBegin = this.twistBegin / 360.0f * twoPi; |
1570 | float twistEnd = this.twistEnd / 360.0f * twoPi; | 1625 | float twistEnd = this.twistEnd / 360.0f * twoPi; |
@@ -1634,6 +1689,32 @@ namespace PrimMesher | |||
1634 | 1689 | ||
1635 | this.numPrimFaces = profile.numPrimFaces; | 1690 | this.numPrimFaces = profile.numPrimFaces; |
1636 | 1691 | ||
1692 | //profileOuterFaceNumber = profile.faceNumbers[0]; | ||
1693 | //if (!needEndFaces) | ||
1694 | // profileOuterFaceNumber--; | ||
1695 | //profileOuterFaceNumber = needEndFaces ? 1 : 0; | ||
1696 | |||
1697 | |||
1698 | //if (hasHollow) | ||
1699 | //{ | ||
1700 | // if (needEndFaces) | ||
1701 | // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts + 1]; | ||
1702 | // else | ||
1703 | // profileHollowFaceNumber = profile.faceNumbers[profile.numOuterVerts] - 1; | ||
1704 | //} | ||
1705 | |||
1706 | |||
1707 | profileOuterFaceNumber = profile.outerFaceNumber; | ||
1708 | if (!needEndFaces) | ||
1709 | profileOuterFaceNumber--; | ||
1710 | |||
1711 | if (hasHollow) | ||
1712 | { | ||
1713 | profileHollowFaceNumber = profile.hollowFaceNumber; | ||
1714 | if (!needEndFaces) | ||
1715 | profileHollowFaceNumber--; | ||
1716 | } | ||
1717 | |||
1637 | int cut1Vert = -1; | 1718 | int cut1Vert = -1; |
1638 | int cut2Vert = -1; | 1719 | int cut2Vert = -1; |
1639 | if (hasProfileCut) | 1720 | if (hasProfileCut) |
@@ -1673,7 +1754,7 @@ namespace PrimMesher | |||
1673 | 1754 | ||
1674 | path.Create(pathType, steps); | 1755 | path.Create(pathType, steps); |
1675 | 1756 | ||
1676 | bool needEndFaces = false; | 1757 | |
1677 | if (pathType == PathType.Circular) | 1758 | if (pathType == PathType.Circular) |
1678 | { | 1759 | { |
1679 | needEndFaces = false; | 1760 | needEndFaces = false; |
@@ -1761,7 +1842,7 @@ namespace PrimMesher | |||
1761 | int startVert = coordsLen + 1; | 1842 | int startVert = coordsLen + 1; |
1762 | int endVert = this.coords.Count; | 1843 | int endVert = this.coords.Count; |
1763 | 1844 | ||
1764 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) | 1845 | if (sides < 5 || this.hasProfileCut || this.hasHollow) |
1765 | startVert--; | 1846 | startVert--; |
1766 | 1847 | ||
1767 | for (int i = startVert; i < endVert; i++) | 1848 | for (int i = startVert; i < endVert; i++) |
@@ -1813,11 +1894,13 @@ namespace PrimMesher | |||
1813 | u1 -= (int)u1; | 1894 | u1 -= (int)u1; |
1814 | if (u2 < 0.1f) | 1895 | if (u2 < 0.1f) |
1815 | u2 = 1.0f; | 1896 | u2 = 1.0f; |
1897 | //this.profileOuterFaceNumber = primFaceNum; | ||
1816 | } | 1898 | } |
1817 | else if (whichVert > profile.coords.Count - profile.numHollowVerts - 1) | 1899 | else if (whichVert > profile.coords.Count - profile.numHollowVerts - 1) |
1818 | { | 1900 | { |
1819 | u1 *= 2.0f; | 1901 | u1 *= 2.0f; |
1820 | u2 *= 2.0f; | 1902 | u2 *= 2.0f; |
1903 | //this.profileHollowFaceNumber = primFaceNum; | ||
1821 | } | 1904 | } |
1822 | } | 1905 | } |
1823 | 1906 | ||