disallow duplicated vertices and cleanup some bagels

This commit is contained in:
benfry
2004-07-13 03:20:16 +00:00
parent de8fd575bf
commit 91c79ecaad
4 changed files with 122 additions and 34 deletions

View File

@@ -128,7 +128,27 @@ public class PPolygon implements PConstants {
sp = new float[vertices.length];
sdp = new float[vertices.length];
}
return vertices[vertexCount++];
return vertices[vertexCount++]; // returns v[0], sets vc to 1
}
/**
* Return true if this vertex is redundant. If so, will also
* decrement the vertex count.
*/
public boolean redundantVertex(float x, float y, float z) {
// because vertexCount will be 2 when setting vertex[1]
if (vertexCount < 2) return false;
// vertexCount-1 is the current vertex that would be used
// vertexCount-2 would be the previous feller
if ((Math.abs(vertices[vertexCount-2][MX] - x) < 0.0001f) &&
(Math.abs(vertices[vertexCount-2][MY] - y) < 0.0001f) &&
(Math.abs(vertices[vertexCount-2][MZ] - z) < 0.0001f)) {
vertexCount--;
return true;
}
return false;
}