Eliminate some unnecessary polygons

0.6.0-stable
Dahlia Trimble 2008-10-11 00:30:27 +00:00
parent ab87a987f5
commit 09c8713801
1 changed files with 25 additions and 10 deletions

View File

@ -879,6 +879,10 @@ namespace PrimMesher
else if (this.sides == 24 && this.hollowSides == 4)
hollow *= 1.414f;
bool hasProfileCut = false;
if (profileStart < 0.0 || profileEnd < 1.0)
hasProfileCut = true;
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true);
if (initialProfileRot != 0.0f)
@ -927,9 +931,16 @@ namespace PrimMesher
int numVerts = newLayer.coords.Count;
Face newFace = new Face();
if (step > 0)
{
for (int i = coordsLen; i < this.coords.Count - 1; i++)
int startVert = coordsLen + 1;
int endVert = this.coords.Count - 1;
if (hasProfileCut || hollow > 0.0f)
startVert--;
for (int i = startVert; i < endVert; i++)
{
newFace.v1 = i;
newFace.v2 = i - numVerts;
@ -941,6 +952,8 @@ namespace PrimMesher
this.faces.Add(newFace);
}
if (hasProfileCut)
{
newFace.v1 = coordsLen - 1;
newFace.v2 = coordsLen - numVerts;
newFace.v3 = coordsLen;
@ -952,6 +965,8 @@ namespace PrimMesher
this.faces.Add(newFace);
}
}
// calc the step for the next iteration of the loop
if (step < steps)
@ -1173,7 +1188,7 @@ namespace PrimMesher
public Coord SurfaceNormal(int faceIndex)
{
//int numFaces = faces.Count;
int numFaces = faces.Count;
if (faceIndex < 0 || faceIndex >= faces.Count)
return new Coord(0.0f, 0.0f, 0.0f);