From 43acb69c49cbb83d0712cf4722213882a8f6ceee Mon Sep 17 00:00:00 2001 From: Jakub Valtar Date: Mon, 3 Aug 2015 18:00:08 -0400 Subject: [PATCH] Fix setVertex for PATH PShapeOpenGL --- core/src/processing/core/PShape.java | 3 +++ core/src/processing/opengl/PShapeOpenGL.java | 17 ++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index 768553079..a9b28eaa9 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -115,6 +115,9 @@ public class PShape implements PConstants { static public final String NO_VERTICES_ERROR = "getVertexCount() only works with PATH or GEOMETRY shapes"; + public static final String NOT_A_SIMPLE_VERTEX = + "%1$s can not be called on quadratic or bezier vertices"; + // boundary box of this shape //protected float x; //protected float y; diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index 3ddead7ce..6cfdb1008 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -1708,14 +1708,25 @@ public class PShapeOpenGL extends PShape { return; } + if (vertexCodes[index] != VERTEX) { + PGraphics.showWarning(NOT_A_SIMPLE_VERTEX, "setVertex()"); + return; + } + // TODO: in certain cases (kind = TRIANGLE, etc) the correspondence between // input and tessellated vertices is 1-1, so in those cases re-tessellation // wouldn't be necessary. But in order to reasonable take care of that // situation, we would need a complete rethinking of the rendering architecture // in Processing :-) - inGeo.vertices[3 * index + 0] = x; - inGeo.vertices[3 * index + 1] = y; - inGeo.vertices[3 * index + 2] = z; + if (family == PATH) { + vertices[index][X] = x; + vertices[index][Y] = y; + if (is3D) vertices[index][Z] = z; + } else { + inGeo.vertices[3 * index + 0] = x; + inGeo.vertices[3 * index + 1] = y; + inGeo.vertices[3 * index + 2] = z; + } markForTessellation(); }