From bb518933b09bfcddc59375d78bc484ab9c4e6980 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Tue, 3 Sep 2013 11:51:04 -0400 Subject: [PATCH] PShapeOpenGL uses close field from parent PShape, this takes care of #2035 --- core/src/processing/opengl/PGraphics2D.java | 29 ------------------ core/src/processing/opengl/PGraphics3D.java | 32 -------------------- core/src/processing/opengl/PShapeOpenGL.java | 19 +++++------- 3 files changed, 8 insertions(+), 72 deletions(-) diff --git a/core/src/processing/opengl/PGraphics2D.java b/core/src/processing/opengl/PGraphics2D.java index dd4089dca..f1149ab65 100644 --- a/core/src/processing/opengl/PGraphics2D.java +++ b/core/src/processing/opengl/PGraphics2D.java @@ -307,35 +307,6 @@ public class PGraphics2D extends PGraphicsOpenGL { } else if (type == PShape.GEOMETRY) { shape = new PShapeOpenGL(parent, PShape.GEOMETRY); } - - /* - if (type == POINTS) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(POINTS); - } else if (type == LINES) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(LINES); - } else if (type == TRIANGLE || type == TRIANGLES) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(TRIANGLES); - } else if (type == TRIANGLE_FAN) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(TRIANGLE_FAN); - } else if (type == TRIANGLE_STRIP) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(TRIANGLE_STRIP); - } else if (type == QUAD || type == QUADS) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(QUADS); - } else if (type == QUAD_STRIP) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(QUAD_STRIP); - } else if (type == POLYGON) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(POLYGON); - } - */ - shape.is3D(false); return shape; } diff --git a/core/src/processing/opengl/PGraphics3D.java b/core/src/processing/opengl/PGraphics3D.java index a60641dac..c2d78474a 100644 --- a/core/src/processing/opengl/PGraphics3D.java +++ b/core/src/processing/opengl/PGraphics3D.java @@ -178,38 +178,6 @@ public class PGraphics3D extends PGraphicsOpenGL { } else if (type == PShape.GEOMETRY) { shape = new PShapeOpenGL(parent, PShape.GEOMETRY); } - - /* - (type == POINTS) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - - shape.setKind(POINTS); - } else if (type == LINES) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - - shape.setKind(LINES); - } else if (type == TRIANGLE || type == TRIANGLES) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - - shape.setKind(TRIANGLES); - } else if (type == TRIANGLE_FAN) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(TRIANGLE_FAN); - } else if (type == TRIANGLE_STRIP) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(TRIANGLE_STRIP); - } else if (type == QUAD || type == QUADS) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(QUADS); - } else if (type == QUAD_STRIP) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(QUAD_STRIP); - } else if (type == POLYGON) { - shape = new PShapeOpenGL(parent, PShape.GEOMETRY); - shape.setKind(POLYGON); - } - */ - shape.is3D(true); return shape; } diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index e0fde4a2c..3d666cf28 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -162,12 +162,9 @@ public class PShapeOpenGL extends PShape { protected boolean tessellated; protected boolean needBufferInit = false; -// protected boolean polyBuffersCreated = false; -// protected boolean lineBuffersCreated = false; -// protected boolean pointBuffersCreated = false; - protected boolean isSolid; - protected boolean isClosed; + // Flag to indicate if the shape can have holes or not. + protected boolean solid; protected boolean breakShape = false; protected boolean shapeCreated = false; @@ -951,7 +948,7 @@ public class PShapeOpenGL extends PShape { child.solid(solid); } } else { - isSolid = solid; + this.solid = solid; } } @@ -1090,7 +1087,7 @@ public class PShapeOpenGL extends PShape { // size, which might lead to arrays larger than the vertex counts. inGeo.trim(); - isClosed = mode == CLOSE; + close = mode == CLOSE; markForTessellation(); shapeCreated = true; } @@ -2531,8 +2528,8 @@ public class PShapeOpenGL extends PShape { if (normalMode == NORMAL_MODE_AUTO) inGeo.calcQuadStripNormals(); tessellator.tessellateQuadStrip(); } else if (kind == POLYGON) { - if (stroke) inGeo.addPolygonEdges(isClosed); - tessellator.tessellatePolygon(isSolid, isClosed, + if (stroke) inGeo.addPolygonEdges(close); + tessellator.tessellatePolygon(solid, close, normalMode == NORMAL_MODE_AUTO); } } else if (family == PRIMITIVE) { @@ -2924,8 +2921,8 @@ public class PShapeOpenGL extends PShape { } } - if (stroke) inGeo.addPolygonEdges(isClosed); - tessellator.tessellatePolygon(false, isClosed, true); + if (stroke) inGeo.addPolygonEdges(close); + tessellator.tessellatePolygon(false, close, true); }