3
3
/*
4
4
Part of the Processing project - http://processing.org
5
5
6
- Copyright (c) 2012-16 The Processing Foundation
6
+ Copyright (c) 2012-15 The Processing Foundation
7
7
Copyright (c) 2004-12 Ben Fry and Casey Reas
8
8
Copyright (c) 2001-04 Massachusetts Institute of Technology
9
9
@@ -1761,10 +1761,11 @@ public void setAttrib(String name, int index, float... values) {
1761
1761
return ;
1762
1762
}
1763
1763
1764
- VertexAttribute attrib = polyAttribs .get (name );
1764
+ VertexAttribute attrib = attribImpl (name , VertexAttribute .OTHER , PGL .FLOAT ,
1765
+ values .length );
1765
1766
float [] array = inGeo .fattribs .get (name );
1766
1767
for (int i = 0 ; i < values .length ; i ++) {
1767
- array [attrib .size * index + 0 ] = values [i ];
1768
+ array [attrib .size * index + i ] = values [i ];
1768
1769
}
1769
1770
markForTessellation ();
1770
1771
}
@@ -1777,10 +1778,11 @@ public void setAttrib(String name, int index, int... values) {
1777
1778
return ;
1778
1779
}
1779
1780
1780
- VertexAttribute attrib = polyAttribs .get (name );
1781
+ VertexAttribute attrib = attribImpl (name , VertexAttribute .OTHER , PGL .INT ,
1782
+ values .length );
1781
1783
int [] array = inGeo .iattribs .get (name );
1782
1784
for (int i = 0 ; i < values .length ; i ++) {
1783
- array [attrib .size * index + 0 ] = values [i ];
1785
+ array [attrib .size * index + i ] = values [i ];
1784
1786
}
1785
1787
markForTessellation ();
1786
1788
}
@@ -1793,10 +1795,11 @@ public void setAttrib(String name, int index, boolean... values) {
1793
1795
return ;
1794
1796
}
1795
1797
1796
- VertexAttribute attrib = polyAttribs .get (name );
1798
+ VertexAttribute attrib = attribImpl (name , VertexAttribute .OTHER , PGL .BOOL ,
1799
+ values .length );
1797
1800
byte [] array = inGeo .battribs .get (name );
1798
1801
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 );
1800
1803
}
1801
1804
markForTessellation ();
1802
1805
}
@@ -2828,15 +2831,21 @@ protected void initModified() {
2828
2831
2829
2832
protected void tessellate () {
2830
2833
if (root == this && parent == null ) { // Root shape
2834
+ boolean initAttr = false ;
2831
2835
if (polyAttribs == null ) {
2832
2836
polyAttribs = PGraphicsOpenGL .newAttributeMap ();
2833
- collectPolyAttribs () ;
2837
+ initAttr = true ;
2834
2838
}
2835
2839
2836
2840
if (tessGeo == null ) {
2837
2841
tessGeo = PGraphicsOpenGL .newTessGeometry (pg , polyAttribs , PGraphicsOpenGL .RETAINED );
2838
2842
}
2839
2843
tessGeo .clear ();
2844
+
2845
+ if (initAttr ) {
2846
+ collectPolyAttribs ();
2847
+ }
2848
+
2840
2849
for (int i = 0 ; i < polyAttribs .size (); i ++) {
2841
2850
VertexAttribute attrib = polyAttribs .get (i );
2842
2851
tessGeo .initAttrib (attrib );
@@ -2854,6 +2863,7 @@ protected void tessellate() {
2854
2863
2855
2864
protected void collectPolyAttribs () {
2856
2865
AttributeMap rootAttribs = root .polyAttribs ;
2866
+ tessGeo = root .tessGeo ;
2857
2867
2858
2868
if (family == GROUP ) {
2859
2869
for (int i = 0 ; i < childCount ; i ++) {
0 commit comments