Skip to content

Commit 77721fa

Browse files
committed
ported attribute handling fixes from java mode
1 parent f122b52 commit 77721fa

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

core/src/processing/opengl/PShapeOpenGL.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Part of the Processing project - http://processing.org
55
6-
Copyright (c) 2012-16 The Processing Foundation
6+
Copyright (c) 2012-15 The Processing Foundation
77
Copyright (c) 2004-12 Ben Fry and Casey Reas
88
Copyright (c) 2001-04 Massachusetts Institute of Technology
99
@@ -1761,10 +1761,11 @@ public void setAttrib(String name, int index, float... values) {
17611761
return;
17621762
}
17631763

1764-
VertexAttribute attrib = polyAttribs.get(name);
1764+
VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.FLOAT,
1765+
values.length);
17651766
float[] array = inGeo.fattribs.get(name);
17661767
for (int i = 0; i < values.length; i++) {
1767-
array[attrib.size * index + 0] = values[i];
1768+
array[attrib.size * index + i] = values[i];
17681769
}
17691770
markForTessellation();
17701771
}
@@ -1777,10 +1778,11 @@ public void setAttrib(String name, int index, int... values) {
17771778
return;
17781779
}
17791780

1780-
VertexAttribute attrib = polyAttribs.get(name);
1781+
VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.INT,
1782+
values.length);
17811783
int[] array = inGeo.iattribs.get(name);
17821784
for (int i = 0; i < values.length; i++) {
1783-
array[attrib.size * index + 0] = values[i];
1785+
array[attrib.size * index + i] = values[i];
17841786
}
17851787
markForTessellation();
17861788
}
@@ -1793,10 +1795,11 @@ public void setAttrib(String name, int index, boolean... values) {
17931795
return;
17941796
}
17951797

1796-
VertexAttribute attrib = polyAttribs.get(name);
1798+
VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.BOOL,
1799+
values.length);
17971800
byte[] array = inGeo.battribs.get(name);
17981801
for (int i = 0; i < values.length; i++) {
1799-
array[attrib.size * index + 0] = (byte)(values[i]?1:0);
1802+
array[attrib.size * index + i] = (byte)(values[i]?1:0);
18001803
}
18011804
markForTessellation();
18021805
}
@@ -2828,15 +2831,21 @@ protected void initModified() {
28282831

28292832
protected void tessellate() {
28302833
if (root == this && parent == null) { // Root shape
2834+
boolean initAttr = false;
28312835
if (polyAttribs == null) {
28322836
polyAttribs = PGraphicsOpenGL.newAttributeMap();
2833-
collectPolyAttribs();
2837+
initAttr = true;
28342838
}
28352839

28362840
if (tessGeo == null) {
28372841
tessGeo = PGraphicsOpenGL.newTessGeometry(pg, polyAttribs, PGraphicsOpenGL.RETAINED);
28382842
}
28392843
tessGeo.clear();
2844+
2845+
if (initAttr) {
2846+
collectPolyAttribs();
2847+
}
2848+
28402849
for (int i = 0; i < polyAttribs.size(); i++) {
28412850
VertexAttribute attrib = polyAttribs.get(i);
28422851
tessGeo.initAttrib(attrib);
@@ -2854,6 +2863,7 @@ protected void tessellate() {
28542863

28552864
protected void collectPolyAttribs() {
28562865
AttributeMap rootAttribs = root.polyAttribs;
2866+
tessGeo = root.tessGeo;
28572867

28582868
if (family == GROUP) {
28592869
for (int i = 0; i < childCount; i++) {

0 commit comments

Comments
 (0)