From 7450a790e64f1109669e9d83c098347c6e8fc98c Mon Sep 17 00:00:00 2001 From: codeanticode Date: Wed, 30 May 2012 15:50:07 +0000 Subject: [PATCH] ignore bevel triangles in raw output of lines --- .../src/processing/opengl/PGraphicsOpenGL.java | 12 +++++++----- .../opengl/src/processing/opengl/PShapeOpenGL.java | 10 +++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java index 59506f671..e30f196b1 100644 --- a/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PGraphicsOpenGL.java @@ -2542,21 +2542,23 @@ public class PGraphicsOpenGL extends PGraphics { int icount = cache.indexCount[n]; int voffset = cache.vertexOffset[n]; - // TODO: fix this, as it doesn't consider the vertices now taken up - // by the bevel joins. for (int ln = ioffset / 6; ln < (ioffset + icount) / 6; ln++) { // Each line segment is defined by six indices since its // formed by two triangles. We only need the first and last - // vertices. + // vertices. + // This bunch of vertices could also be the bevel triangles, + // with we detect this situation by looking at the line weight. int i0 = voffset + indices[6 * ln + 0]; int i1 = voffset + indices[6 * ln + 5]; + float sw0 = 2 * attribs[4 * i0 + 3]; + float sw1 = 2 * attribs[4 * i1 + 3]; + if (zero(sw0)) continue; // Bevel triangles, skip. + float[] pt0 = {0, 0, 0, 0}; float[] pt1 = {0, 0, 0, 0}; int argb0 = PGL.nativeToJavaARGB(color[i0]); int argb1 = PGL.nativeToJavaARGB(color[i1]); - float sw0 = 2 * attribs[4 * i0 + 3]; - float sw1 = 2 * attribs[4 * i1 + 3]; if (flushMode == FLUSH_CONTINUOUSLY || hints[DISABLE_TRANSFORM_CACHE]) { float[] src0 = {0, 0, 0, 0}; diff --git a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java index 04ee14435..4fb73bc9b 100644 --- a/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java +++ b/java/libraries/opengl/src/processing/opengl/PShapeOpenGL.java @@ -4088,8 +4088,14 @@ public class PShapeOpenGL extends PShape { // Each line segment is defined by six indices since its // formed by two triangles. We only need the first and last // vertices. + // This bunch of vertices could also be the bevel triangles, + // with we detect this situation by looking at the line weight. int i0 = voffset + indices[6 * ln + 0]; int i1 = voffset + indices[6 * ln + 5]; + float sw0 = 2 * attribs[4 * i0 + 3]; + float sw1 = 2 * attribs[4 * i1 + 3]; + + if (PGraphicsOpenGL.zero(sw0)) continue; // Bevel triangles, skip. float[] src0 = {0, 0, 0, 0}; float[] src1 = {0, 0, 0, 0}; @@ -4097,9 +4103,7 @@ public class PShapeOpenGL extends PShape { float[] pt1 = {0, 0, 0, 0}; int argb0 = PGL.nativeToJavaARGB(color[i0]); int argb1 = PGL.nativeToJavaARGB(color[i1]); - float sw0 = 2 * attribs[4 * i0 + 3]; - float sw1 = 2 * attribs[4 * i1 + 3]; - + PApplet.arrayCopy(vertices, 4 * i0, src0, 0, 4); PApplet.arrayCopy(vertices, 4 * i1, src1, 0, 4); // Applying any transformation is currently stored in the