From f498bbdcde129d5a6bf2824821c511ae8a3a04e7 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 24 May 2012 15:46:04 +0000 Subject: [PATCH] taking care of empty groups in PShapeOpenGL, some additional methods --- core/src/processing/core/PGraphics.java | 17 ++++++- core/src/processing/core/PShape.java | 22 ++++++++ .../src/processing/opengl/PShapeOpenGL.java | 51 ++++++++++++++++--- 3 files changed, 81 insertions(+), 9 deletions(-) diff --git a/core/src/processing/core/PGraphics.java b/core/src/processing/core/PGraphics.java index 402f46934..e4098b6dd 100644 --- a/core/src/processing/core/PGraphics.java +++ b/core/src/processing/core/PGraphics.java @@ -544,6 +544,8 @@ public class PGraphics extends PImage implements PConstants { * based on the IMAGE or NORMALIZED. */ public int textureMode; + + public int textureWrap; /** * Current horizontal coordinate for texture, will always @@ -1063,7 +1065,20 @@ public class PGraphics extends PImage implements PConstants { this.textureMode = mode; } - + + // TODO: use this setting in GL renderer. + public void textureWrap(int wrap) { + this.textureWrap = wrap; + } + + + // TODO: do we need something like this to choose between + // point, linear and trilinear texture sampling? + //public void textureQualityt(int quality) { + // this.textureQuality = quality; + //} + + /** * ( begin auto-generated from texture.xml ) * diff --git a/core/src/processing/core/PShape.java b/core/src/processing/core/PShape.java index ea4d808fd..ef78d67c2 100644 --- a/core/src/processing/core/PShape.java +++ b/core/src/processing/core/PShape.java @@ -396,6 +396,28 @@ public class PShape implements PConstants { return depth; } + + + // TODO: need to discuss about these two (four). + public PVector getTop() { + return getTop(null); + } + + + public PVector getTop(PVector top) { + return top; + } + + + public PVector getBottom() { + return getBottom(null); + } + + + public PVector getBottom(PVector bottom) { + return bottom; + } + /** * Return true if this shape is 2D. Defaults to true. diff --git a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java index 3078edd80..4069925f3 100644 --- a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java @@ -534,6 +534,26 @@ public class PShapeOpenGL extends PShape { } + public PVector getTop(PVector top) { + if (top == null) { + top = new PVector(); + } + top.set(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY); + getVertexMin(top); + return top; + } + + + public PVector getBottom(PVector bottom) { + if (bottom == null) { + bottom = new PVector(); + } + bottom.set(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY); + getVertexMax(bottom); + return bottom; + } + + protected void getVertexMin(PVector min) { updateTessellation(); @@ -3266,7 +3286,7 @@ public class PShapeOpenGL extends PShape { firstPolyIndexCache = lastPolyIndexCache = -1; int gindex = -1; - + for (int i = 0; i < childCount; i++) { PShapeOpenGL child = (PShapeOpenGL) children[i]; @@ -3291,8 +3311,13 @@ public class PShapeOpenGL extends PShape { } // Updating the first and last poly vertices for this group shape. - if (i == 0) firstPolyVertex = child.firstPolyVertex; - if (i == childCount - 1) lastPolyVertex = child.lastPolyVertex; + if (-1 < child.firstPolyVertex) { + if (firstPolyVertex == -1) firstPolyVertex = Integer.MAX_VALUE; + firstPolyVertex = PApplet.min(firstPolyVertex, child.firstPolyVertex); + } + if (-1 < child.lastPolyVertex) { + lastPolyVertex = PApplet.max(lastPolyVertex, child.lastPolyVertex); + } } lastPolyIndexCache = gindex; } else { @@ -3387,8 +3412,13 @@ public class PShapeOpenGL extends PShape { } // Updating the first and last line vertices for this group shape. - if (i == 0) firstLineVertex = child.firstLineVertex; - if (i == childCount - 1) lastLineVertex = child.lastLineVertex; + if (-1 < child.firstLineVertex) { + if (firstLineVertex == -1) firstLineVertex = Integer.MAX_VALUE; + firstLineVertex = PApplet.min(firstLineVertex, child.firstLineVertex); + } + if (-1 < child.lastLineVertex) { + lastLineVertex = PApplet.max(lastLineVertex, child.lastLineVertex); + } } lastLineIndexCache = gindex; } else { @@ -3444,9 +3474,14 @@ public class PShapeOpenGL extends PShape { } } - // Updating the first and last point vertices for this group shape. - if (i == 0) firstPointVertex = child.firstPointVertex; - if (i == childCount - 1) lastPointVertex = child.lastPointVertex; + // Updating the first and last point vertices for this group shape. + if (-1 < child.firstPointVertex) { + if (firstPointVertex == -1) firstPointVertex = Integer.MAX_VALUE; + firstPointVertex = PApplet.min(firstPointVertex, child.firstPointVertex); + } + if (-1 < child.lastPointVertex) { + lastPointVertex = PApplet.max(lastPointVertex, child.lastPointVertex); + } } lastPointIndexCache = gindex; } else {