diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index b9a2bf921..ea889ef48 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -9068,15 +9068,15 @@ public class PGraphicsOpenGL extends PGraphics { } void initAttrib(VertexAttribute attrib) { - if (attrib.type == PGL.FLOAT) { + if (attrib.type == PGL.FLOAT && !fpolyAttribs.containsKey(attrib.name)) { float[] temp = new float[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; fpolyAttribs.put(attrib.name, temp); polyAttribBuffers.put(attrib.name, PGL.allocateFloatBuffer(temp)); - } else if (attrib.type == PGL.INT) { + } else if (attrib.type == PGL.INT && !ipolyAttribs.containsKey(attrib.name)) { int[] temp = new int[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; ipolyAttribs.put(attrib.name, temp); polyAttribBuffers.put(attrib.name, PGL.allocateIntBuffer(temp)); - } else if (attrib.type == PGL.BOOL) { + } else if (attrib.type == PGL.BOOL && !bpolyAttribs.containsKey(attrib.name)) { byte[] temp = new byte[attrib.tessSize * PGL.DEFAULT_TESS_VERTICES]; bpolyAttribs.put(attrib.name, temp); polyAttribBuffers.put(attrib.name, PGL.allocateByteBuffer(temp)); @@ -13116,7 +13116,6 @@ public class PGraphicsOpenGL extends PGraphics { vertex[0] = coords[0]; vertex[1] = coords[1]; vertex[2] = coords[2]; - System.out.println("combine: " + n); // Calculating the rest of the vertex parameters (color, // normal, texcoords) as the linear combination of the diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index 07fc7ae6c..a3c3200af 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -1182,7 +1182,6 @@ public class PShapeOpenGL extends PShape { attrib = new VertexAttribute(name, type, size); polyAttribs.put(name, attrib); inGeo.initAttrib(attrib); - tessGeo.initAttrib(attrib); } if (attrib.size != size) { PGraphics.showWarning("New value for vertex attribute has wrong number of values"); @@ -2794,6 +2793,10 @@ public class PShapeOpenGL extends PShape { tessGeo = PGraphicsOpenGL.newTessGeometry(pg, polyAttribs, PGraphicsOpenGL.RETAINED); } tessGeo.clear(); + for (int i = 0; i < polyAttribs.size(); i++) { + VertexAttribute attrib = polyAttribs.get(i); + tessGeo.initAttrib(attrib); + } tessellateImpl(); @@ -4542,14 +4545,8 @@ public class PShapeOpenGL extends PShape { modified = true; } - protected void setModifiedPolyAttrib(VertexAttribute attrib, int first, int last) { - if (first < attrib.firstModified) attrib.firstModified = first; - if (last > attrib.lastModified) attrib.lastModified = last; - attrib.modified = true; - modified = true; - } - protected void setModifiedPolyAttribs(VertexAttribute attrib, int first, int last) { + protected void setModifiedPolyAttrib(VertexAttribute attrib, int first, int last) { if (first < attrib.firstModified) attrib.firstModified = first; if (last > attrib.lastModified) attrib.lastModified = last; attrib.modified = true;