From 60ec10bf53fc3d45231d0fb744bb184a43b67881 Mon Sep 17 00:00:00 2001 From: Ben Fry Date: Sun, 16 Nov 2014 10:12:31 -0700 Subject: [PATCH] fix is3D/set3D mixup, add getVertexCount() warning --- build/shared/revisions.txt | 12 ++++++++++-- core/src/processing/core/PGraphicsJava2D.java | 4 ++-- core/src/processing/core/PShape.java | 11 ++++++++++- core/src/processing/opengl/PGraphics2D.java | 4 ++-- core/src/processing/opengl/PGraphics3D.java | 4 ++-- core/todo.txt | 4 ++++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/build/shared/revisions.txt b/build/shared/revisions.txt index 6387798ef..28d565493 100644 --- a/build/shared/revisions.txt +++ b/build/shared/revisions.txt @@ -6,12 +6,12 @@ and incorporating various pull requests. [ changes ] -+ Removed the sound library, it's now available as its own library ++ Removed the sound library. It's now available as its own library from the Library Manager. + Change how languages are loaded, adding a local override. -+ Update to use JRE/JDK 7u72 . ++ Update to use JRE/JDK 7u72 + Implement the active() method for Serial and Server https://github.com/processing/processing/issues/2364 @@ -34,6 +34,10 @@ and incorporating various pull requests. + Support "header" option with ODS files ++ Show a warning when calling getVertexCount() on GROUP or PRIMITIVE shapes + https://github.com/processing/processing/issues/2873 + https://github.com/processing/processing-docs/issues/167 + [ bug fixes ] @@ -152,6 +156,10 @@ and incorporating various pull requests. https://github.com/processing/processing/issues/2576 https://github.com/processing/processing/pull/2922 ++ 'return' keyword not treated as such when followed by a bracket + https://github.com/processing/processing/issues/2099 + https://github.com/processing/processing/pull/2958 + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . diff --git a/core/src/processing/core/PGraphicsJava2D.java b/core/src/processing/core/PGraphicsJava2D.java index 4c7fb35e8..0bef72841 100644 --- a/core/src/processing/core/PGraphicsJava2D.java +++ b/core/src/processing/core/PGraphicsJava2D.java @@ -513,7 +513,7 @@ public class PGraphicsJava2D extends PGraphics { } else if (type == PShape.GEOMETRY) { shape = new PShape(pg, PShape.GEOMETRY); } - shape.is3D(false); + shape.set3D(false); return shape; } @@ -584,7 +584,7 @@ public class PGraphicsJava2D extends PGraphics { shape.setParams(p); } - shape.is3D(false); + shape.set3D(false); return shape; } diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index 9aae40799..a51275c59 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -112,6 +112,9 @@ public class PShape implements PConstants { public static final String NO_SUCH_VERTEX_ERROR = "%1$s vertex index does not exist"; + static public final String NO_VERTICES_ERROR = + "getVertexCount() only works with PATH or GEOMETRY shapes"; + // boundary box of this shape //protected float x; //protected float y; @@ -539,7 +542,7 @@ public class PShape implements PConstants { } - public void is3D(boolean val) { + public void set3D(boolean val) { is3D = val; } @@ -2051,6 +2054,9 @@ public class PShape implements PConstants { * @see PShape#setVertex(int, float, float) */ public int getVertexCount() { + if (family == GROUP || family == PRIMITIVE) { + PGraphics.showWarning(NO_VERTICES_ERROR); + } return vertexCount; } @@ -2100,6 +2106,7 @@ public class PShape implements PConstants { return vertices[index][Z]; } + /** * @webref pshape:method * @brief Sets the vertex at the index position @@ -2119,6 +2126,7 @@ public class PShape implements PConstants { vertices[index][Y] = y; } + /** * @param z the z value for the vertex */ @@ -2133,6 +2141,7 @@ public class PShape implements PConstants { vertices[index][Z] = z; } + /** * @param vec the PVector to define the x, y, z coordinates */ diff --git a/core/src/processing/opengl/PGraphics2D.java b/core/src/processing/opengl/PGraphics2D.java index b3fc4e890..1812c111e 100644 --- a/core/src/processing/opengl/PGraphics2D.java +++ b/core/src/processing/opengl/PGraphics2D.java @@ -308,7 +308,7 @@ public class PGraphics2D extends PGraphicsOpenGL { } else if (type == PShape.GEOMETRY) { shape = new PShapeOpenGL(pg, PShape.GEOMETRY); } - shape.is3D(false); + shape.set3D(false); return shape; } @@ -379,7 +379,7 @@ public class PGraphics2D extends PGraphicsOpenGL { shape.setParams(p); } - shape.is3D(false); + shape.set3D(false); return shape; } diff --git a/core/src/processing/opengl/PGraphics3D.java b/core/src/processing/opengl/PGraphics3D.java index 77edcc9f0..c37941c78 100644 --- a/core/src/processing/opengl/PGraphics3D.java +++ b/core/src/processing/opengl/PGraphics3D.java @@ -191,7 +191,7 @@ public class PGraphics3D extends PGraphicsOpenGL { } else if (type == PShape.GEOMETRY) { shape = new PShapeOpenGL(pg, PShape.GEOMETRY); } - shape.is3D(true); + shape.set3D(true); return shape; } @@ -272,7 +272,7 @@ public class PGraphics3D extends PGraphicsOpenGL { shape.setParams(p); } - shape.is3D(true); + shape.set3D(true); return shape; } } \ No newline at end of file diff --git a/core/todo.txt b/core/todo.txt index 3f4072f98..7074d7c9f 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -1,6 +1,10 @@ 0232 core (3.0a5) X detect CMYK JPEG images and return null X https://community.oracle.com/thread/1272045?start=0&tstart=0 +X show a warning when calling getVertexCount() on GROUP or PRIMITIVE shapes +X https://github.com/processing/processing/issues/2873 +X https://github.com/processing/processing-docs/issues/167 +X replace is3D(boolean) with set3D() data X fix XML.getString() with a default when no attrs are present at all