initialize attribs in right place

This commit is contained in:
codeanticode
2015-05-24 09:40:29 -04:00
parent 55fee051a8
commit c7dc28b518
2 changed files with 8 additions and 12 deletions
@@ -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
+5 -8
View File
@@ -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;