mirror of
https://github.com/processing/processing4.git
synced 2026-02-11 09:39:19 +01:00
disallow duplicated vertices and cleanup some bagels
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user