propane 3.5.0-java → 3.9.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
  4. data/.mvn/wrapper/maven-wrapper.properties +2 -2
  5. data/.travis.yml +1 -1
  6. data/CHANGELOG.md +7 -1
  7. data/README.md +7 -22
  8. data/Rakefile +3 -2
  9. data/lib/propane.rb +2 -1
  10. data/lib/propane/app.rb +4 -0
  11. data/lib/propane/helper_methods.rb +0 -1
  12. data/lib/propane/runner.rb +12 -12
  13. data/lib/propane/version.rb +1 -1
  14. data/library/pdf/pdf.rb +7 -0
  15. data/library/svg/svg.rb +7 -0
  16. data/pom.rb +65 -43
  17. data/pom.xml +44 -5
  18. data/propane.gemspec +9 -4
  19. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  20. data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
  21. data/src/main/java/monkstone/fastmath/Deglut.java +6 -56
  22. data/src/main/java/monkstone/noise/FastTerrain.java +874 -0
  23. data/src/main/java/monkstone/noise/Noise.java +90 -0
  24. data/src/main/java/monkstone/noise/NoiseGenerator.java +75 -0
  25. data/src/main/java/monkstone/noise/NoiseMode.java +28 -0
  26. data/src/main/java/monkstone/noise/OpenSimplex2F.java +881 -0
  27. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1106 -0
  28. data/src/main/java/monkstone/noise/SmoothTerrain.java +1099 -0
  29. data/src/main/java/processing/awt/PGraphicsJava2D.java +8 -17
  30. data/src/main/java/processing/awt/PImageAWT.java +123 -6
  31. data/src/main/java/processing/awt/PShapeJava2D.java +1 -0
  32. data/src/main/java/processing/awt/PSurfaceAWT.java +9 -7
  33. data/src/main/java/processing/awt/ShimAWT.java +2 -1
  34. data/src/main/java/processing/core/PApplet.java +13297 -14838
  35. data/src/main/java/processing/core/PConstants.java +5 -5
  36. data/src/main/java/processing/core/PFont.java +5 -17
  37. data/src/main/java/processing/core/PGraphics.java +346 -351
  38. data/src/main/java/processing/core/PImage.java +1440 -1537
  39. data/src/main/java/processing/core/PMatrix2D.java +24 -7
  40. data/src/main/java/processing/core/PMatrix3D.java +12 -5
  41. data/src/main/java/processing/core/PShape.java +155 -173
  42. data/src/main/java/processing/core/PShapeOBJ.java +2 -0
  43. data/src/main/java/processing/core/PShapeSVG.java +632 -611
  44. data/src/main/java/processing/core/PSurface.java +15 -10
  45. data/src/main/java/processing/core/PSurfaceNone.java +8 -4
  46. data/src/main/java/processing/core/PVector.java +35 -28
  47. data/src/main/java/processing/data/Table.java +20 -20
  48. data/src/main/java/processing/data/XML.java +1 -1
  49. data/src/main/java/processing/event/Event.java +1 -1
  50. data/src/main/java/processing/event/MouseEvent.java +7 -6
  51. data/src/main/java/processing/javafx/PGraphicsFX2D.java +20 -345
  52. data/src/main/java/processing/javafx/PSurfaceFX.java +127 -125
  53. data/src/main/java/processing/opengl/FrameBuffer.java +2 -4
  54. data/src/main/java/processing/opengl/LinePath.java +4 -0
  55. data/src/main/java/processing/opengl/LineStroker.java +2 -6
  56. data/src/main/java/processing/opengl/PGL.java +72 -45
  57. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +106 -60
  58. data/src/main/java/processing/opengl/PJOGL.java +15 -3
  59. data/src/main/java/processing/opengl/PShader.java +26 -47
  60. data/src/main/java/processing/opengl/PShapeOpenGL.java +1041 -1001
  61. data/src/main/java/processing/opengl/PSurfaceJOGL.java +211 -208
  62. data/src/main/java/processing/opengl/Texture.java +7 -4
  63. data/src/main/java/processing/opengl/VertexBuffer.java +2 -2
  64. data/src/main/java/processing/pdf/PGraphicsPDF.java +581 -0
  65. data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
  66. data/test/deglut_spec_test.rb +2 -2
  67. data/vendors/Rakefile +22 -33
  68. metadata +53 -21
  69. data/library/simplex_noise/simplex_noise.rb +0 -5
  70. data/src/main/java/monkstone/noise/SimplexNoise.java +0 -436
@@ -54,9 +54,12 @@ import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
54
54
  import com.jogamp.opengl.glu.GLU;
55
55
  import com.jogamp.opengl.glu.GLUtessellator;
56
56
  import com.jogamp.opengl.glu.GLUtessellatorCallbackAdapter;
57
+ import com.jogamp.opengl.util.awt.AWTGLReadBufferUtil;
57
58
 
59
+ import processing.awt.PImageAWT;
58
60
  import processing.core.PApplet;
59
61
  import processing.core.PGraphics;
62
+ import processing.core.PImage;
60
63
  import processing.core.PMatrix3D;
61
64
  import processing.core.PSurface;
62
65
 
@@ -148,6 +151,11 @@ public class PJOGL extends PGL {
148
151
  glu = new GLU();
149
152
  }
150
153
 
154
+ public PJOGL(PGraphicsOpenGL pg, PGL.RenderCallback callback) {
155
+ super(pg, callback);
156
+ glu = new GLU();
157
+ }
158
+
151
159
 
152
160
  @Override
153
161
  public Object getNative() {
@@ -171,6 +179,13 @@ public class PJOGL extends PGL {
171
179
  protected void registerListeners() {}
172
180
 
173
181
 
182
+ @Override
183
+ protected PImage screenshot() {
184
+ AWTGLReadBufferUtil util = new AWTGLReadBufferUtil(capabilities.getGLProfile(), false);
185
+ return new PImageAWT(util.readPixelsToBufferedImage​(gl, true));
186
+ }
187
+
188
+
174
189
  static public void setIcon(String... icons) {
175
190
  PJOGL.icons = new String[icons.length];
176
191
  PApplet.arrayCopy(icons, PJOGL.icons);
@@ -622,7 +637,6 @@ public class PJOGL extends PGL {
622
637
  setProperty(GLU.GLU_TESS_WINDING_RULE, rule);
623
638
  }
624
639
 
625
- @Override
626
640
  public void setProperty(int property, int value) {
627
641
  GLU.gluTessProperty(tess, property, value);
628
642
  }
@@ -1821,8 +1835,6 @@ public class PJOGL extends PGL {
1821
1835
  gl2.glBlendColor(red, green, blue, alpha);
1822
1836
  }
1823
1837
 
1824
- ///////////////////////////////////////////////////////////
1825
-
1826
1838
  // Whole Framebuffer Operations
1827
1839
 
1828
1840
  @Override
@@ -376,7 +376,6 @@ public class PShader implements PConstants {
376
376
 
377
377
  /**
378
378
  * Returns true if the shader is bound, false otherwise.
379
- * @return
380
379
  */
381
380
  public boolean bound() {
382
381
  return bound;
@@ -678,21 +677,14 @@ public class PShader implements PConstants {
678
677
  int length) {
679
678
  if (-1 < loc) {
680
679
  updateIntBuffer(vec);
681
- switch (ncoords) {
682
- case 1:
683
- pgl.uniform1iv(loc, length, intBuffer);
684
- break;
685
- case 2:
686
- pgl.uniform2iv(loc, length, intBuffer);
687
- break;
688
- case 3:
689
- pgl.uniform3iv(loc, length, intBuffer);
690
- break;
691
- case 4:
692
- pgl.uniform3iv(loc, length, intBuffer);
693
- break;
694
- default:
695
- break;
680
+ if (ncoords == 1) {
681
+ pgl.uniform1iv(loc, length, intBuffer);
682
+ } else if (ncoords == 2) {
683
+ pgl.uniform2iv(loc, length, intBuffer);
684
+ } else if (ncoords == 3) {
685
+ pgl.uniform3iv(loc, length, intBuffer);
686
+ } else if (ncoords == 4) {
687
+ pgl.uniform3iv(loc, length, intBuffer);
696
688
  }
697
689
  }
698
690
  }
@@ -702,21 +694,14 @@ public class PShader implements PConstants {
702
694
  int length) {
703
695
  if (-1 < loc) {
704
696
  updateFloatBuffer(vec);
705
- switch (ncoords) {
706
- case 1:
707
- pgl.uniform1fv(loc, length, floatBuffer);
708
- break;
709
- case 2:
710
- pgl.uniform2fv(loc, length, floatBuffer);
711
- break;
712
- case 3:
713
- pgl.uniform3fv(loc, length, floatBuffer);
714
- break;
715
- case 4:
716
- pgl.uniform4fv(loc, length, floatBuffer);
717
- break;
718
- default:
719
- break;
697
+ if (ncoords == 1) {
698
+ pgl.uniform1fv(loc, length, floatBuffer);
699
+ } else if (ncoords == 2) {
700
+ pgl.uniform2fv(loc, length, floatBuffer);
701
+ } else if (ncoords == 3) {
702
+ pgl.uniform3fv(loc, length, floatBuffer);
703
+ } else if (ncoords == 4) {
704
+ pgl.uniform4fv(loc, length, floatBuffer);
720
705
  }
721
706
  }
722
707
  }
@@ -725,18 +710,12 @@ public class PShader implements PConstants {
725
710
  protected void setUniformMatrix(int loc, float[] mat) {
726
711
  if (-1 < loc) {
727
712
  updateFloatBuffer(mat);
728
- switch (mat.length) {
729
- case 4:
730
- pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
731
- break;
732
- case 9:
733
- pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
734
- break;
735
- case 16:
736
- pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
737
- break;
738
- default:
739
- break;
713
+ if (mat.length == 4) {
714
+ pgl.uniformMatrix2fv(loc, 1, false, floatBuffer);
715
+ } else if (mat.length == 9) {
716
+ pgl.uniformMatrix3fv(loc, 1, false, floatBuffer);
717
+ } else if (mat.length == 16) {
718
+ pgl.uniformMatrix4fv(loc, 1, false, floatBuffer);
740
719
  }
741
720
  }
742
721
  }
@@ -850,7 +829,7 @@ public class PShader implements PConstants {
850
829
  if (textures == null) textures = new HashMap<>();
851
830
  textures.put(loc, tex);
852
831
 
853
- if (texUnits == null) texUnits = new HashMap<>();
832
+ if (texUnits == null) texUnits = new HashMap<Integer, Integer>();
854
833
  if (texUnits.containsKey(loc)) {
855
834
  unit = texUnits.get(loc);
856
835
  pgl.uniform1i(loc, unit);
@@ -878,7 +857,7 @@ public class PShader implements PConstants {
878
857
 
879
858
  protected void bindTextures() {
880
859
  if (textures != null && texUnits != null) {
881
- textures.keySet().forEach((loc) -> {
860
+ for (int loc: textures.keySet()) {
882
861
  Texture tex = textures.get(loc);
883
862
  Integer unit = texUnits.get(loc);
884
863
  if (unit != null) {
@@ -887,7 +866,7 @@ public class PShader implements PConstants {
887
866
  } else {
888
867
  throw new RuntimeException("Cannot find unit for texture " + tex);
889
868
  }
890
- });
869
+ }
891
870
  }
892
871
  }
893
872
 
@@ -997,7 +976,7 @@ public class PShader implements PConstants {
997
976
  pgl.compileShader(glVertex);
998
977
 
999
978
  pgl.getShaderiv(glVertex, PGL.COMPILE_STATUS, intBuffer);
1000
- boolean compiled = intBuffer.get(0) != 0;
979
+ boolean compiled = intBuffer.get(0) == 0 ? false : true;
1001
980
  if (!compiled) {
1002
981
  PGraphics.showException("Cannot compile vertex shader:\n" +
1003
982
  pgl.getShaderInfoLog(glVertex));
@@ -1,6 +1,6 @@
1
1
  /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
2
 
3
- /*
3
+ /*
4
4
  Part of the Processing project - http://processing.org
5
5
 
6
6
  Copyright (c) 2012-15 The Processing Foundation
@@ -20,7 +20,8 @@
20
20
  Public License along with this library; if not, write to the
21
21
  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
22
  Boston, MA 02111-1307 USA
23
- */
23
+ */
24
+
24
25
  package processing.opengl;
25
26
 
26
27
  import processing.core.PApplet;
@@ -44,33 +45,34 @@ import java.util.Arrays;
44
45
  import java.util.HashSet;
45
46
 
46
47
  /**
47
- * This class holds a 3D model composed of vertices, normals, colors (per
48
- * vertex) and texture coordinates (also per vertex). All this data is stored in
49
- * Vertex Buffer Objects (VBO) in GPU memory for very fast access. OBJ loading
50
- * implemented using code from Saito's OBJLoader library:
51
- * http://code.google.com/p/saitoobjloader/ and OBJReader from Ahmet Kizilay
52
- * http://www.openprocessing.org/visuals/?visualID=191 By Andres Colubri
48
+ * This class holds a 3D model composed of vertices, normals, colors
49
+ * (per vertex) and texture coordinates (also per vertex). All this data is
50
+ * stored in Vertex Buffer Objects (VBO) in GPU memory for very fast access.
51
+ * OBJ loading implemented using code from Saito's OBJLoader library:
52
+ * http://code.google.com/p/saitoobjloader/
53
+ * and OBJReader from Ahmet Kizilay
54
+ * http://www.openprocessing.org/visuals/?visualID=191
55
+ * By Andres Colubri
53
56
  *
54
57
  *
55
- * Other formats to consider: AMF:
56
- * http://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format STL:
57
- * http://en.wikipedia.org/wiki/STL_(file_format) OFF:
58
- * http://people.sc.fsu.edu/~jburkardt/data/off/off.html(file_format) DXF:
59
- * http://en.wikipedia.org/wiki/AutoCAD_DXF
58
+ * Other formats to consider:
59
+ * AMF: http://en.wikipedia.org/wiki/Additive_Manufacturing_File_Format
60
+ * STL: http://en.wikipedia.org/wiki/STL_(file_format)
61
+ * OFF: http://people.sc.fsu.edu/~jburkardt/data/off/off.html(file_format)
62
+ * DXF: http://en.wikipedia.org/wiki/AutoCAD_DXF
60
63
  */
61
64
  public class PShapeOpenGL extends PShape {
62
-
63
65
  // Testing these constants, not use as they might go away...
64
- static public final int POSITION = 0;
65
- static public final int NORMAL = 1;
66
- static public final int TEXCOORD = 2;
66
+ static public final int POSITION = 0;
67
+ static public final int NORMAL = 1;
68
+ static public final int TEXCOORD = 2;
67
69
  static public final int DIRECTION = 3;
68
- static public final int OFFSET = 4;
70
+ static public final int OFFSET = 4;
69
71
 
70
72
  static protected final int TRANSLATE = 0;
71
- static protected final int ROTATE = 1;
72
- static protected final int SCALE = 2;
73
- static protected final int MATRIX = 3;
73
+ static protected final int ROTATE = 1;
74
+ static protected final int SCALE = 2;
75
+ static protected final int MATRIX = 3;
74
76
 
75
77
  protected PGraphicsOpenGL pg;
76
78
  protected PGL pgl;
@@ -79,7 +81,9 @@ public class PShapeOpenGL extends PShape {
79
81
  protected PShapeOpenGL root;
80
82
 
81
83
  // ........................................................
84
+
82
85
  // Input, tessellated geometry
86
+
83
87
  protected InGeometry inGeo;
84
88
  protected TessGeometry tessGeo;
85
89
  protected Tessellator tessellator;
@@ -87,13 +91,17 @@ public class PShapeOpenGL extends PShape {
87
91
  protected AttributeMap polyAttribs;
88
92
 
89
93
  // ........................................................
94
+
90
95
  // Texturing
96
+
91
97
  protected HashSet<PImage> textures;
92
98
  protected boolean strokedTexture;
93
99
  protected boolean untexChild;
94
100
 
95
101
  // ........................................................
102
+
96
103
  // OpenGL buffers
104
+
97
105
  protected VertexBuffer bufPolyVertex;
98
106
  protected VertexBuffer bufPolyColor;
99
107
  protected VertexBuffer bufPolyNormal;
@@ -118,7 +126,9 @@ public class PShapeOpenGL extends PShape {
118
126
  public int glUsage = PGL.STATIC_DRAW;
119
127
 
120
128
  // ........................................................
129
+
121
130
  // Offsets for geometry aggregation and update.
131
+
122
132
  protected int polyVertCopyOffset;
123
133
  protected int polyIndCopyOffset;
124
134
  protected int lineVertCopyOffset;
@@ -156,13 +166,17 @@ public class PShapeOpenGL extends PShape {
156
166
  protected int lastPointVertex;
157
167
 
158
168
  // ........................................................
169
+
159
170
  // Geometric transformations.
171
+
160
172
  protected PMatrix transform;
161
173
  protected PMatrix transformInv;
162
174
  protected PMatrix matrixInv;
163
175
 
164
176
  // ........................................................
177
+
165
178
  // State/rendering flags
179
+
166
180
  protected boolean tessellated;
167
181
  protected boolean needBufferInit = false;
168
182
 
@@ -184,7 +198,9 @@ public class PShapeOpenGL extends PShape {
184
198
  protected boolean hasPoints;
185
199
 
186
200
  // ........................................................
201
+
187
202
  // Bezier and Catmull-Rom curves
203
+
188
204
  protected int bezierDetail;
189
205
  protected int curveDetail;
190
206
  protected float curveTightness;
@@ -194,7 +210,9 @@ public class PShapeOpenGL extends PShape {
194
210
  protected float savedCurveTightness;
195
211
 
196
212
  // ........................................................
213
+
197
214
  // Normals
215
+
198
216
  protected float normalX, normalY, normalZ;
199
217
 
200
218
  // normal calculated per triangle
@@ -208,7 +226,9 @@ public class PShapeOpenGL extends PShape {
208
226
  protected int normalMode;
209
227
 
210
228
  // ........................................................
229
+
211
230
  // Modification variables (used only by the root shape)
231
+
212
232
  protected boolean modified;
213
233
 
214
234
  protected boolean modifiedPolyVertices;
@@ -260,8 +280,10 @@ public class PShapeOpenGL extends PShape {
260
280
  protected int lastModifiedPointAttribute;
261
281
 
262
282
  // ........................................................
283
+
263
284
  // Saved style variables to style can be re-enabled after disableStyle,
264
285
  // although it won't work if properties are defined on a per-vertex basis.
286
+
265
287
  protected boolean savedStroke;
266
288
  protected int savedStrokeColor;
267
289
  protected float savedStrokeWeight;
@@ -281,9 +303,11 @@ public class PShapeOpenGL extends PShape {
281
303
 
282
304
  protected int savedTextureMode;
283
305
 
306
+
284
307
  PShapeOpenGL() {
285
308
  }
286
309
 
310
+
287
311
  public PShapeOpenGL(PGraphicsOpenGL pg, int family) {
288
312
  this.pg = pg;
289
313
  this.family = family;
@@ -325,7 +349,7 @@ public class PShapeOpenGL extends PShape {
325
349
  textureMode = pg.textureMode;
326
350
 
327
351
  colorMode(pg.colorMode,
328
- pg.colorModeX, pg.colorModeY, pg.colorModeZ, pg.colorModeA);
352
+ pg.colorModeX, pg.colorModeY, pg.colorModeZ, pg.colorModeA);
329
353
 
330
354
  // Initial values for fill, stroke and tint colors are also imported from
331
355
  // the renderer. This is particular relevant for primitive shapes, since is
@@ -378,20 +402,20 @@ public class PShapeOpenGL extends PShape {
378
402
  perVertexStyles = true;
379
403
  }
380
404
 
381
- /**
382
- * Create a shape from the PRIMITIVE family, using this kind and these params
383
- */
405
+
406
+ /** Create a shape from the PRIMITIVE family, using this kind and these params */
384
407
  public PShapeOpenGL(PGraphicsOpenGL pg, int kind, float... p) {
385
408
  this(pg, PRIMITIVE);
386
409
  setKind(kind);
387
410
  setParams(p);
388
411
  }
389
412
 
413
+
390
414
  @Override
391
415
  public void addChild(PShape who) {
392
416
  if (who instanceof PShapeOpenGL) {
393
417
  if (family == GROUP) {
394
- PShapeOpenGL c3d = (PShapeOpenGL) who;
418
+ PShapeOpenGL c3d = (PShapeOpenGL)who;
395
419
 
396
420
  super.addChild(c3d);
397
421
  c3d.updateRoot(root);
@@ -399,9 +423,9 @@ public class PShapeOpenGL extends PShape {
399
423
 
400
424
  if (c3d.family == GROUP) {
401
425
  if (c3d.textures != null) {
402
- c3d.textures.forEach((tex) -> {
426
+ for (PImage tex: c3d.textures) {
403
427
  addTexture(tex);
404
- });
428
+ }
405
429
  } else {
406
430
  untexChild(true);
407
431
  }
@@ -427,11 +451,12 @@ public class PShapeOpenGL extends PShape {
427
451
  }
428
452
  }
429
453
 
454
+
430
455
  @Override
431
456
  public void addChild(PShape who, int idx) {
432
457
  if (who instanceof PShapeOpenGL) {
433
458
  if (family == GROUP) {
434
- PShapeOpenGL c3d = (PShapeOpenGL) who;
459
+ PShapeOpenGL c3d = (PShapeOpenGL)who;
435
460
 
436
461
  super.addChild(c3d, idx);
437
462
  c3d.updateRoot(root);
@@ -467,6 +492,7 @@ public class PShapeOpenGL extends PShape {
467
492
  }
468
493
  }
469
494
 
495
+
470
496
  @Override
471
497
  public void removeChild(int idx) {
472
498
  super.removeChild(idx);
@@ -475,37 +501,49 @@ public class PShapeOpenGL extends PShape {
475
501
  markForTessellation();
476
502
  }
477
503
 
504
+
478
505
  protected void updateRoot(PShape root) {
479
506
  this.root = (PShapeOpenGL) root;
480
507
  if (family == GROUP) {
481
508
  for (int i = 0; i < childCount; i++) {
482
- PShapeOpenGL child = (PShapeOpenGL) children[i];
509
+ PShapeOpenGL child = (PShapeOpenGL)children[i];
483
510
  child.updateRoot(root);
484
511
  }
485
512
  }
486
513
  }
487
514
 
515
+
488
516
  ///////////////////////////////////////////////////////////
517
+
489
518
  //
490
519
  // Shape creation (temporary hack)
520
+
521
+
491
522
  public static PShapeOpenGL createShape(PGraphicsOpenGL pg, PShape src) {
492
523
  PShapeOpenGL dest = null;
493
- if (src.getFamily() == GROUP) {
494
- //dest = PGraphics3D.createShapeImpl(pg, GROUP);
495
- dest = (PShapeOpenGL) pg.createShapeFamily(GROUP);
496
- copyGroup(pg, src, dest);
497
- } else if (src.getFamily() == PRIMITIVE) {
498
- //dest = PGraphics3D.createShapeImpl(pg, src.getKind(), src.getParams());
499
- dest = (PShapeOpenGL) pg.createShapePrimitive(src.getKind(), src.getParams());
500
- PShape.copyPrimitive(src, dest);
501
- } else if (src.getFamily() == GEOMETRY) {
502
- //dest = PGraphics3D.createShapeImpl(pg, PShape.GEOMETRY);
503
- dest = (PShapeOpenGL) pg.createShapeFamily(PShape.GEOMETRY);
504
- PShape.copyGeometry(src, dest);
505
- } else if (src.getFamily() == PATH) {
506
- dest = (PShapeOpenGL) pg.createShapeFamily(PShape.PATH);
507
- //dest = PGraphics3D.createShapeImpl(pg, PATH);
508
- PShape.copyPath(src, dest);
524
+ switch (src.getFamily()) {
525
+ case GROUP:
526
+ //dest = PGraphics3D.createShapeImpl(pg, GROUP);
527
+ dest = (PShapeOpenGL) pg.createShapeFamily(GROUP);
528
+ copyGroup(pg, src, dest);
529
+ break;
530
+ case PRIMITIVE:
531
+ //dest = PGraphics3D.createShapeImpl(pg, src.getKind(), src.getParams());
532
+ dest = (PShapeOpenGL) pg.createShapePrimitive(src.getKind(), src.getParams());
533
+ PShape.copyPrimitive(src, dest);
534
+ break;
535
+ case GEOMETRY:
536
+ //dest = PGraphics3D.createShapeImpl(pg, PShape.GEOMETRY);
537
+ dest = (PShapeOpenGL) pg.createShapeFamily(PShape.GEOMETRY);
538
+ PShape.copyGeometry(src, dest);
539
+ break;
540
+ case PATH:
541
+ dest = (PShapeOpenGL) pg.createShapeFamily(PShape.PATH);
542
+ //dest = PGraphics3D.createShapeImpl(pg, PATH);
543
+ PShape.copyPath(src, dest);
544
+ break;
545
+ default:
546
+ break;
509
547
  }
510
548
  dest.setName(src.getName());
511
549
  dest.width = src.width;
@@ -540,7 +578,8 @@ public class PShapeOpenGL extends PShape {
540
578
  dest.height = src.height;
541
579
  return dest;
542
580
  }
543
- */
581
+ */
582
+
544
583
  static public void copyGroup(PGraphicsOpenGL pg, PShape src, PShape dest) {
545
584
  copyMatrix(src, dest);
546
585
  copyStyles(src, dest);
@@ -564,16 +603,21 @@ public class PShapeOpenGL extends PShape {
564
603
  dest.addChild(c);
565
604
  }
566
605
  }
567
- */
606
+ */
607
+
568
608
  ///////////////////////////////////////////////////////////
609
+
569
610
  //
611
+
570
612
  // Query methods
613
+
614
+
571
615
  @Override
572
616
  public float getWidth() {
573
617
  PVector min = new PVector(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY,
574
- Float.POSITIVE_INFINITY);
618
+ Float.POSITIVE_INFINITY);
575
619
  PVector max = new PVector(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
576
- Float.NEGATIVE_INFINITY);
620
+ Float.NEGATIVE_INFINITY);
577
621
  if (shapeCreated) {
578
622
  getVertexMin(min);
579
623
  getVertexMax(max);
@@ -582,12 +626,13 @@ public class PShapeOpenGL extends PShape {
582
626
  return width;
583
627
  }
584
628
 
629
+
585
630
  @Override
586
631
  public float getHeight() {
587
632
  PVector min = new PVector(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY,
588
- Float.POSITIVE_INFINITY);
633
+ Float.POSITIVE_INFINITY);
589
634
  PVector max = new PVector(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
590
- Float.NEGATIVE_INFINITY);
635
+ Float.NEGATIVE_INFINITY);
591
636
  if (shapeCreated) {
592
637
  getVertexMin(min);
593
638
  getVertexMax(max);
@@ -596,12 +641,13 @@ public class PShapeOpenGL extends PShape {
596
641
  return height;
597
642
  }
598
643
 
644
+
599
645
  @Override
600
646
  public float getDepth() {
601
647
  PVector min = new PVector(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY,
602
- Float.POSITIVE_INFINITY);
648
+ Float.POSITIVE_INFINITY);
603
649
  PVector max = new PVector(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
604
- Float.NEGATIVE_INFINITY);
650
+ Float.NEGATIVE_INFINITY);
605
651
  if (shapeCreated) {
606
652
  getVertexMin(min);
607
653
  getVertexMax(max);
@@ -610,6 +656,7 @@ public class PShapeOpenGL extends PShape {
610
656
  return depth;
611
657
  }
612
658
 
659
+
613
660
  protected void getVertexMin(PVector min) {
614
661
  updateTessellation();
615
662
 
@@ -633,6 +680,7 @@ public class PShapeOpenGL extends PShape {
633
680
  }
634
681
  }
635
682
 
683
+
636
684
  protected void getVertexMax(PVector max) {
637
685
  updateTessellation();
638
686
 
@@ -656,6 +704,7 @@ public class PShapeOpenGL extends PShape {
656
704
  }
657
705
  }
658
706
 
707
+
659
708
  protected int getVertexSum(PVector sum, int count) {
660
709
  updateTessellation();
661
710
 
@@ -671,20 +720,25 @@ public class PShapeOpenGL extends PShape {
671
720
  if (is3D()) {
672
721
  if (hasLines) {
673
722
  count += tessGeo.getLineVertexSum(sum, firstLineVertex,
674
- lastLineVertex);
723
+ lastLineVertex);
675
724
  }
676
725
  if (hasPoints) {
677
726
  count += tessGeo.getPointVertexSum(sum, firstPointVertex,
678
- lastPointVertex);
727
+ lastPointVertex);
679
728
  }
680
729
  }
681
730
  }
682
731
  return count;
683
732
  }
684
733
 
734
+
685
735
  ///////////////////////////////////////////////////////////
736
+
686
737
  //
738
+
687
739
  // Drawing methods
740
+
741
+
688
742
  @Override
689
743
  public void setTextureMode(int mode) {
690
744
  if (openShape) {
@@ -702,10 +756,9 @@ public class PShapeOpenGL extends PShape {
702
756
  }
703
757
  }
704
758
 
759
+
705
760
  protected void setTextureModeImpl(int mode) {
706
- if (textureMode == mode) {
707
- return;
708
- }
761
+ if (textureMode == mode) return;
709
762
  textureMode = mode;
710
763
  if (image != null) {
711
764
  float uFactor = image.width;
@@ -718,6 +771,7 @@ public class PShapeOpenGL extends PShape {
718
771
  }
719
772
  }
720
773
 
774
+
721
775
  @Override
722
776
  public void setTexture(PImage tex) {
723
777
  if (openShape) {
@@ -735,6 +789,7 @@ public class PShapeOpenGL extends PShape {
735
789
  }
736
790
  }
737
791
 
792
+
738
793
  protected void setTextureImpl(PImage tex) {
739
794
  PImage image0 = image;
740
795
  image = tex;
@@ -755,21 +810,20 @@ public class PShapeOpenGL extends PShape {
755
810
  }
756
811
 
757
812
  if (image0 != tex && parent != null) {
758
- ((PShapeOpenGL) parent).removeTexture(image0, this);
813
+ ((PShapeOpenGL)parent).removeTexture(image0, this);
759
814
  }
760
815
  if (parent != null) {
761
- ((PShapeOpenGL) parent).addTexture(image);
816
+ ((PShapeOpenGL)parent).addTexture(image);
762
817
  if (is2D() && stroke) {
763
- ((PShapeOpenGL) parent).strokedTexture(true);
818
+ ((PShapeOpenGL)parent).strokedTexture(true);
764
819
  }
765
820
  }
766
821
  }
767
822
 
823
+
768
824
  protected void scaleTextureUV(float uFactor, float vFactor) {
769
- if (PGraphicsOpenGL.same(uFactor, 1)
770
- && PGraphicsOpenGL.same(vFactor, 1)) {
771
- return;
772
- }
825
+ if (PGraphicsOpenGL.same(uFactor, 1) &&
826
+ PGraphicsOpenGL.same(vFactor, 1)) return;
773
827
 
774
828
  for (int i = 0; i < inGeo.vertexCount; i++) {
775
829
  float u = inGeo.texcoords[2 * i + 0];
@@ -784,12 +838,8 @@ public class PShapeOpenGL extends PShape {
784
838
  last1 = lastPolyVertex + 1;
785
839
  } else if (is2D()) {
786
840
  last1 = lastPolyVertex + 1;
787
- if (-1 < firstLineVertex) {
788
- last1 = firstLineVertex;
789
- }
790
- if (-1 < firstPointVertex) {
791
- last1 = firstPointVertex;
792
- }
841
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
842
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
793
843
  }
794
844
  for (int i = firstLineVertex; i < last1; i++) {
795
845
  float u = tessGeo.polyTexCoords[2 * i + 0];
@@ -801,27 +851,26 @@ public class PShapeOpenGL extends PShape {
801
851
  }
802
852
  }
803
853
 
854
+
804
855
  protected void addTexture(PImage tex) {
805
856
  if (textures == null) {
806
857
  textures = new HashSet<>();
807
858
  }
808
859
  textures.add(tex);
809
860
  if (parent != null) {
810
- ((PShapeOpenGL) parent).addTexture(tex);
861
+ ((PShapeOpenGL)parent).addTexture(tex);
811
862
  }
812
863
  }
813
864
 
865
+
814
866
  protected void removeTexture(PImage tex, PShapeOpenGL caller) {
815
- if (textures == null || !textures.contains(tex)) {
816
- return; // Nothing to remove.
817
- }
867
+ if (textures == null || !textures.contains(tex)) return; // Nothing to remove.
868
+
818
869
  // First check that none of the child shapes have texture tex...
819
870
  boolean childHasTex = false;
820
871
  for (int i = 0; i < childCount; i++) {
821
872
  PShapeOpenGL child = (PShapeOpenGL) children[i];
822
- if (child == caller) {
823
- continue;
824
- }
873
+ if (child == caller) continue;
825
874
  if (child.hasTexture(tex)) {
826
875
  childHasTex = true;
827
876
  break;
@@ -831,7 +880,7 @@ public class PShapeOpenGL extends PShape {
831
880
  if (!childHasTex) {
832
881
  // ...if not, it is safe to remove from this shape.
833
882
  textures.remove(tex);
834
- if (textures.size() == 0) {
883
+ if (textures.isEmpty()) {
835
884
  textures = null;
836
885
  }
837
886
  }
@@ -839,18 +888,19 @@ public class PShapeOpenGL extends PShape {
839
888
  // Since this shape and all its child shapes don't contain
840
889
  // tex anymore, we now can remove it from the parent.
841
890
  if (parent != null) {
842
- ((PShapeOpenGL) parent).removeTexture(tex, this);
891
+ ((PShapeOpenGL)parent).removeTexture(tex, this);
843
892
  }
844
893
  }
845
894
 
895
+
846
896
  protected void strokedTexture(boolean newValue) {
847
897
  strokedTexture(newValue, null);
848
898
  }
849
899
 
900
+
850
901
  protected void strokedTexture(boolean newValue, PShapeOpenGL caller) {
851
- if (strokedTexture == newValue) {
852
- return; // Nothing to change.
853
- }
902
+ if (strokedTexture == newValue) return; // Nothing to change.
903
+
854
904
  if (newValue) {
855
905
  strokedTexture = true;
856
906
  } else {
@@ -858,9 +908,7 @@ public class PShapeOpenGL extends PShape {
858
908
  strokedTexture = false;
859
909
  for (int i = 0; i < childCount; i++) {
860
910
  PShapeOpenGL child = (PShapeOpenGL) children[i];
861
- if (child == caller) {
862
- continue;
863
- }
911
+ if (child == caller) continue;
864
912
  if (child.hasStrokedTexture()) {
865
913
  strokedTexture = true;
866
914
  break;
@@ -870,18 +918,19 @@ public class PShapeOpenGL extends PShape {
870
918
 
871
919
  // Now we can update the parent shape.
872
920
  if (parent != null) {
873
- ((PShapeOpenGL) parent).strokedTexture(newValue, this);
921
+ ((PShapeOpenGL)parent).strokedTexture(newValue, this);
874
922
  }
875
923
  }
876
924
 
925
+
877
926
  protected void untexChild(boolean newValue) {
878
927
  untexChild(newValue, null);
879
928
  }
880
929
 
930
+
881
931
  protected void untexChild(boolean newValue, PShapeOpenGL caller) {
882
- if (untexChild == newValue) {
883
- return; // Nothing to change.
884
- }
932
+ if (untexChild == newValue) return; // Nothing to change.
933
+
885
934
  if (newValue) {
886
935
  untexChild = true;
887
936
  } else {
@@ -889,9 +938,7 @@ public class PShapeOpenGL extends PShape {
889
938
  untexChild = false;
890
939
  for (int i = 0; i < childCount; i++) {
891
940
  PShapeOpenGL child = (PShapeOpenGL) children[i];
892
- if (child == caller) {
893
- continue;
894
- }
941
+ if (child == caller) continue;
895
942
  if (!child.hasTexture()) {
896
943
  untexChild = true;
897
944
  break;
@@ -901,10 +948,11 @@ public class PShapeOpenGL extends PShape {
901
948
 
902
949
  // Now we can update the parent shape.
903
950
  if (parent != null) {
904
- ((PShapeOpenGL) parent).untexChild(newValue, this);
951
+ ((PShapeOpenGL)parent).untexChild(newValue, this);
905
952
  }
906
953
  }
907
954
 
955
+
908
956
  protected boolean hasTexture() {
909
957
  if (family == GROUP) {
910
958
  return textures != null && 0 < textures.size();
@@ -913,6 +961,7 @@ public class PShapeOpenGL extends PShape {
913
961
  }
914
962
  }
915
963
 
964
+
916
965
  protected boolean hasTexture(PImage tex) {
917
966
  if (family == GROUP) {
918
967
  return textures != null && textures.contains(tex);
@@ -921,6 +970,7 @@ public class PShapeOpenGL extends PShape {
921
970
  }
922
971
  }
923
972
 
973
+
924
974
  protected boolean hasStrokedTexture() {
925
975
  if (family == GROUP) {
926
976
  return strokedTexture;
@@ -929,6 +979,7 @@ public class PShapeOpenGL extends PShape {
929
979
  }
930
980
  }
931
981
 
982
+
932
983
  @Override
933
984
  public void solid(boolean solid) {
934
985
  if (family == GROUP) {
@@ -941,41 +992,46 @@ public class PShapeOpenGL extends PShape {
941
992
  }
942
993
  }
943
994
 
995
+
944
996
  @Override
945
997
  protected void beginContourImpl() {
946
998
  breakShape = true;
947
999
  }
948
1000
 
1001
+
949
1002
  @Override
950
1003
  protected void endContourImpl() {
951
1004
  }
952
1005
 
1006
+
953
1007
  @Override
954
1008
  public void vertex(float x, float y) {
955
1009
  vertexImpl(x, y, 0, 0, 0);
956
- if (image != null) {
1010
+ if (image != null)
957
1011
  PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
958
- }
959
1012
  }
960
1013
 
1014
+
961
1015
  @Override
962
1016
  public void vertex(float x, float y, float u, float v) {
963
1017
  vertexImpl(x, y, 0, u, v);
964
1018
  }
965
1019
 
1020
+
966
1021
  @Override
967
1022
  public void vertex(float x, float y, float z) {
968
1023
  vertexImpl(x, y, z, 0, 0);
969
- if (image != null) {
1024
+ if (image != null)
970
1025
  PGraphics.showWarning(PGraphicsOpenGL.MISSING_UV_TEXCOORDS_ERROR);
971
- }
972
1026
  }
973
1027
 
1028
+
974
1029
  @Override
975
1030
  public void vertex(float x, float y, float z, float u, float v) {
976
1031
  vertexImpl(x, y, z, u, v);
977
1032
  }
978
1033
 
1034
+
979
1035
  protected void vertexImpl(float x, float y, float z, float u, float v) {
980
1036
  if (!openShape) {
981
1037
  PGraphics.showWarning(OUTSIDE_BEGIN_END_ERROR, "vertex()");
@@ -1014,16 +1070,17 @@ public class PShapeOpenGL extends PShape {
1014
1070
  }
1015
1071
 
1016
1072
  inGeo.addVertex(x, y, z,
1017
- fcolor,
1018
- normalX, normalY, normalZ,
1019
- u, v,
1020
- scolor, sweight,
1021
- ambientColor, specularColor, emissiveColor, shininess,
1022
- VERTEX, vertexBreak());
1073
+ fcolor,
1074
+ normalX, normalY, normalZ,
1075
+ u, v,
1076
+ scolor, sweight,
1077
+ ambientColor, specularColor, emissiveColor, shininess,
1078
+ VERTEX, vertexBreak());
1023
1079
 
1024
1080
  markForTessellation();
1025
1081
  }
1026
1082
 
1083
+
1027
1084
  protected boolean vertexBreak() {
1028
1085
  if (breakShape) {
1029
1086
  breakShape = false;
@@ -1032,6 +1089,7 @@ public class PShapeOpenGL extends PShape {
1032
1089
  return false;
1033
1090
  }
1034
1091
 
1092
+
1035
1093
  @Override
1036
1094
  public void normal(float nx, float ny, float nz) {
1037
1095
  if (!openShape) {
@@ -1059,59 +1117,54 @@ public class PShapeOpenGL extends PShape {
1059
1117
  }
1060
1118
  }
1061
1119
 
1120
+
1062
1121
  @Override
1063
1122
  public void attribPosition(String name, float x, float y, float z) {
1064
1123
  VertexAttribute attrib = attribImpl(name, VertexAttribute.POSITION,
1065
- PGL.FLOAT, 3);
1066
- if (attrib != null) {
1067
- attrib.set(x, y, z);
1068
- }
1124
+ PGL.FLOAT, 3);
1125
+ if (attrib != null) attrib.set(x, y, z);
1069
1126
  }
1070
1127
 
1128
+
1071
1129
  @Override
1072
1130
  public void attribNormal(String name, float nx, float ny, float nz) {
1073
1131
  VertexAttribute attrib = attribImpl(name, VertexAttribute.NORMAL,
1074
- PGL.FLOAT, 3);
1075
- if (attrib != null) {
1076
- attrib.set(nx, ny, nz);
1077
- }
1132
+ PGL.FLOAT, 3);
1133
+ if (attrib != null) attrib.set(nx, ny, nz);
1078
1134
  }
1079
1135
 
1136
+
1080
1137
  @Override
1081
1138
  public void attribColor(String name, int color) {
1082
1139
  VertexAttribute attrib = attribImpl(name, VertexAttribute.COLOR, PGL.INT, 1);
1083
- if (attrib != null) {
1084
- attrib.set(new int[]{color});
1085
- }
1140
+ if (attrib != null) attrib.set(new int[] {color});
1086
1141
  }
1087
1142
 
1143
+
1088
1144
  @Override
1089
1145
  public void attrib(String name, float... values) {
1090
1146
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.FLOAT,
1091
- values.length);
1092
- if (attrib != null) {
1093
- attrib.set(values);
1094
- }
1147
+ values.length);
1148
+ if (attrib != null) attrib.set(values);
1095
1149
  }
1096
1150
 
1151
+
1097
1152
  @Override
1098
1153
  public void attrib(String name, int... values) {
1099
1154
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.INT,
1100
- values.length);
1101
- if (attrib != null) {
1102
- attrib.set(values);
1103
- }
1155
+ values.length);
1156
+ if (attrib != null) attrib.set(values);
1104
1157
  }
1105
1158
 
1159
+
1106
1160
  @Override
1107
1161
  public void attrib(String name, boolean... values) {
1108
1162
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.BOOL,
1109
- values.length);
1110
- if (attrib != null) {
1111
- attrib.set(values);
1112
- }
1163
+ values.length);
1164
+ if (attrib != null) attrib.set(values);
1113
1165
  }
1114
1166
 
1167
+
1115
1168
  protected VertexAttribute attribImpl(String name, int kind, int type, int size) {
1116
1169
  if (4 < size) {
1117
1170
  PGraphics.showWarning("Vertex attributes cannot have more than 4 values");
@@ -1138,6 +1191,7 @@ public class PShapeOpenGL extends PShape {
1138
1191
  return attrib;
1139
1192
  }
1140
1193
 
1194
+
1141
1195
  @Override
1142
1196
  public void endShape(int mode) {
1143
1197
  super.endShape(mode);
@@ -1151,6 +1205,7 @@ public class PShapeOpenGL extends PShape {
1151
1205
  shapeCreated = true;
1152
1206
  }
1153
1207
 
1208
+
1154
1209
  @Override
1155
1210
  public void setParams(float[] source) {
1156
1211
  if (family != PRIMITIVE) {
@@ -1163,11 +1218,12 @@ public class PShapeOpenGL extends PShape {
1163
1218
  shapeCreated = true;
1164
1219
  }
1165
1220
 
1221
+
1166
1222
  @Override
1167
1223
  public void setPath(int vcount, float[][] verts, int ccount, int[] codes) {
1168
1224
  if (family != PATH) {
1169
- PGraphics.showWarning("Vertex coordinates and codes can only be set to "
1170
- + "PATH shapes");
1225
+ PGraphics.showWarning("Vertex coordinates and codes can only be set to " +
1226
+ "PATH shapes");
1171
1227
  return;
1172
1228
  }
1173
1229
 
@@ -1176,9 +1232,14 @@ public class PShapeOpenGL extends PShape {
1176
1232
  shapeCreated = true;
1177
1233
  }
1178
1234
 
1235
+
1179
1236
  ///////////////////////////////////////////////////////////
1237
+
1180
1238
  //
1239
+
1181
1240
  // Geometric transformations
1241
+
1242
+
1182
1243
  @Override
1183
1244
  public void translate(float tx, float ty) {
1184
1245
  if (is3D) {
@@ -1188,36 +1249,43 @@ public class PShapeOpenGL extends PShape {
1188
1249
  }
1189
1250
  }
1190
1251
 
1252
+
1191
1253
  @Override
1192
1254
  public void translate(float tx, float ty, float tz) {
1193
1255
  transform(TRANSLATE, tx, ty, tz);
1194
1256
  }
1195
1257
 
1258
+
1196
1259
  @Override
1197
1260
  public void rotate(float angle) {
1198
1261
  transform(ROTATE, angle);
1199
1262
  }
1200
1263
 
1264
+
1201
1265
  @Override
1202
1266
  public void rotateX(float angle) {
1203
1267
  rotate(angle, 1, 0, 0);
1204
1268
  }
1205
1269
 
1270
+
1206
1271
  @Override
1207
1272
  public void rotateY(float angle) {
1208
1273
  rotate(angle, 0, 1, 0);
1209
1274
  }
1210
1275
 
1276
+
1211
1277
  @Override
1212
1278
  public void rotateZ(float angle) {
1213
1279
  rotate(angle, 0, 0, 1);
1214
1280
  }
1215
1281
 
1282
+
1216
1283
  @Override
1217
1284
  public void rotate(float angle, float v0, float v1, float v2) {
1218
1285
  transform(ROTATE, angle, v0, v1, v2);
1219
1286
  }
1220
1287
 
1288
+
1221
1289
  @Override
1222
1290
  public void scale(float s) {
1223
1291
  if (is3D) {
@@ -1227,6 +1295,7 @@ public class PShapeOpenGL extends PShape {
1227
1295
  }
1228
1296
  }
1229
1297
 
1298
+
1230
1299
  @Override
1231
1300
  public void scale(float x, float y) {
1232
1301
  if (is3D) {
@@ -1236,35 +1305,40 @@ public class PShapeOpenGL extends PShape {
1236
1305
  }
1237
1306
  }
1238
1307
 
1308
+
1239
1309
  @Override
1240
1310
  public void scale(float x, float y, float z) {
1241
1311
  transform(SCALE, x, y, z);
1242
1312
  }
1243
1313
 
1314
+
1244
1315
  @Override
1245
1316
  public void applyMatrix(PMatrix2D source) {
1246
1317
  transform(MATRIX, source.m00, source.m01, source.m02,
1247
- source.m10, source.m11, source.m12);
1318
+ source.m10, source.m11, source.m12);
1248
1319
  }
1249
1320
 
1321
+
1250
1322
  @Override
1251
1323
  public void applyMatrix(float n00, float n01, float n02,
1252
- float n10, float n11, float n12) {
1324
+ float n10, float n11, float n12) {
1253
1325
  transform(MATRIX, n00, n01, n02,
1254
- n10, n11, n12);
1326
+ n10, n11, n12);
1255
1327
  }
1256
1328
 
1329
+
1257
1330
  @Override
1258
1331
  public void applyMatrix(float n00, float n01, float n02, float n03,
1259
- float n10, float n11, float n12, float n13,
1260
- float n20, float n21, float n22, float n23,
1261
- float n30, float n31, float n32, float n33) {
1332
+ float n10, float n11, float n12, float n13,
1333
+ float n20, float n21, float n22, float n23,
1334
+ float n30, float n31, float n32, float n33) {
1262
1335
  transform(MATRIX, n00, n01, n02, n03,
1263
- n10, n11, n12, n13,
1264
- n20, n21, n22, n23,
1265
- n30, n31, n32, n33);
1336
+ n10, n11, n12, n13,
1337
+ n20, n21, n22, n23,
1338
+ n30, n31, n32, n33);
1266
1339
  }
1267
1340
 
1341
+
1268
1342
  @Override
1269
1343
  public void resetMatrix() {
1270
1344
  if (shapeCreated && matrix != null && matrixInv != null) {
@@ -1279,6 +1353,7 @@ public class PShapeOpenGL extends PShape {
1279
1353
  }
1280
1354
  }
1281
1355
 
1356
+
1282
1357
  protected void transform(int type, float... args) {
1283
1358
  int dimensions = is3D ? 3 : 2;
1284
1359
  boolean invertible = true;
@@ -1304,46 +1379,46 @@ public class PShapeOpenGL extends PShape {
1304
1379
  }
1305
1380
 
1306
1381
  switch (type) {
1307
- case TRANSLATE:
1308
- if (ncoords == 3) {
1309
- transform.translate(args[0], args[1], args[2]);
1310
- PGraphicsOpenGL.invTranslate((PMatrix3D) transformInv, args[0], args[1], args[2]);
1311
- } else {
1312
- transform.translate(args[0], args[1]);
1313
- PGraphicsOpenGL.invTranslate((PMatrix2D) transformInv, args[0], args[1]);
1314
- }
1315
- break;
1316
- case ROTATE:
1317
- if (ncoords == 3) {
1318
- transform.rotate(args[0], args[1], args[2], args[3]);
1319
- PGraphicsOpenGL.invRotate((PMatrix3D) transformInv, args[0], args[1], args[2], args[3]);
1320
- } else {
1321
- transform.rotate(args[0]);
1322
- PGraphicsOpenGL.invRotate((PMatrix2D) transformInv, -args[0]);
1323
- }
1324
- break;
1325
- case SCALE:
1326
- if (ncoords == 3) {
1327
- transform.scale(args[0], args[1], args[2]);
1328
- PGraphicsOpenGL.invScale((PMatrix3D) transformInv, args[0], args[1], args[2]);
1329
- } else {
1330
- transform.scale(args[0], args[1]);
1331
- PGraphicsOpenGL.invScale((PMatrix2D) transformInv, args[0], args[1]);
1332
- }
1333
- break;
1334
- case MATRIX:
1335
- if (ncoords == 3) {
1336
- transform.set(args[0], args[1], args[2], args[3],
1337
- args[4], args[5], args[6], args[7],
1338
- args[8], args[9], args[10], args[11],
1339
- args[12], args[13], args[14], args[15]);
1340
- } else {
1341
- transform.set(args[0], args[1], args[2],
1342
- args[3], args[4], args[5]);
1343
- }
1344
- transformInv.set(transform);
1345
- invertible = transformInv.invert();
1346
- break;
1382
+ case TRANSLATE:
1383
+ if (ncoords == 3) {
1384
+ transform.translate(args[0], args[1], args[2]);
1385
+ PGraphicsOpenGL.invTranslate((PMatrix3D)transformInv, args[0], args[1], args[2]);
1386
+ } else {
1387
+ transform.translate(args[0], args[1]);
1388
+ PGraphicsOpenGL.invTranslate((PMatrix2D)transformInv, args[0], args[1]);
1389
+ }
1390
+ break;
1391
+ case ROTATE:
1392
+ if (ncoords == 3) {
1393
+ transform.rotate(args[0], args[1], args[2], args[3]);
1394
+ PGraphicsOpenGL.invRotate((PMatrix3D)transformInv, args[0], args[1], args[2], args[3]);
1395
+ } else {
1396
+ transform.rotate(args[0]);
1397
+ PGraphicsOpenGL.invRotate((PMatrix2D)transformInv, -args[0]);
1398
+ }
1399
+ break;
1400
+ case SCALE:
1401
+ if (ncoords == 3) {
1402
+ transform.scale(args[0], args[1], args[2]);
1403
+ PGraphicsOpenGL.invScale((PMatrix3D)transformInv, args[0], args[1], args[2]);
1404
+ } else {
1405
+ transform.scale(args[0], args[1]);
1406
+ PGraphicsOpenGL.invScale((PMatrix2D)transformInv, args[0], args[1]);
1407
+ }
1408
+ break;
1409
+ case MATRIX:
1410
+ if (ncoords == 3) {
1411
+ transform.set(args[ 0], args[ 1], args[ 2], args[ 3],
1412
+ args[ 4], args[ 5], args[ 6], args[ 7],
1413
+ args[ 8], args[ 9], args[10], args[11],
1414
+ args[12], args[13], args[14], args[15]);
1415
+ } else {
1416
+ transform.set(args[0], args[1], args[2],
1417
+ args[3], args[4], args[5]);
1418
+ }
1419
+ transformInv.set(transform);
1420
+ invertible = transformInv.invert();
1421
+ break;
1347
1422
  }
1348
1423
  matrix.preApply(transform);
1349
1424
  if (invertible) {
@@ -1351,15 +1426,14 @@ public class PShapeOpenGL extends PShape {
1351
1426
  } else {
1352
1427
  PGraphics.showWarning("Transformation applied on the shape cannot be inverted");
1353
1428
  }
1354
- if (tessellated) {
1355
- applyMatrixImpl(transform);
1356
- }
1429
+ if (tessellated) applyMatrixImpl(transform);
1357
1430
  }
1358
1431
 
1432
+
1359
1433
  protected void applyMatrixImpl(PMatrix matrix) {
1360
1434
  if (hasPolys) {
1361
1435
  tessGeo.applyMatrixOnPolyGeometry(matrix,
1362
- firstPolyVertex, lastPolyVertex);
1436
+ firstPolyVertex, lastPolyVertex);
1363
1437
  root.setModifiedPolyVertices(firstPolyVertex, lastPolyVertex);
1364
1438
  root.setModifiedPolyNormals(firstPolyVertex, lastPolyVertex);
1365
1439
  polyAttribs.values().stream().filter((attrib) -> (attrib.isPosition() || attrib.isNormal())).forEachOrdered((attrib) -> {
@@ -1370,20 +1444,21 @@ public class PShapeOpenGL extends PShape {
1370
1444
  if (is3D()) {
1371
1445
  if (hasLines) {
1372
1446
  tessGeo.applyMatrixOnLineGeometry(matrix,
1373
- firstLineVertex, lastLineVertex);
1447
+ firstLineVertex, lastLineVertex);
1374
1448
  root.setModifiedLineVertices(firstLineVertex, lastLineVertex);
1375
1449
  root.setModifiedLineAttributes(firstLineVertex, lastLineVertex);
1376
1450
  }
1377
1451
 
1378
1452
  if (hasPoints) {
1379
1453
  tessGeo.applyMatrixOnPointGeometry(matrix,
1380
- firstPointVertex, lastPointVertex);
1454
+ firstPointVertex, lastPointVertex);
1381
1455
  root.setModifiedPointVertices(firstPointVertex, lastPointVertex);
1382
1456
  root.setModifiedPointAttributes(firstPointVertex, lastPointVertex);
1383
1457
  }
1384
1458
  }
1385
1459
  }
1386
1460
 
1461
+
1387
1462
  @Override
1388
1463
  protected void checkMatrix(int dimensions) {
1389
1464
  if (matrix == null) {
@@ -1400,9 +1475,14 @@ public class PShapeOpenGL extends PShape {
1400
1475
  }
1401
1476
  }
1402
1477
 
1478
+
1403
1479
  ///////////////////////////////////////////////////////////
1480
+
1404
1481
  //
1482
+
1405
1483
  // Bezier curves
1484
+
1485
+
1406
1486
  @Override
1407
1487
  public void bezierDetail(int detail) {
1408
1488
  bezierDetail = detail;
@@ -1412,61 +1492,72 @@ public class PShapeOpenGL extends PShape {
1412
1492
  //pg.bezierDetail(detail); // setting the detail in the renderer, WTF??
1413
1493
  }
1414
1494
 
1495
+
1415
1496
  @Override
1416
1497
  public void bezierVertex(float x2, float y2,
1417
- float x3, float y3,
1418
- float x4, float y4) {
1498
+ float x3, float y3,
1499
+ float x4, float y4) {
1419
1500
  bezierVertexImpl(x2, y2, 0,
1420
- x3, y3, 0,
1421
- x4, y4, 0);
1501
+ x3, y3, 0,
1502
+ x4, y4, 0);
1422
1503
  }
1423
1504
 
1505
+
1424
1506
  @Override
1425
1507
  public void bezierVertex(float x2, float y2, float z2,
1426
- float x3, float y3, float z3,
1427
- float x4, float y4, float z4) {
1508
+ float x3, float y3, float z3,
1509
+ float x4, float y4, float z4) {
1428
1510
  bezierVertexImpl(x2, y2, z2,
1429
- x3, y3, z3,
1430
- x4, y4, z4);
1511
+ x3, y3, z3,
1512
+ x4, y4, z4);
1431
1513
  }
1432
1514
 
1515
+
1433
1516
  protected void bezierVertexImpl(float x2, float y2, float z2,
1434
- float x3, float y3, float z3,
1435
- float x4, float y4, float z4) {
1517
+ float x3, float y3, float z3,
1518
+ float x4, float y4, float z4) {
1436
1519
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
1437
- ambientColor, specularColor, emissiveColor, shininess);
1520
+ ambientColor, specularColor, emissiveColor, shininess);
1438
1521
  inGeo.setNormal(normalX, normalY, normalZ);
1439
1522
  inGeo.addBezierVertex(x2, y2, z2,
1440
- x3, y3, z3,
1441
- x4, y4, z4, vertexBreak());
1523
+ x3, y3, z3,
1524
+ x4, y4, z4, vertexBreak());
1442
1525
  }
1443
1526
 
1527
+
1444
1528
  @Override
1445
1529
  public void quadraticVertex(float cx, float cy,
1446
- float x3, float y3) {
1530
+ float x3, float y3) {
1447
1531
  quadraticVertexImpl(cx, cy, 0,
1448
- x3, y3, 0);
1532
+ x3, y3, 0);
1449
1533
  }
1450
1534
 
1535
+
1451
1536
  @Override
1452
1537
  public void quadraticVertex(float cx, float cy, float cz,
1453
- float x3, float y3, float z3) {
1538
+ float x3, float y3, float z3) {
1454
1539
  quadraticVertexImpl(cx, cy, cz,
1455
- x3, y3, z3);
1540
+ x3, y3, z3);
1456
1541
  }
1457
1542
 
1543
+
1458
1544
  protected void quadraticVertexImpl(float cx, float cy, float cz,
1459
- float x3, float y3, float z3) {
1545
+ float x3, float y3, float z3) {
1460
1546
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
1461
- ambientColor, specularColor, emissiveColor, shininess);
1547
+ ambientColor, specularColor, emissiveColor, shininess);
1462
1548
  inGeo.setNormal(normalX, normalY, normalZ);
1463
1549
  inGeo.addQuadraticVertex(cx, cy, cz,
1464
- x3, y3, z3, vertexBreak());
1550
+ x3, y3, z3, vertexBreak());
1465
1551
  }
1466
1552
 
1553
+
1467
1554
  ///////////////////////////////////////////////////////////
1555
+
1468
1556
  //
1557
+
1469
1558
  // Catmull-Rom curves
1559
+
1560
+
1470
1561
  @Override
1471
1562
  public void curveDetail(int detail) {
1472
1563
  curveDetail = detail;
@@ -1476,6 +1567,7 @@ public class PShapeOpenGL extends PShape {
1476
1567
  }
1477
1568
  }
1478
1569
 
1570
+
1479
1571
  @Override
1480
1572
  public void curveTightness(float tightness) {
1481
1573
  curveTightness = tightness;
@@ -1485,31 +1577,38 @@ public class PShapeOpenGL extends PShape {
1485
1577
  }
1486
1578
  }
1487
1579
 
1580
+
1488
1581
  @Override
1489
1582
  public void curveVertex(float x, float y) {
1490
1583
  curveVertexImpl(x, y, 0);
1491
1584
  }
1492
1585
 
1586
+
1493
1587
  @Override
1494
1588
  public void curveVertex(float x, float y, float z) {
1495
1589
  curveVertexImpl(x, y, z);
1496
1590
  }
1497
1591
 
1592
+
1498
1593
  protected void curveVertexImpl(float x, float y, float z) {
1499
1594
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
1500
- ambientColor, specularColor, emissiveColor, shininess);
1595
+ ambientColor, specularColor, emissiveColor, shininess);
1501
1596
  inGeo.setNormal(normalX, normalY, normalZ);
1502
1597
  inGeo.addCurveVertex(x, y, z, vertexBreak());
1503
1598
  }
1504
1599
 
1600
+
1505
1601
  ///////////////////////////////////////////////////////////
1602
+
1506
1603
  //
1604
+
1507
1605
  // Setters/getters of individual vertices
1606
+
1607
+
1508
1608
  @Override
1509
1609
  public int getVertexCount() {
1510
- if (family == GROUP) {
1511
- return 0; // Group shapes don't have vertices
1512
- } else {
1610
+ if (family == GROUP) return 0; // Group shapes don't have vertices
1611
+ else {
1513
1612
  if (family == PRIMITIVE || family == PATH) {
1514
1613
  // the input geometry of primitive and path shapes is built during
1515
1614
  // tessellation
@@ -1519,6 +1618,7 @@ public class PShapeOpenGL extends PShape {
1519
1618
  }
1520
1619
  }
1521
1620
 
1621
+
1522
1622
  @Override
1523
1623
  public PVector getVertex(int index, PVector vec) {
1524
1624
  if (vec == null) {
@@ -1530,26 +1630,31 @@ public class PShapeOpenGL extends PShape {
1530
1630
  return vec;
1531
1631
  }
1532
1632
 
1633
+
1533
1634
  @Override
1534
1635
  public float getVertexX(int index) {
1535
1636
  return inGeo.vertices[3 * index + 0];
1536
1637
  }
1537
1638
 
1639
+
1538
1640
  @Override
1539
1641
  public float getVertexY(int index) {
1540
1642
  return inGeo.vertices[3 * index + 1];
1541
1643
  }
1542
1644
 
1645
+
1543
1646
  @Override
1544
1647
  public float getVertexZ(int index) {
1545
1648
  return inGeo.vertices[3 * index + 2];
1546
1649
  }
1547
1650
 
1651
+
1548
1652
  @Override
1549
1653
  public void setVertex(int index, float x, float y) {
1550
1654
  setVertex(index, x, y, 0);
1551
1655
  }
1552
1656
 
1657
+
1553
1658
  @Override
1554
1659
  public void setVertex(int index, float x, float y, float z) {
1555
1660
  if (openShape) {
@@ -1563,8 +1668,8 @@ public class PShapeOpenGL extends PShape {
1563
1668
  // situation, we would need a complete rethinking of the rendering architecture
1564
1669
  // in Processing :-)
1565
1670
  if (family == PATH) {
1566
- if (vertexCodes != null && vertexCodeCount > 0
1567
- && vertexCodes[index] != VERTEX) {
1671
+ if (vertexCodes != null && vertexCodeCount > 0 &&
1672
+ vertexCodes[index] != VERTEX) {
1568
1673
  PGraphics.showWarning(NOT_A_SIMPLE_VERTEX, "setVertex()");
1569
1674
  return;
1570
1675
  }
@@ -1582,6 +1687,7 @@ public class PShapeOpenGL extends PShape {
1582
1687
  markForTessellation();
1583
1688
  }
1584
1689
 
1690
+
1585
1691
  @Override
1586
1692
  public void setVertex(int index, PVector vec) {
1587
1693
  if (openShape) {
@@ -1590,8 +1696,8 @@ public class PShapeOpenGL extends PShape {
1590
1696
  }
1591
1697
 
1592
1698
  if (family == PATH) {
1593
- if (vertexCodes != null && vertexCodeCount > 0
1594
- && vertexCodes[index] != VERTEX) {
1699
+ if (vertexCodes != null && vertexCodeCount > 0 &&
1700
+ vertexCodes[index] != VERTEX) {
1595
1701
  PGraphics.showWarning(NOT_A_SIMPLE_VERTEX, "setVertex()");
1596
1702
  return;
1597
1703
  }
@@ -1608,6 +1714,7 @@ public class PShapeOpenGL extends PShape {
1608
1714
  markForTessellation();
1609
1715
  }
1610
1716
 
1717
+
1611
1718
  @Override
1612
1719
  public PVector getNormal(int index, PVector vec) {
1613
1720
  if (vec == null) {
@@ -1619,21 +1726,25 @@ public class PShapeOpenGL extends PShape {
1619
1726
  return vec;
1620
1727
  }
1621
1728
 
1729
+
1622
1730
  @Override
1623
1731
  public float getNormalX(int index) {
1624
1732
  return inGeo.normals[3 * index + 0];
1625
1733
  }
1626
1734
 
1735
+
1627
1736
  @Override
1628
1737
  public float getNormalY(int index) {
1629
1738
  return inGeo.normals[3 * index + 1];
1630
1739
  }
1631
1740
 
1741
+
1632
1742
  @Override
1633
1743
  public float getNormalZ(int index) {
1634
1744
  return inGeo.normals[3 * index + 2];
1635
1745
  }
1636
1746
 
1747
+
1637
1748
  @Override
1638
1749
  public void setNormal(int index, float nx, float ny, float nz) {
1639
1750
  if (openShape) {
@@ -1647,6 +1758,7 @@ public class PShapeOpenGL extends PShape {
1647
1758
  markForTessellation();
1648
1759
  }
1649
1760
 
1761
+
1650
1762
  @Override
1651
1763
  public void setAttrib(String name, int index, float... values) {
1652
1764
  if (openShape) {
@@ -1655,12 +1767,13 @@ public class PShapeOpenGL extends PShape {
1655
1767
  }
1656
1768
 
1657
1769
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.FLOAT,
1658
- values.length);
1770
+ values.length);
1659
1771
  float[] array = inGeo.fattribs.get(name);
1660
1772
  System.arraycopy(values, 0, array, attrib.size * index, values.length);
1661
1773
  markForTessellation();
1662
1774
  }
1663
1775
 
1776
+
1664
1777
  @Override
1665
1778
  public void setAttrib(String name, int index, int... values) {
1666
1779
  if (openShape) {
@@ -1669,12 +1782,15 @@ public class PShapeOpenGL extends PShape {
1669
1782
  }
1670
1783
 
1671
1784
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.INT,
1672
- values.length);
1785
+ values.length);
1673
1786
  int[] array = inGeo.iattribs.get(name);
1674
- System.arraycopy(values, 0, array, attrib.size * index, values.length);
1787
+ for (int i = 0; i < values.length; i++) {
1788
+ array[attrib.size * index + i] = values[i];
1789
+ }
1675
1790
  markForTessellation();
1676
1791
  }
1677
1792
 
1793
+
1678
1794
  @Override
1679
1795
  public void setAttrib(String name, int index, boolean... values) {
1680
1796
  if (openShape) {
@@ -1683,24 +1799,27 @@ public class PShapeOpenGL extends PShape {
1683
1799
  }
1684
1800
 
1685
1801
  VertexAttribute attrib = attribImpl(name, VertexAttribute.OTHER, PGL.BOOL,
1686
- values.length);
1802
+ values.length);
1687
1803
  byte[] array = inGeo.battribs.get(name);
1688
1804
  for (int i = 0; i < values.length; i++) {
1689
- array[attrib.size * index + i] = (byte) (values[i] ? 1 : 0);
1805
+ array[attrib.size * index + i] = (byte)(values[i]?1:0);
1690
1806
  }
1691
1807
  markForTessellation();
1692
1808
  }
1693
1809
 
1810
+
1694
1811
  @Override
1695
1812
  public float getTextureU(int index) {
1696
1813
  return inGeo.texcoords[2 * index + 0];
1697
1814
  }
1698
1815
 
1816
+
1699
1817
  @Override
1700
1818
  public float getTextureV(int index) {
1701
1819
  return inGeo.texcoords[2 * index + 1];
1702
1820
  }
1703
1821
 
1822
+
1704
1823
  @Override
1705
1824
  public void setTextureUV(int index, float u, float v) {
1706
1825
  if (openShape) {
@@ -1718,6 +1837,7 @@ public class PShapeOpenGL extends PShape {
1718
1837
  markForTessellation();
1719
1838
  }
1720
1839
 
1840
+
1721
1841
  @Override
1722
1842
  public int getFill(int index) {
1723
1843
  if (family != GROUP && image == null) {
@@ -1727,6 +1847,7 @@ public class PShapeOpenGL extends PShape {
1727
1847
  }
1728
1848
  }
1729
1849
 
1850
+
1730
1851
  @Override
1731
1852
  public void setFill(boolean fill) {
1732
1853
  if (openShape) {
@@ -1745,6 +1866,7 @@ public class PShapeOpenGL extends PShape {
1745
1866
  this.fill = fill;
1746
1867
  }
1747
1868
 
1869
+
1748
1870
  @Override
1749
1871
  public void setFill(int fill) {
1750
1872
  if (openShape) {
@@ -1762,30 +1884,25 @@ public class PShapeOpenGL extends PShape {
1762
1884
  }
1763
1885
  }
1764
1886
 
1887
+
1765
1888
  protected void setFillImpl(int fill) {
1766
- if (fillColor == fill) {
1767
- return;
1768
- }
1889
+ if (fillColor == fill) return;
1769
1890
  fillColor = fill;
1770
1891
 
1771
1892
  if (image == null) {
1772
1893
  Arrays.fill(inGeo.colors, 0, inGeo.vertexCount,
1773
- PGL.javaToNativeARGB(fillColor));
1894
+ PGL.javaToNativeARGB(fillColor));
1774
1895
  if (shapeCreated && tessellated && hasPolys) {
1775
1896
  if (is3D()) {
1776
1897
  Arrays.fill(tessGeo.polyColors, firstPolyVertex, lastPolyVertex + 1,
1777
- PGL.javaToNativeARGB(fillColor));
1898
+ PGL.javaToNativeARGB(fillColor));
1778
1899
  root.setModifiedPolyColors(firstPolyVertex, lastPolyVertex);
1779
1900
  } else if (is2D()) {
1780
1901
  int last1 = lastPolyVertex + 1;
1781
- if (-1 < firstLineVertex) {
1782
- last1 = firstLineVertex;
1783
- }
1784
- if (-1 < firstPointVertex) {
1785
- last1 = firstPointVertex;
1786
- }
1902
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
1903
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
1787
1904
  Arrays.fill(tessGeo.polyColors, firstPolyVertex, last1,
1788
- PGL.javaToNativeARGB(fillColor));
1905
+ PGL.javaToNativeARGB(fillColor));
1789
1906
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
1790
1907
  }
1791
1908
  }
@@ -1801,6 +1918,7 @@ public class PShapeOpenGL extends PShape {
1801
1918
  }
1802
1919
  }
1803
1920
 
1921
+
1804
1922
  @Override
1805
1923
  public void setFill(int index, int fill) {
1806
1924
  if (openShape) {
@@ -1814,6 +1932,7 @@ public class PShapeOpenGL extends PShape {
1814
1932
  }
1815
1933
  }
1816
1934
 
1935
+
1817
1936
  @Override
1818
1937
  public int getTint(int index) {
1819
1938
  if (family != GROUP && image != null) {
@@ -1823,6 +1942,7 @@ public class PShapeOpenGL extends PShape {
1823
1942
  }
1824
1943
  }
1825
1944
 
1945
+
1826
1946
  @Override
1827
1947
  public void setTint(boolean tint) {
1828
1948
  if (openShape) {
@@ -1841,6 +1961,7 @@ public class PShapeOpenGL extends PShape {
1841
1961
  this.tint = tint;
1842
1962
  }
1843
1963
 
1964
+
1844
1965
  @Override
1845
1966
  public void setTint(int tint) {
1846
1967
  if (openShape) {
@@ -1858,36 +1979,32 @@ public class PShapeOpenGL extends PShape {
1858
1979
  }
1859
1980
  }
1860
1981
 
1982
+
1861
1983
  protected void setTintImpl(int tint) {
1862
- if (tintColor == tint) {
1863
- return;
1864
- }
1984
+ if (tintColor == tint) return;
1865
1985
  tintColor = tint;
1866
1986
 
1867
1987
  if (image != null) {
1868
1988
  Arrays.fill(inGeo.colors, 0, inGeo.vertexCount,
1869
- PGL.javaToNativeARGB(tintColor));
1989
+ PGL.javaToNativeARGB(tintColor));
1870
1990
  if (shapeCreated && tessellated && hasPolys) {
1871
1991
  if (is3D()) {
1872
1992
  Arrays.fill(tessGeo.polyColors, firstPolyVertex, lastPolyVertex + 1,
1873
- PGL.javaToNativeARGB(tintColor));
1993
+ PGL.javaToNativeARGB(tintColor));
1874
1994
  root.setModifiedPolyColors(firstPolyVertex, lastPolyVertex);
1875
1995
  } else if (is2D()) {
1876
1996
  int last1 = lastPolyVertex + 1;
1877
- if (-1 < firstLineVertex) {
1878
- last1 = firstLineVertex;
1879
- }
1880
- if (-1 < firstPointVertex) {
1881
- last1 = firstPointVertex;
1882
- }
1997
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
1998
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
1883
1999
  Arrays.fill(tessGeo.polyColors, firstPolyVertex, last1,
1884
- PGL.javaToNativeARGB(tintColor));
2000
+ PGL.javaToNativeARGB(tintColor));
1885
2001
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
1886
2002
  }
1887
2003
  }
1888
2004
  }
1889
2005
  }
1890
2006
 
2007
+
1891
2008
  @Override
1892
2009
  public void setTint(int index, int tint) {
1893
2010
  if (openShape) {
@@ -1901,6 +2018,7 @@ public class PShapeOpenGL extends PShape {
1901
2018
  }
1902
2019
  }
1903
2020
 
2021
+
1904
2022
  @Override
1905
2023
  public int getStroke(int index) {
1906
2024
  if (family != GROUP) {
@@ -1910,6 +2028,7 @@ public class PShapeOpenGL extends PShape {
1910
2028
  }
1911
2029
  }
1912
2030
 
2031
+
1913
2032
  @Override
1914
2033
  public void setStroke(boolean stroke) {
1915
2034
  if (openShape) {
@@ -1928,6 +2047,7 @@ public class PShapeOpenGL extends PShape {
1928
2047
  }
1929
2048
  }
1930
2049
 
2050
+
1931
2051
  protected void setStrokeImpl(boolean stroke) {
1932
2052
  if (this.stroke != stroke) {
1933
2053
  if (stroke) {
@@ -1941,13 +2061,14 @@ public class PShapeOpenGL extends PShape {
1941
2061
 
1942
2062
  markForTessellation();
1943
2063
  if (is2D() && parent != null) {
1944
- ((PShapeOpenGL) parent).strokedTexture(stroke && image != null);
2064
+ ((PShapeOpenGL)parent).strokedTexture(stroke && image != null);
1945
2065
  }
1946
2066
 
1947
2067
  this.stroke = stroke;
1948
2068
  }
1949
2069
  }
1950
2070
 
2071
+
1951
2072
  @Override
1952
2073
  public void setStroke(int stroke) {
1953
2074
  if (openShape) {
@@ -1965,40 +2086,40 @@ public class PShapeOpenGL extends PShape {
1965
2086
  }
1966
2087
  }
1967
2088
 
2089
+
1968
2090
  protected void setStrokeImpl(int stroke) {
1969
- if (strokeColor == stroke) {
1970
- return;
1971
- }
2091
+ if (strokeColor == stroke) return;
1972
2092
  strokeColor = stroke;
1973
2093
 
1974
2094
  Arrays.fill(inGeo.strokeColors, 0, inGeo.vertexCount,
1975
- PGL.javaToNativeARGB(strokeColor));
2095
+ PGL.javaToNativeARGB(strokeColor));
1976
2096
  if (shapeCreated && tessellated && (hasLines || hasPoints)) {
1977
2097
  if (hasLines) {
1978
2098
  if (is3D()) {
1979
2099
  Arrays.fill(tessGeo.lineColors, firstLineVertex, lastLineVertex + 1,
1980
- PGL.javaToNativeARGB(strokeColor));
2100
+ PGL.javaToNativeARGB(strokeColor));
1981
2101
  root.setModifiedLineColors(firstLineVertex, lastLineVertex);
1982
2102
  } else if (is2D()) {
1983
2103
  Arrays.fill(tessGeo.polyColors, firstLineVertex, lastLineVertex + 1,
1984
- PGL.javaToNativeARGB(strokeColor));
2104
+ PGL.javaToNativeARGB(strokeColor));
1985
2105
  root.setModifiedPolyColors(firstLineVertex, lastLineVertex);
1986
2106
  }
1987
2107
  }
1988
2108
  if (hasPoints) {
1989
2109
  if (is3D()) {
1990
2110
  Arrays.fill(tessGeo.pointColors, firstPointVertex, lastPointVertex + 1,
1991
- PGL.javaToNativeARGB(strokeColor));
2111
+ PGL.javaToNativeARGB(strokeColor));
1992
2112
  root.setModifiedPointColors(firstPointVertex, lastPointVertex);
1993
2113
  } else if (is2D()) {
1994
2114
  Arrays.fill(tessGeo.polyColors, firstPointVertex, lastPointVertex + 1,
1995
- PGL.javaToNativeARGB(strokeColor));
2115
+ PGL.javaToNativeARGB(strokeColor));
1996
2116
  root.setModifiedPolyColors(firstPointVertex, lastPointVertex);
1997
2117
  }
1998
2118
  }
1999
2119
  }
2000
2120
  }
2001
2121
 
2122
+
2002
2123
  @Override
2003
2124
  public void setStroke(int index, int stroke) {
2004
2125
  if (openShape) {
@@ -2010,6 +2131,7 @@ public class PShapeOpenGL extends PShape {
2010
2131
  markForTessellation();
2011
2132
  }
2012
2133
 
2134
+
2013
2135
  @Override
2014
2136
  public float getStrokeWeight(int index) {
2015
2137
  if (family != GROUP) {
@@ -2019,6 +2141,7 @@ public class PShapeOpenGL extends PShape {
2019
2141
  }
2020
2142
  }
2021
2143
 
2144
+
2022
2145
  @Override
2023
2146
  public void setStrokeWeight(float weight) {
2024
2147
  if (openShape) {
@@ -2036,10 +2159,9 @@ public class PShapeOpenGL extends PShape {
2036
2159
  }
2037
2160
  }
2038
2161
 
2162
+
2039
2163
  protected void setStrokeWeightImpl(float weight) {
2040
- if (PGraphicsOpenGL.same(strokeWeight, weight)) {
2041
- return;
2042
- }
2164
+ if (PGraphicsOpenGL.same(strokeWeight, weight)) return;
2043
2165
  float oldWeight = strokeWeight;
2044
2166
  strokeWeight = weight;
2045
2167
 
@@ -2076,6 +2198,7 @@ public class PShapeOpenGL extends PShape {
2076
2198
  }
2077
2199
  }
2078
2200
 
2201
+
2079
2202
  @Override
2080
2203
  public void setStrokeWeight(int index, float weight) {
2081
2204
  if (openShape) {
@@ -2087,6 +2210,7 @@ public class PShapeOpenGL extends PShape {
2087
2210
  markForTessellation();
2088
2211
  }
2089
2212
 
2213
+
2090
2214
  @Override
2091
2215
  public void setStrokeJoin(int join) {
2092
2216
  if (openShape) {
@@ -2110,6 +2234,7 @@ public class PShapeOpenGL extends PShape {
2110
2234
  }
2111
2235
  }
2112
2236
 
2237
+
2113
2238
  @Override
2114
2239
  public void setStrokeCap(int cap) {
2115
2240
  if (openShape) {
@@ -2133,6 +2258,7 @@ public class PShapeOpenGL extends PShape {
2133
2258
  }
2134
2259
  }
2135
2260
 
2261
+
2136
2262
  @Override
2137
2263
  public int getAmbient(int index) {
2138
2264
  if (family != GROUP) {
@@ -2142,6 +2268,7 @@ public class PShapeOpenGL extends PShape {
2142
2268
  }
2143
2269
  }
2144
2270
 
2271
+
2145
2272
  @Override
2146
2273
  public void setAmbient(int ambient) {
2147
2274
  if (openShape) {
@@ -2159,35 +2286,31 @@ public class PShapeOpenGL extends PShape {
2159
2286
  }
2160
2287
  }
2161
2288
 
2289
+
2162
2290
  protected void setAmbientImpl(int ambient) {
2163
- if (ambientColor == ambient) {
2164
- return;
2165
- }
2291
+ if (ambientColor == ambient) return;
2166
2292
  ambientColor = ambient;
2167
2293
 
2168
2294
  Arrays.fill(inGeo.ambient, 0, inGeo.vertexCount,
2169
- PGL.javaToNativeARGB(ambientColor));
2295
+ PGL.javaToNativeARGB(ambientColor));
2170
2296
  if (shapeCreated && tessellated && hasPolys) {
2171
2297
  if (is3D()) {
2172
2298
  Arrays.fill(tessGeo.polyAmbient, firstPolyVertex, lastPolyVertex + 1,
2173
- PGL.javaToNativeARGB(ambientColor));
2299
+ PGL.javaToNativeARGB(ambientColor));
2174
2300
  root.setModifiedPolyAmbient(firstPolyVertex, lastPolyVertex);
2175
2301
  } else if (is2D()) {
2176
2302
  int last1 = lastPolyVertex + 1;
2177
- if (-1 < firstLineVertex) {
2178
- last1 = firstLineVertex;
2179
- }
2180
- if (-1 < firstPointVertex) {
2181
- last1 = firstPointVertex;
2182
- }
2303
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2304
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2183
2305
  Arrays.fill(tessGeo.polyAmbient, firstPolyVertex, last1,
2184
- PGL.javaToNativeARGB(ambientColor));
2306
+ PGL.javaToNativeARGB(ambientColor));
2185
2307
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
2186
2308
  }
2187
2309
  }
2188
2310
  setAmbient = true;
2189
2311
  }
2190
2312
 
2313
+
2191
2314
  @Override
2192
2315
  public void setAmbient(int index, int ambient) {
2193
2316
  if (openShape) {
@@ -2200,6 +2323,7 @@ public class PShapeOpenGL extends PShape {
2200
2323
  setAmbient = true;
2201
2324
  }
2202
2325
 
2326
+
2203
2327
  @Override
2204
2328
  public int getSpecular(int index) {
2205
2329
  if (family == GROUP) {
@@ -2209,6 +2333,7 @@ public class PShapeOpenGL extends PShape {
2209
2333
  }
2210
2334
  }
2211
2335
 
2336
+
2212
2337
  @Override
2213
2338
  public void setSpecular(int specular) {
2214
2339
  if (openShape) {
@@ -2226,34 +2351,30 @@ public class PShapeOpenGL extends PShape {
2226
2351
  }
2227
2352
  }
2228
2353
 
2354
+
2229
2355
  protected void setSpecularImpl(int specular) {
2230
- if (specularColor == specular) {
2231
- return;
2232
- }
2356
+ if (specularColor == specular) return;
2233
2357
  specularColor = specular;
2234
2358
 
2235
2359
  Arrays.fill(inGeo.specular, 0, inGeo.vertexCount,
2236
- PGL.javaToNativeARGB(specularColor));
2360
+ PGL.javaToNativeARGB(specularColor));
2237
2361
  if (shapeCreated && tessellated && hasPolys) {
2238
2362
  if (is3D()) {
2239
2363
  Arrays.fill(tessGeo.polySpecular, firstPolyVertex, lastPolyVertex + 1,
2240
- PGL.javaToNativeARGB(specularColor));
2364
+ PGL.javaToNativeARGB(specularColor));
2241
2365
  root.setModifiedPolySpecular(firstPolyVertex, lastPolyVertex);
2242
2366
  } else if (is2D()) {
2243
2367
  int last1 = lastPolyVertex + 1;
2244
- if (-1 < firstLineVertex) {
2245
- last1 = firstLineVertex;
2246
- }
2247
- if (-1 < firstPointVertex) {
2248
- last1 = firstPointVertex;
2249
- }
2368
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2369
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2250
2370
  Arrays.fill(tessGeo.polySpecular, firstPolyVertex, last1,
2251
- PGL.javaToNativeARGB(specularColor));
2371
+ PGL.javaToNativeARGB(specularColor));
2252
2372
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
2253
2373
  }
2254
2374
  }
2255
2375
  }
2256
2376
 
2377
+
2257
2378
  @Override
2258
2379
  public void setSpecular(int index, int specular) {
2259
2380
  if (openShape) {
@@ -2265,6 +2386,7 @@ public class PShapeOpenGL extends PShape {
2265
2386
  markForTessellation();
2266
2387
  }
2267
2388
 
2389
+
2268
2390
  @Override
2269
2391
  public int getEmissive(int index) {
2270
2392
  if (family == GROUP) {
@@ -2274,6 +2396,7 @@ public class PShapeOpenGL extends PShape {
2274
2396
  }
2275
2397
  }
2276
2398
 
2399
+
2277
2400
  @Override
2278
2401
  public void setEmissive(int emissive) {
2279
2402
  if (openShape) {
@@ -2291,34 +2414,30 @@ public class PShapeOpenGL extends PShape {
2291
2414
  }
2292
2415
  }
2293
2416
 
2417
+
2294
2418
  protected void setEmissiveImpl(int emissive) {
2295
- if (emissiveColor == emissive) {
2296
- return;
2297
- }
2419
+ if (emissiveColor == emissive) return;
2298
2420
  emissiveColor = emissive;
2299
2421
 
2300
2422
  Arrays.fill(inGeo.emissive, 0, inGeo.vertexCount,
2301
- PGL.javaToNativeARGB(emissiveColor));
2423
+ PGL.javaToNativeARGB(emissiveColor));
2302
2424
  if (shapeCreated && tessellated && 0 < tessGeo.polyVertexCount) {
2303
2425
  if (is3D()) {
2304
2426
  Arrays.fill(tessGeo.polyEmissive, firstPolyVertex, lastPolyVertex + 1,
2305
- PGL.javaToNativeARGB(emissiveColor));
2427
+ PGL.javaToNativeARGB(emissiveColor));
2306
2428
  root.setModifiedPolyEmissive(firstPolyVertex, lastPolyVertex);
2307
2429
  } else if (is2D()) {
2308
2430
  int last1 = lastPolyVertex + 1;
2309
- if (-1 < firstLineVertex) {
2310
- last1 = firstLineVertex;
2311
- }
2312
- if (-1 < firstPointVertex) {
2313
- last1 = firstPointVertex;
2314
- }
2431
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2432
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2315
2433
  Arrays.fill(tessGeo.polyEmissive, firstPolyVertex, last1,
2316
- PGL.javaToNativeARGB(emissiveColor));
2434
+ PGL.javaToNativeARGB(emissiveColor));
2317
2435
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
2318
2436
  }
2319
2437
  }
2320
2438
  }
2321
2439
 
2440
+
2322
2441
  @Override
2323
2442
  public void setEmissive(int index, int emissive) {
2324
2443
  if (openShape) {
@@ -2330,6 +2449,7 @@ public class PShapeOpenGL extends PShape {
2330
2449
  markForTessellation();
2331
2450
  }
2332
2451
 
2452
+
2333
2453
  @Override
2334
2454
  public float getShininess(int index) {
2335
2455
  if (family == GROUP) {
@@ -2339,6 +2459,7 @@ public class PShapeOpenGL extends PShape {
2339
2459
  }
2340
2460
  }
2341
2461
 
2462
+
2342
2463
  @Override
2343
2464
  public void setShininess(float shininess) {
2344
2465
  if (openShape) {
@@ -2356,32 +2477,28 @@ public class PShapeOpenGL extends PShape {
2356
2477
  }
2357
2478
  }
2358
2479
 
2480
+
2359
2481
  protected void setShininessImpl(float shininess) {
2360
- if (PGraphicsOpenGL.same(this.shininess, shininess)) {
2361
- return;
2362
- }
2482
+ if (PGraphicsOpenGL.same(this.shininess, shininess)) return;
2363
2483
  this.shininess = shininess;
2364
2484
 
2365
2485
  Arrays.fill(inGeo.shininess, 0, inGeo.vertexCount, shininess);
2366
2486
  if (shapeCreated && tessellated && hasPolys) {
2367
2487
  if (is3D()) {
2368
2488
  Arrays.fill(tessGeo.polyShininess, firstPolyVertex, lastPolyVertex + 1,
2369
- shininess);
2489
+ shininess);
2370
2490
  root.setModifiedPolyShininess(firstPolyVertex, lastPolyVertex);
2371
2491
  } else if (is2D()) {
2372
2492
  int last1 = lastPolyVertex + 1;
2373
- if (-1 < firstLineVertex) {
2374
- last1 = firstLineVertex;
2375
- }
2376
- if (-1 < firstPointVertex) {
2377
- last1 = firstPointVertex;
2378
- }
2493
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2494
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2379
2495
  Arrays.fill(tessGeo.polyShininess, firstPolyVertex, last1, shininess);
2380
2496
  root.setModifiedPolyColors(firstPolyVertex, last1 - 1);
2381
2497
  }
2382
2498
  }
2383
2499
  }
2384
2500
 
2501
+
2385
2502
  @Override
2386
2503
  public void setShininess(int index, float shine) {
2387
2504
  if (openShape) {
@@ -2394,30 +2511,31 @@ public class PShapeOpenGL extends PShape {
2394
2511
  }
2395
2512
 
2396
2513
  ///////////////////////////////////////////////////////////
2514
+
2397
2515
  //
2516
+
2398
2517
  // Vertex codes
2518
+
2519
+
2399
2520
  @Override
2400
2521
  public int[] getVertexCodes() {
2401
- if (family == GROUP) {
2402
- return null;
2403
- } else {
2522
+ if (family == GROUP) return null;
2523
+ else {
2404
2524
  if (family == PRIMITIVE || family == PATH) {
2405
2525
  // the input geometry of primitive and path shapes is built during
2406
2526
  // tessellation
2407
2527
  updateTessellation();
2408
2528
  }
2409
- if (inGeo.codes == null) {
2410
- return null;
2411
- }
2529
+ if (inGeo.codes == null) return null;
2412
2530
  return inGeo.codes;
2413
2531
  }
2414
2532
  }
2415
2533
 
2534
+
2416
2535
  @Override
2417
2536
  public int getVertexCodeCount() {
2418
- if (family == GROUP) {
2419
- return 0;
2420
- } else {
2537
+ if (family == GROUP) return 0;
2538
+ else {
2421
2539
  if (family == PRIMITIVE || family == PATH) {
2422
2540
  // the input geometry of primitive and path shapes is built during
2423
2541
  // tessellation
@@ -2427,6 +2545,7 @@ public class PShapeOpenGL extends PShape {
2427
2545
  }
2428
2546
  }
2429
2547
 
2548
+
2430
2549
  /**
2431
2550
  * One of VERTEX, BEZIER_VERTEX, CURVE_VERTEX, or BREAK.
2432
2551
  */
@@ -2435,9 +2554,14 @@ public class PShapeOpenGL extends PShape {
2435
2554
  return inGeo.codes[index];
2436
2555
  }
2437
2556
 
2557
+
2438
2558
  ///////////////////////////////////////////////////////////
2559
+
2439
2560
  //
2561
+
2440
2562
  // Tessellated geometry getter.
2563
+
2564
+
2441
2565
  @Override
2442
2566
  public PShape getTessellation() {
2443
2567
  updateTessellation();
@@ -2540,107 +2664,88 @@ public class PShapeOpenGL extends PShape {
2540
2664
  public float[] getTessellation(int kind, int data) {
2541
2665
  updateTessellation();
2542
2666
 
2543
- switch (kind) {
2544
- case TRIANGLES:
2545
- switch (data) {
2546
- case POSITION:
2547
- if (is3D()) {
2548
- root.setModifiedPolyVertices(firstPolyVertex, lastPolyVertex);
2549
- } else if (is2D()) {
2550
- int last1 = lastPolyVertex + 1;
2551
- if (-1 < firstLineVertex) {
2552
- last1 = firstLineVertex;
2553
- }
2554
- if (-1 < firstPointVertex) {
2555
- last1 = firstPointVertex;
2556
- }
2557
- root.setModifiedPolyVertices(firstPolyVertex, last1 - 1);
2558
- }
2559
- return tessGeo.polyVertices;
2560
- case NORMAL:
2561
- if (is3D()) {
2562
- root.setModifiedPolyNormals(firstPolyVertex, lastPolyVertex);
2563
- } else if (is2D()) {
2564
- int last1 = lastPolyVertex + 1;
2565
- if (-1 < firstLineVertex) {
2566
- last1 = firstLineVertex;
2567
- }
2568
- if (-1 < firstPointVertex) {
2569
- last1 = firstPointVertex;
2570
- }
2571
- root.setModifiedPolyNormals(firstPolyVertex, last1 - 1);
2572
- }
2573
- return tessGeo.polyNormals;
2574
- case TEXCOORD:
2575
- if (is3D()) {
2576
- root.setModifiedPolyTexCoords(firstPolyVertex, lastPolyVertex);
2577
- } else if (is2D()) {
2578
- int last1 = lastPolyVertex + 1;
2579
- if (-1 < firstLineVertex) {
2580
- last1 = firstLineVertex;
2581
- }
2582
- if (-1 < firstPointVertex) {
2583
- last1 = firstPointVertex;
2584
- }
2585
- root.setModifiedPolyTexCoords(firstPolyVertex, last1 - 1);
2586
- }
2587
- return tessGeo.polyTexCoords;
2588
- default:
2589
- break;
2667
+ if (kind == TRIANGLES) {
2668
+ if (data == POSITION) {
2669
+ if (is3D()) {
2670
+ root.setModifiedPolyVertices(firstPolyVertex, lastPolyVertex);
2671
+ } else if (is2D()) {
2672
+ int last1 = lastPolyVertex + 1;
2673
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2674
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2675
+ root.setModifiedPolyVertices(firstPolyVertex, last1 - 1);
2590
2676
  }
2591
- break;
2592
-
2593
- case LINES:
2594
- if (data == POSITION) {
2595
- if (is3D()) {
2596
- root.setModifiedLineVertices(firstLineVertex, lastLineVertex);
2597
- } else if (is2D()) {
2598
- root.setModifiedPolyVertices(firstLineVertex, lastLineVertex);
2599
- }
2600
- return tessGeo.lineVertices;
2601
- } else if (data == DIRECTION) {
2602
- if (is2D()) {
2603
- root.setModifiedLineAttributes(firstLineVertex, lastLineVertex);
2604
- }
2605
- return tessGeo.lineDirections;
2677
+ return tessGeo.polyVertices;
2678
+ } else if (data == NORMAL) {
2679
+ if (is3D()) {
2680
+ root.setModifiedPolyNormals(firstPolyVertex, lastPolyVertex);
2681
+ } else if (is2D()) {
2682
+ int last1 = lastPolyVertex + 1;
2683
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2684
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2685
+ root.setModifiedPolyNormals(firstPolyVertex, last1 - 1);
2606
2686
  }
2607
- break;
2608
- case POINTS:
2609
- if (data == POSITION) {
2610
- if (is3D()) {
2611
- root.setModifiedPointVertices(firstPointVertex, lastPointVertex);
2612
- } else if (is2D()) {
2613
- root.setModifiedPolyVertices(firstPointVertex, lastPointVertex);
2614
- }
2615
- return tessGeo.pointVertices;
2616
- } else if (data == OFFSET) {
2617
- if (is2D()) {
2618
- root.setModifiedPointAttributes(firstPointVertex, lastPointVertex);
2619
- }
2620
- return tessGeo.pointOffsets;
2687
+ return tessGeo.polyNormals;
2688
+ } else if (data == TEXCOORD) {
2689
+ if (is3D()) {
2690
+ root.setModifiedPolyTexCoords(firstPolyVertex, lastPolyVertex);
2691
+ } else if (is2D()) {
2692
+ int last1 = lastPolyVertex + 1;
2693
+ if (-1 < firstLineVertex) last1 = firstLineVertex;
2694
+ if (-1 < firstPointVertex) last1 = firstPointVertex;
2695
+ root.setModifiedPolyTexCoords(firstPolyVertex, last1 - 1);
2621
2696
  }
2622
- break;
2623
- default:
2624
- break;
2697
+ return tessGeo.polyTexCoords;
2698
+ }
2699
+ } else if (kind == LINES) {
2700
+ if (data == POSITION) {
2701
+ if (is3D()) {
2702
+ root.setModifiedLineVertices(firstLineVertex, lastLineVertex);
2703
+ } else if (is2D()) {
2704
+ root.setModifiedPolyVertices(firstLineVertex, lastLineVertex);
2705
+ }
2706
+ return tessGeo.lineVertices;
2707
+ } else if (data == DIRECTION) {
2708
+ if (is2D()) {
2709
+ root.setModifiedLineAttributes(firstLineVertex, lastLineVertex);
2710
+ }
2711
+ return tessGeo.lineDirections;
2712
+ }
2713
+ } else if (kind == POINTS) {
2714
+ if (data == POSITION) {
2715
+ if (is3D()) {
2716
+ root.setModifiedPointVertices(firstPointVertex, lastPointVertex);
2717
+ } else if (is2D()) {
2718
+ root.setModifiedPolyVertices(firstPointVertex, lastPointVertex);
2719
+ }
2720
+ return tessGeo.pointVertices;
2721
+ } else if (data == OFFSET) {
2722
+ if (is2D()) {
2723
+ root.setModifiedPointAttributes(firstPointVertex, lastPointVertex);
2724
+ }
2725
+ return tessGeo.pointOffsets;
2726
+ }
2625
2727
  }
2626
2728
  return null;
2627
2729
  }
2628
2730
 
2629
2731
  ///////////////////////////////////////////////////////////
2732
+
2630
2733
  //
2734
+
2631
2735
  // Geometry utils
2736
+
2632
2737
  // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
2633
2738
  @Override
2634
2739
  public boolean contains(float x, float y) {
2635
2740
  if (family == PATH) {
2636
2741
  boolean c = false;
2637
- for (int i = 0, j = inGeo.vertexCount - 1; i < inGeo.vertexCount; j = i++) {
2638
- if (((inGeo.vertices[3 * i + 1] > y) != (inGeo.vertices[3 * j + 1] > y))
2639
- && (x
2640
- < (inGeo.vertices[3 * j] - inGeo.vertices[3 * i])
2641
- * (y - inGeo.vertices[3 * i + 1])
2642
- / (inGeo.vertices[3 * j + 1] - inGeo.vertices[3 * i + 1])
2643
- + inGeo.vertices[3 * i])) {
2742
+ for (int i = 0, j = inGeo.vertexCount-1; i < inGeo.vertexCount; j = i++) {
2743
+ if (((inGeo.vertices[3 * i + 1] > y) != (inGeo.vertices[3 * j + 1] > y)) &&
2744
+ (x <
2745
+ (inGeo.vertices[3 * j]-inGeo.vertices[3 * i]) *
2746
+ (y-inGeo.vertices[3 * i + 1]) /
2747
+ (inGeo.vertices[3 * j + 1]-inGeo.vertices[3 * i + 1]) +
2748
+ inGeo.vertices[3 * i])) {
2644
2749
  c = !c;
2645
2750
  }
2646
2751
  }
@@ -2650,9 +2755,14 @@ public class PShapeOpenGL extends PShape {
2650
2755
  }
2651
2756
  }
2652
2757
 
2758
+
2653
2759
  ///////////////////////////////////////////////////////////
2760
+
2654
2761
  //
2762
+
2655
2763
  // Tessellation
2764
+
2765
+
2656
2766
  protected void updateTessellation() {
2657
2767
  if (!root.tessellated) {
2658
2768
  root.tessellate();
@@ -2662,11 +2772,13 @@ public class PShapeOpenGL extends PShape {
2662
2772
  }
2663
2773
  }
2664
2774
 
2775
+
2665
2776
  protected void markForTessellation() {
2666
2777
  root.tessellated = false;
2667
2778
  tessellated = false;
2668
2779
  }
2669
2780
 
2781
+
2670
2782
  protected void initModified() {
2671
2783
  modified = false;
2672
2784
 
@@ -2719,6 +2831,7 @@ public class PShapeOpenGL extends PShape {
2719
2831
  lastModifiedPointAttribute = PConstants.MIN_INT;
2720
2832
  }
2721
2833
 
2834
+
2722
2835
  protected void tessellate() {
2723
2836
  if (root == this && parent == null) { // Root shape
2724
2837
  boolean initAttr = false;
@@ -2750,6 +2863,7 @@ public class PShapeOpenGL extends PShape {
2750
2863
  }
2751
2864
  }
2752
2865
 
2866
+
2753
2867
  protected void collectPolyAttribs() {
2754
2868
  AttributeMap rootAttribs = root.polyAttribs;
2755
2869
  tessGeo = root.tessGeo;
@@ -2816,141 +2930,93 @@ public class PShapeOpenGL extends PShape {
2816
2930
  tessellator.setTransform(matrix);
2817
2931
  tessellator.set3D(is3D());
2818
2932
 
2819
- switch (family) {
2820
- case GEOMETRY:
2821
- switch (kind) {
2822
- case POINTS:
2823
- tessellator.tessellatePoints();
2824
- break;
2825
- case LINES:
2826
- tessellator.tessellateLines();
2827
- break;
2828
- case LINE_STRIP:
2829
- tessellator.tessellateLineStrip();
2830
- break;
2831
- case LINE_LOOP:
2832
- tessellator.tessellateLineLoop();
2833
- break;
2834
- case TRIANGLE:
2835
- case TRIANGLES:
2836
- if (stroke) {
2837
- inGeo.addTrianglesEdges();
2838
- }
2839
- if (normalMode == NORMAL_MODE_AUTO) {
2840
- inGeo.calcTrianglesNormals();
2841
- }
2842
- tessellator.tessellateTriangles();
2843
- break;
2844
- case TRIANGLE_FAN:
2845
- if (stroke) {
2846
- inGeo.addTriangleFanEdges();
2847
- }
2848
- if (normalMode == NORMAL_MODE_AUTO) {
2849
- inGeo.calcTriangleFanNormals();
2850
- }
2851
- tessellator.tessellateTriangleFan();
2852
- break;
2853
- case TRIANGLE_STRIP:
2854
- if (stroke) {
2855
- inGeo.addTriangleStripEdges();
2856
- }
2857
- if (normalMode == NORMAL_MODE_AUTO) {
2858
- inGeo.calcTriangleStripNormals();
2859
- }
2860
- tessellator.tessellateTriangleStrip();
2861
- break;
2862
- case QUAD:
2863
- case QUADS:
2864
- if (stroke) {
2865
- inGeo.addQuadsEdges();
2866
- }
2867
- if (normalMode == NORMAL_MODE_AUTO) {
2868
- inGeo.calcQuadsNormals();
2869
- }
2870
- tessellator.tessellateQuads();
2871
- break;
2872
- case QUAD_STRIP:
2873
- if (stroke) {
2874
- inGeo.addQuadStripEdges();
2875
- }
2876
- if (normalMode == NORMAL_MODE_AUTO) {
2877
- inGeo.calcQuadStripNormals();
2878
- }
2879
- tessellator.tessellateQuadStrip();
2880
- break;
2881
- case POLYGON:
2882
- boolean bez = inGeo.hasBezierVertex();
2883
- boolean quad = inGeo.hasQuadraticVertex();
2884
- boolean curv = inGeo.hasCurveVertex();
2885
- if (bez || quad) {
2886
- saveBezierVertexSettings();
2887
- }
2888
- if (curv) {
2889
- saveCurveVertexSettings();
2890
- tessellator.resetCurveVertexCount();
2891
- }
2892
- tessellator.tessellatePolygon(solid, close,
2893
- normalMode == NORMAL_MODE_AUTO);
2894
- if (bez || quad) {
2895
- restoreBezierVertexSettings();
2896
- }
2897
- if (curv) {
2898
- restoreCurveVertexSettings();
2899
- }
2900
- break;
2901
- default:
2902
- break;
2933
+ if (family == GEOMETRY) {
2934
+ if (kind == POINTS) {
2935
+ tessellator.tessellatePoints();
2936
+ } else if (kind == LINES) {
2937
+ tessellator.tessellateLines();
2938
+ } else if (kind == LINE_STRIP) {
2939
+ tessellator.tessellateLineStrip();
2940
+ } else if (kind == LINE_LOOP) {
2941
+ tessellator.tessellateLineLoop();
2942
+ } else if (kind == TRIANGLE || kind == TRIANGLES) {
2943
+ if (stroke) inGeo.addTrianglesEdges();
2944
+ if (normalMode == NORMAL_MODE_AUTO) inGeo.calcTrianglesNormals();
2945
+ tessellator.tessellateTriangles();
2946
+ } else if (kind == TRIANGLE_FAN) {
2947
+ if (stroke) inGeo.addTriangleFanEdges();
2948
+ if (normalMode == NORMAL_MODE_AUTO) inGeo.calcTriangleFanNormals();
2949
+ tessellator.tessellateTriangleFan();
2950
+ } else if (kind == TRIANGLE_STRIP) {
2951
+ if (stroke) inGeo.addTriangleStripEdges();
2952
+ if (normalMode == NORMAL_MODE_AUTO) inGeo.calcTriangleStripNormals();
2953
+ tessellator.tessellateTriangleStrip();
2954
+ } else if (kind == QUAD || kind == QUADS) {
2955
+ if (stroke) inGeo.addQuadsEdges();
2956
+ if (normalMode == NORMAL_MODE_AUTO) inGeo.calcQuadsNormals();
2957
+ tessellator.tessellateQuads();
2958
+ } else if (kind == QUAD_STRIP) {
2959
+ if (stroke) inGeo.addQuadStripEdges();
2960
+ if (normalMode == NORMAL_MODE_AUTO) inGeo.calcQuadStripNormals();
2961
+ tessellator.tessellateQuadStrip();
2962
+ } else if (kind == POLYGON) {
2963
+ boolean bez = inGeo.hasBezierVertex();
2964
+ boolean quad = inGeo.hasQuadraticVertex();
2965
+ boolean curv = inGeo.hasCurveVertex();
2966
+ if (bez || quad) saveBezierVertexSettings();
2967
+ if (curv) {
2968
+ saveCurveVertexSettings();
2969
+ tessellator.resetCurveVertexCount();
2903
2970
  }
2904
- break;
2905
-
2906
- case PRIMITIVE:
2907
- // The input geometry needs to be cleared because the geometry
2908
- // generation methods in InGeometry add the vertices of the
2909
- // new primitive to what is already stored.
2910
- inGeo.clear();
2911
- switch (kind) {
2912
- case POINT:
2913
- tessellatePoint();
2914
- break;
2915
- case LINE:
2916
- tessellateLine();
2917
- break;
2918
- case TRIANGLE:
2919
- tessellateTriangle();
2920
- break;
2921
- case QUAD:
2922
- tessellateQuad();
2923
- break;
2924
- case RECT:
2925
- tessellateRect();
2926
- break;
2927
- case ELLIPSE:
2928
- tessellateEllipse();
2929
- break;
2930
- case ARC:
2931
- tessellateArc();
2932
- break;
2933
- case BOX:
2934
- tessellateBox();
2935
- break;
2936
- case SPHERE:
2937
- tessellateSphere();
2938
- break;
2939
- default:
2940
- break;
2941
- }
2942
- break;
2943
-
2944
- case PATH:
2945
- inGeo.clear();
2946
- tessellatePath();
2947
- break;
2948
- default:
2949
- break;
2971
+ tessellator.tessellatePolygon(solid, close,
2972
+ normalMode == NORMAL_MODE_AUTO);
2973
+ if (bez ||quad) restoreBezierVertexSettings();
2974
+ if (curv) restoreCurveVertexSettings();
2975
+ }
2976
+ } else if (family == PRIMITIVE) {
2977
+ // The input geometry needs to be cleared because the geometry
2978
+ // generation methods in InGeometry add the vertices of the
2979
+ // new primitive to what is already stored.
2980
+ inGeo.clear();
2981
+
2982
+ switch (kind) {
2983
+ case POINT:
2984
+ tessellatePoint();
2985
+ break;
2986
+ case LINE:
2987
+ tessellateLine();
2988
+ break;
2989
+ case TRIANGLE:
2990
+ tessellateTriangle();
2991
+ break;
2992
+ case QUAD:
2993
+ tessellateQuad();
2994
+ break;
2995
+ case RECT:
2996
+ tessellateRect();
2997
+ break;
2998
+ case ELLIPSE:
2999
+ tessellateEllipse();
3000
+ break;
3001
+ case ARC:
3002
+ tessellateArc();
3003
+ break;
3004
+ case BOX:
3005
+ tessellateBox();
3006
+ break;
3007
+ case SPHERE:
3008
+ tessellateSphere();
3009
+ break;
3010
+ default:
3011
+ break;
3012
+ }
3013
+ } else if (family == PATH) {
3014
+ inGeo.clear();
3015
+ tessellatePath();
2950
3016
  }
2951
3017
 
2952
3018
  if (image != null && parent != null) {
2953
- ((PShapeOpenGL) parent).addTexture(image);
3019
+ ((PShapeOpenGL)parent).addTexture(image);
2954
3020
  }
2955
3021
 
2956
3022
  firstPolyIndexCache = tessellator.firstPolyIndexCache;
@@ -2969,6 +3035,7 @@ public class PShapeOpenGL extends PShape {
2969
3035
  tessellated = true;
2970
3036
  }
2971
3037
 
3038
+
2972
3039
  protected void tessellatePoint() {
2973
3040
  float x = 0, y = 0, z = 0;
2974
3041
  if (params.length == 2) {
@@ -2982,12 +3049,13 @@ public class PShapeOpenGL extends PShape {
2982
3049
  }
2983
3050
 
2984
3051
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
2985
- ambientColor, specularColor, emissiveColor, shininess);
3052
+ ambientColor, specularColor, emissiveColor, shininess);
2986
3053
  inGeo.setNormal(normalX, normalY, normalZ);
2987
3054
  inGeo.addPoint(x, y, z, fill, stroke);
2988
3055
  tessellator.tessellatePoints();
2989
3056
  }
2990
3057
 
3058
+
2991
3059
  protected void tessellateLine() {
2992
3060
  float x1 = 0, y1 = 0, z1 = 0;
2993
3061
  float x2 = 0, y2 = 0, z2 = 0;
@@ -3006,14 +3074,15 @@ public class PShapeOpenGL extends PShape {
3006
3074
  }
3007
3075
 
3008
3076
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3009
- ambientColor, specularColor, emissiveColor, shininess);
3077
+ ambientColor, specularColor, emissiveColor, shininess);
3010
3078
  inGeo.setNormal(normalX, normalY, normalZ);
3011
3079
  inGeo.addLine(x1, y1, z1,
3012
- x2, y2, z2,
3013
- fill, stroke);
3080
+ x2, y2, z2,
3081
+ fill, stroke);
3014
3082
  tessellator.tessellateLines();
3015
3083
  }
3016
3084
 
3085
+
3017
3086
  protected void tessellateTriangle() {
3018
3087
  float x1 = 0, y1 = 0;
3019
3088
  float x2 = 0, y2 = 0;
@@ -3028,15 +3097,16 @@ public class PShapeOpenGL extends PShape {
3028
3097
  }
3029
3098
 
3030
3099
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3031
- ambientColor, specularColor, emissiveColor, shininess);
3100
+ ambientColor, specularColor, emissiveColor, shininess);
3032
3101
  inGeo.setNormal(normalX, normalY, normalZ);
3033
3102
  inGeo.addTriangle(x1, y1, 0,
3034
- x2, y2, 0,
3035
- x3, y3, 0,
3036
- fill, stroke);
3103
+ x2, y2, 0,
3104
+ x3, y3, 0,
3105
+ fill, stroke);
3037
3106
  tessellator.tessellateTriangles();
3038
3107
  }
3039
3108
 
3109
+
3040
3110
  protected void tessellateQuad() {
3041
3111
  float x1 = 0, y1 = 0;
3042
3112
  float x2 = 0, y2 = 0;
@@ -3054,16 +3124,17 @@ public class PShapeOpenGL extends PShape {
3054
3124
  }
3055
3125
 
3056
3126
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3057
- ambientColor, specularColor, emissiveColor, shininess);
3127
+ ambientColor, specularColor, emissiveColor, shininess);
3058
3128
  inGeo.setNormal(normalX, normalY, normalZ);
3059
3129
  inGeo.addQuad(x1, y1, 0,
3060
- x2, y2, 0,
3061
- x3, y3, 0,
3062
- x4, y4, 0,
3063
- stroke);
3130
+ x2, y2, 0,
3131
+ x3, y3, 0,
3132
+ x4, y4, 0,
3133
+ stroke);
3064
3134
  tessellator.tessellateQuads();
3065
3135
  }
3066
3136
 
3137
+
3067
3138
  protected void tessellateRect() {
3068
3139
  float a = 0, b = 0, c = 0, d = 0;
3069
3140
  float tl = 0, tr = 0, br = 0, bl = 0;
@@ -3097,57 +3168,44 @@ public class PShapeOpenGL extends PShape {
3097
3168
 
3098
3169
  float hradius, vradius;
3099
3170
  switch (mode) {
3100
- case CORNERS:
3101
- break;
3102
- case CORNER:
3103
- c += a;
3104
- d += b;
3105
- break;
3106
- case RADIUS:
3107
- hradius = c;
3108
- vradius = d;
3109
- c = a + hradius;
3110
- d = b + vradius;
3111
- a -= hradius;
3112
- b -= vradius;
3113
- break;
3114
- case CENTER:
3115
- hradius = c / 2.0f;
3116
- vradius = d / 2.0f;
3117
- c = a + hradius;
3118
- d = b + vradius;
3119
- a -= hradius;
3120
- b -= vradius;
3171
+ case CORNERS:
3172
+ break;
3173
+ case CORNER:
3174
+ c += a; d += b;
3175
+ break;
3176
+ case RADIUS:
3177
+ hradius = c;
3178
+ vradius = d;
3179
+ c = a + hradius;
3180
+ d = b + vradius;
3181
+ a -= hradius;
3182
+ b -= vradius;
3183
+ break;
3184
+ case CENTER:
3185
+ hradius = c / 2.0f;
3186
+ vradius = d / 2.0f;
3187
+ c = a + hradius;
3188
+ d = b + vradius;
3189
+ a -= hradius;
3190
+ b -= vradius;
3121
3191
  }
3122
3192
 
3123
3193
  if (a > c) {
3124
- float temp = a;
3125
- a = c;
3126
- c = temp;
3194
+ float temp = a; a = c; c = temp;
3127
3195
  }
3128
3196
 
3129
3197
  if (b > d) {
3130
- float temp = b;
3131
- b = d;
3132
- d = temp;
3198
+ float temp = b; b = d; d = temp;
3133
3199
  }
3134
3200
 
3135
3201
  float maxRounding = PApplet.min((c - a) / 2, (d - b) / 2);
3136
- if (tl > maxRounding) {
3137
- tl = maxRounding;
3138
- }
3139
- if (tr > maxRounding) {
3140
- tr = maxRounding;
3141
- }
3142
- if (br > maxRounding) {
3143
- br = maxRounding;
3144
- }
3145
- if (bl > maxRounding) {
3146
- bl = maxRounding;
3147
- }
3202
+ if (tl > maxRounding) tl = maxRounding;
3203
+ if (tr > maxRounding) tr = maxRounding;
3204
+ if (br > maxRounding) br = maxRounding;
3205
+ if (bl > maxRounding) bl = maxRounding;
3148
3206
 
3149
3207
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3150
- ambientColor, specularColor, emissiveColor, shininess);
3208
+ ambientColor, specularColor, emissiveColor, shininess);
3151
3209
  inGeo.setNormal(normalX, normalY, normalZ);
3152
3210
  if (rounded) {
3153
3211
  saveBezierVertexSettings();
@@ -3160,6 +3218,7 @@ public class PShapeOpenGL extends PShape {
3160
3218
  }
3161
3219
  }
3162
3220
 
3221
+
3163
3222
  protected void tessellateEllipse() {
3164
3223
  float a = 0, b = 0, c = 0, d = 0;
3165
3224
  int mode = ellipseMode;
@@ -3176,19 +3235,23 @@ public class PShapeOpenGL extends PShape {
3176
3235
  float w = c;
3177
3236
  float h = d;
3178
3237
 
3179
- if (mode == CORNERS) {
3180
- w = c - a;
3181
- h = d - b;
3182
-
3183
- } else if (mode == RADIUS) {
3184
- x = a - c;
3185
- y = b - d;
3186
- w = c * 2;
3187
- h = d * 2;
3188
-
3189
- } else if (mode == DIAMETER) {
3190
- x = a - c / 2f;
3191
- y = b - d / 2f;
3238
+ switch (mode) {
3239
+ case CORNERS:
3240
+ w = c - a;
3241
+ h = d - b;
3242
+ break;
3243
+ case RADIUS:
3244
+ x = a - c;
3245
+ y = b - d;
3246
+ w = c * 2;
3247
+ h = d * 2;
3248
+ break;
3249
+ case DIAMETER:
3250
+ x = a - c/2f;
3251
+ y = b - d/2f;
3252
+ break;
3253
+ default:
3254
+ break;
3192
3255
  }
3193
3256
 
3194
3257
  if (w < 0) { // undo negative width
@@ -3202,12 +3265,13 @@ public class PShapeOpenGL extends PShape {
3202
3265
  }
3203
3266
 
3204
3267
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3205
- ambientColor, specularColor, emissiveColor, shininess);
3268
+ ambientColor, specularColor, emissiveColor, shininess);
3206
3269
  inGeo.setNormal(normalX, normalY, normalZ);
3207
3270
  inGeo.addEllipse(x, y, w, h, fill, stroke);
3208
3271
  tessellator.tessellateTriangleFan();
3209
3272
  }
3210
3273
 
3274
+
3211
3275
  protected void tessellateArc() {
3212
3276
  float a = 0, b = 0, c = 0, d = 0;
3213
3277
  float start = 0, stop = 0;
@@ -3222,7 +3286,7 @@ public class PShapeOpenGL extends PShape {
3222
3286
  start = params[4];
3223
3287
  stop = params[5];
3224
3288
  if (params.length == 7) {
3225
- arcMode = (int) (params[6]);
3289
+ arcMode = (int)(params[6]);
3226
3290
  }
3227
3291
  }
3228
3292
 
@@ -3231,23 +3295,19 @@ public class PShapeOpenGL extends PShape {
3231
3295
  float w = c;
3232
3296
  float h = d;
3233
3297
 
3234
- switch (mode) {
3235
- case CORNERS:
3236
- w = c - a;
3237
- h = d - b;
3238
- break;
3239
- case RADIUS:
3240
- x = a - c;
3241
- y = b - d;
3242
- w = c * 2;
3243
- h = d * 2;
3244
- break;
3245
- case CENTER:
3246
- x = a - c / 2f;
3247
- y = b - d / 2f;
3248
- break;
3249
- default:
3250
- break;
3298
+ if (mode == CORNERS) {
3299
+ w = c - a;
3300
+ h = d - b;
3301
+
3302
+ } else if (mode == RADIUS) {
3303
+ x = a - c;
3304
+ y = b - d;
3305
+ w = c * 2;
3306
+ h = d * 2;
3307
+
3308
+ } else if (mode == CENTER) {
3309
+ x = a - c/2f;
3310
+ y = b - d/2f;
3251
3311
  }
3252
3312
 
3253
3313
  // make sure the loop will exit before starting while
@@ -3265,7 +3325,7 @@ public class PShapeOpenGL extends PShape {
3265
3325
  stop = start + TWO_PI;
3266
3326
  }
3267
3327
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3268
- ambientColor, specularColor, emissiveColor, shininess);
3328
+ ambientColor, specularColor, emissiveColor, shininess);
3269
3329
  inGeo.setNormal(normalX, normalY, normalZ);
3270
3330
  inGeo.addArc(x, y, w, h, start, stop, fill, stroke, arcMode);
3271
3331
  tessellator.tessellateTriangleFan();
@@ -3273,6 +3333,7 @@ public class PShapeOpenGL extends PShape {
3273
3333
  }
3274
3334
  }
3275
3335
 
3336
+
3276
3337
  protected void tessellateBox() {
3277
3338
  float w = 0, h = 0, d = 0;
3278
3339
  if (params.length == 1) {
@@ -3284,11 +3345,12 @@ public class PShapeOpenGL extends PShape {
3284
3345
  }
3285
3346
 
3286
3347
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3287
- ambientColor, specularColor, emissiveColor, shininess);
3348
+ ambientColor, specularColor, emissiveColor, shininess);
3288
3349
  inGeo.addBox(w, h, d, fill, stroke);
3289
3350
  tessellator.tessellateQuads();
3290
3351
  }
3291
3352
 
3353
+
3292
3354
  protected void tessellateSphere() {
3293
3355
  float r = 0;
3294
3356
  int nu = sphereDetailU;
@@ -3296,10 +3358,10 @@ public class PShapeOpenGL extends PShape {
3296
3358
  if (1 <= params.length) {
3297
3359
  r = params[0];
3298
3360
  if (params.length == 2) {
3299
- nu = nv = (int) params[1];
3361
+ nu = nv = (int)params[1];
3300
3362
  } else if (params.length == 3) {
3301
- nu = (int) params[1];
3302
- nv = (int) params[2];
3363
+ nu = (int)params[1];
3364
+ nv = (int)params[2];
3303
3365
  }
3304
3366
  }
3305
3367
 
@@ -3313,23 +3375,22 @@ public class PShapeOpenGL extends PShape {
3313
3375
  }
3314
3376
 
3315
3377
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3316
- ambientColor, specularColor, emissiveColor, shininess);
3378
+ ambientColor, specularColor, emissiveColor, shininess);
3317
3379
  int[] indices = inGeo.addSphere(r, nu, nv, fill, stroke);
3318
3380
  tessellator.tessellateTriangles(indices);
3319
3381
 
3320
- if ((0 < savedDetailU && savedDetailU != nu)
3321
- || (0 < savedDetailV && savedDetailV != nv)) {
3382
+ if ((0 < savedDetailU && savedDetailU != nu) ||
3383
+ (0 < savedDetailV && savedDetailV != nv)) {
3322
3384
  pg.sphereDetail(savedDetailU, savedDetailV);
3323
3385
  }
3324
3386
  }
3325
3387
 
3388
+
3326
3389
  protected void tessellatePath() {
3327
- if (vertices == null) {
3328
- return;
3329
- }
3390
+ if (vertices == null) return;
3330
3391
 
3331
3392
  inGeo.setMaterial(fillColor, strokeColor, strokeWeight,
3332
- ambientColor, specularColor, emissiveColor, shininess);
3393
+ ambientColor, specularColor, emissiveColor, shininess);
3333
3394
 
3334
3395
  if (vertexCodeCount == 0) { // each point is a simple vertex
3335
3396
  if (vertices[0].length == 2) { // tessellating 2D vertices
@@ -3339,7 +3400,7 @@ public class PShapeOpenGL extends PShape {
3339
3400
  } else { // drawing 3D vertices
3340
3401
  for (int i = 0; i < vertexCount; i++) {
3341
3402
  inGeo.addVertex(vertices[i][X], vertices[i][Y], vertices[i][Z],
3342
- VERTEX, false);
3403
+ VERTEX, false);
3343
3404
  }
3344
3405
  }
3345
3406
  } else { // coded set of vertices
@@ -3351,88 +3412,88 @@ public class PShapeOpenGL extends PShape {
3351
3412
  for (int j = 0; j < vertexCodeCount; j++) {
3352
3413
  switch (vertexCodes[j]) {
3353
3414
 
3354
- case VERTEX:
3355
- inGeo.addVertex(vertices[idx][X], vertices[idx][Y], VERTEX, brk);
3356
- brk = false;
3357
- idx++;
3358
- break;
3415
+ case VERTEX:
3416
+ inGeo.addVertex(vertices[idx][X], vertices[idx][Y], VERTEX, brk);
3417
+ brk = false;
3418
+ idx++;
3419
+ break;
3359
3420
 
3360
- case QUADRATIC_VERTEX:
3361
- inGeo.addQuadraticVertex(vertices[idx + 0][X], vertices[idx + 0][Y], 0,
3362
- vertices[idx + 1][X], vertices[idx + 1][Y], 0,
3363
- brk);
3364
- brk = false;
3365
- idx += 2;
3366
- break;
3421
+ case QUADRATIC_VERTEX:
3422
+ inGeo.addQuadraticVertex(vertices[idx+0][X], vertices[idx+0][Y], 0,
3423
+ vertices[idx+1][X], vertices[idx+1][Y], 0,
3424
+ brk);
3425
+ brk = false;
3426
+ idx += 2;
3427
+ break;
3367
3428
 
3368
- case BEZIER_VERTEX:
3369
- inGeo.addBezierVertex(vertices[idx + 0][X], vertices[idx + 0][Y], 0,
3370
- vertices[idx + 1][X], vertices[idx + 1][Y], 0,
3371
- vertices[idx + 2][X], vertices[idx + 2][Y], 0,
3372
- brk);
3373
- brk = false;
3374
- idx += 3;
3375
- break;
3429
+ case BEZIER_VERTEX:
3430
+ inGeo.addBezierVertex(vertices[idx+0][X], vertices[idx+0][Y], 0,
3431
+ vertices[idx+1][X], vertices[idx+1][Y], 0,
3432
+ vertices[idx+2][X], vertices[idx+2][Y], 0,
3433
+ brk);
3434
+ brk = false;
3435
+ idx += 3;
3436
+ break;
3376
3437
 
3377
- case CURVE_VERTEX:
3378
- inGeo.addCurveVertex(vertices[idx][X], vertices[idx][Y], 0, brk);
3379
- brk = false;
3380
- idx++;
3381
- break;
3438
+ case CURVE_VERTEX:
3439
+ inGeo.addCurveVertex(vertices[idx][X], vertices[idx][Y], 0, brk);
3440
+ brk = false;
3441
+ idx++;
3442
+ break;
3382
3443
 
3383
- case BREAK:
3384
- brk = true;
3444
+ case BREAK:
3445
+ brk = true;
3385
3446
  }
3386
3447
  }
3387
3448
  } else { // tessellating a 3D path
3388
3449
  for (int j = 0; j < vertexCodeCount; j++) {
3389
3450
  switch (vertexCodes[j]) {
3390
3451
 
3391
- case VERTEX:
3392
- inGeo.addVertex(vertices[idx][X], vertices[idx][Y],
3393
- vertices[idx][Z], brk);
3394
- brk = false;
3395
- idx++;
3396
- break;
3452
+ case VERTEX:
3453
+ inGeo.addVertex(vertices[idx][X], vertices[idx][Y],
3454
+ vertices[idx][Z], brk);
3455
+ brk = false;
3456
+ idx++;
3457
+ break;
3397
3458
 
3398
- case QUADRATIC_VERTEX:
3399
- inGeo.addQuadraticVertex(vertices[idx + 0][X],
3400
- vertices[idx + 0][Y],
3401
- vertices[idx + 0][Z],
3402
- vertices[idx + 1][X],
3403
- vertices[idx + 1][Y],
3404
- vertices[idx + 0][Z],
3405
- brk);
3406
- brk = false;
3407
- idx += 2;
3408
- break;
3459
+ case QUADRATIC_VERTEX:
3460
+ inGeo.addQuadraticVertex(vertices[idx+0][X],
3461
+ vertices[idx+0][Y],
3462
+ vertices[idx+0][Z],
3463
+ vertices[idx+1][X],
3464
+ vertices[idx+1][Y],
3465
+ vertices[idx+0][Z],
3466
+ brk);
3467
+ brk = false;
3468
+ idx += 2;
3469
+ break;
3409
3470
 
3410
- case BEZIER_VERTEX:
3411
- inGeo.addBezierVertex(vertices[idx + 0][X],
3412
- vertices[idx + 0][Y],
3413
- vertices[idx + 0][Z],
3414
- vertices[idx + 1][X],
3415
- vertices[idx + 1][Y],
3416
- vertices[idx + 1][Z],
3417
- vertices[idx + 2][X],
3418
- vertices[idx + 2][Y],
3419
- vertices[idx + 2][Z],
3420
- brk);
3421
- brk = false;
3422
- idx += 3;
3423
- break;
3471
+ case BEZIER_VERTEX:
3472
+ inGeo.addBezierVertex(vertices[idx+0][X],
3473
+ vertices[idx+0][Y],
3474
+ vertices[idx+0][Z],
3475
+ vertices[idx+1][X],
3476
+ vertices[idx+1][Y],
3477
+ vertices[idx+1][Z],
3478
+ vertices[idx+2][X],
3479
+ vertices[idx+2][Y],
3480
+ vertices[idx+2][Z],
3481
+ brk);
3482
+ brk = false;
3483
+ idx += 3;
3484
+ break;
3424
3485
 
3425
- case CURVE_VERTEX:
3426
- inGeo.addCurveVertex(vertices[idx][X],
3427
- vertices[idx][Y],
3428
- vertices[idx][Z],
3429
- brk);
3430
- brk = false;
3431
- idx++;
3432
- break;
3486
+ case CURVE_VERTEX:
3487
+ inGeo.addCurveVertex(vertices[idx][X],
3488
+ vertices[idx][Y],
3489
+ vertices[idx][Z],
3490
+ brk);
3491
+ brk = false;
3492
+ idx++;
3493
+ break;
3433
3494
 
3434
- case BREAK:
3435
- brk = true;
3495
+ case BREAK:
3496
+ brk = true;
3436
3497
  }
3437
3498
  }
3438
3499
  }
@@ -3441,20 +3502,14 @@ public class PShapeOpenGL extends PShape {
3441
3502
  boolean bez = inGeo.hasBezierVertex();
3442
3503
  boolean quad = inGeo.hasQuadraticVertex();
3443
3504
  boolean curv = inGeo.hasCurveVertex();
3444
- if (bez || quad) {
3445
- saveBezierVertexSettings();
3446
- }
3505
+ if (bez || quad) saveBezierVertexSettings();
3447
3506
  if (curv) {
3448
3507
  saveCurveVertexSettings();
3449
3508
  tessellator.resetCurveVertexCount();
3450
3509
  }
3451
3510
  tessellator.tessellatePolygon(true, close, true);
3452
- if (bez || quad) {
3453
- restoreBezierVertexSettings();
3454
- }
3455
- if (curv) {
3456
- restoreCurveVertexSettings();
3457
- }
3511
+ if (bez || quad) restoreBezierVertexSettings();
3512
+ if (curv) restoreCurveVertexSettings();
3458
3513
  }
3459
3514
 
3460
3515
  protected void saveBezierVertexSettings() {
@@ -3491,8 +3546,12 @@ public class PShapeOpenGL extends PShape {
3491
3546
  }
3492
3547
 
3493
3548
  ///////////////////////////////////////////////////////////
3549
+
3494
3550
  //
3551
+
3495
3552
  // Aggregation
3553
+
3554
+
3496
3555
  protected void aggregate() {
3497
3556
  if (root == this && parent == null) {
3498
3557
  // Initializing auxiliary variables in root node
@@ -3517,6 +3576,7 @@ public class PShapeOpenGL extends PShape {
3517
3576
  }
3518
3577
  }
3519
3578
 
3579
+
3520
3580
  // This method is very important, as it is responsible of generating the
3521
3581
  // correct vertex and index offsets for each level of the shape hierarchy.
3522
3582
  // This is the core of the recursive algorithm that calculates the indices
@@ -3567,12 +3627,8 @@ public class PShapeOpenGL extends PShape {
3567
3627
  updatePolyIndexCache();
3568
3628
  }
3569
3629
  if (is3D()) {
3570
- if (hasLines) {
3571
- updateLineIndexCache();
3572
- }
3573
- if (hasPoints) {
3574
- updatePointIndexCache();
3575
- }
3630
+ if (hasLines) updateLineIndexCache();
3631
+ if (hasPoints) updatePointIndexCache();
3576
3632
  }
3577
3633
 
3578
3634
  if (matrix != null) {
@@ -3580,21 +3636,22 @@ public class PShapeOpenGL extends PShape {
3580
3636
  // this shape before tessellation, so they are applied now.
3581
3637
  if (hasPolys) {
3582
3638
  tessGeo.applyMatrixOnPolyGeometry(matrix,
3583
- firstPolyVertex, lastPolyVertex);
3639
+ firstPolyVertex, lastPolyVertex);
3584
3640
  }
3585
3641
  if (is3D()) {
3586
3642
  if (hasLines) {
3587
3643
  tessGeo.applyMatrixOnLineGeometry(matrix,
3588
- firstLineVertex, lastLineVertex);
3644
+ firstLineVertex, lastLineVertex);
3589
3645
  }
3590
3646
  if (hasPoints) {
3591
3647
  tessGeo.applyMatrixOnPointGeometry(matrix,
3592
- firstPointVertex, lastPointVertex);
3648
+ firstPointVertex, lastPointVertex);
3593
3649
  }
3594
3650
  }
3595
3651
  }
3596
3652
  }
3597
3653
 
3654
+
3598
3655
  // Updates the index cache for the range that corresponds to this shape.
3599
3656
  protected void updatePolyIndexCache() {
3600
3657
  IndexCache cache = tessGeo.polyIndexCache;
@@ -3610,6 +3667,7 @@ public class PShapeOpenGL extends PShape {
3610
3667
 
3611
3668
  // The index ranges of the child shapes that share the vertex offset
3612
3669
  // are unified into a single range in the parent level.
3670
+
3613
3671
  firstPolyIndexCache = lastPolyIndexCache = -1;
3614
3672
  int gindex = -1;
3615
3673
 
@@ -3630,7 +3688,7 @@ public class PShapeOpenGL extends PShape {
3630
3688
  // This is a result of how the indices are updated for the
3631
3689
  // leaf shapes.
3632
3690
  cache.incCounts(gindex,
3633
- cache.indexCount[n], cache.vertexCount[n]);
3691
+ cache.indexCount[n], cache.vertexCount[n]);
3634
3692
  } else {
3635
3693
  gindex = cache.addNew(n);
3636
3694
  }
@@ -3662,22 +3720,21 @@ public class PShapeOpenGL extends PShape {
3662
3720
  // root shape. When this happens, the indices in the child shape need
3663
3721
  // to be restarted as well to reflect the new index offset.
3664
3722
 
3665
- firstPolyVertex = lastPolyVertex
3666
- = cache.vertexOffset[firstPolyIndexCache];
3723
+ firstPolyVertex = lastPolyVertex =
3724
+ cache.vertexOffset[firstPolyIndexCache];
3667
3725
  for (int n = firstPolyIndexCache; n <= lastPolyIndexCache; n++) {
3668
3726
  int ioffset = cache.indexOffset[n];
3669
3727
  int icount = cache.indexCount[n];
3670
3728
  int vcount = cache.vertexCount[n];
3671
3729
 
3672
- if (PGL.MAX_VERTEX_INDEX1 <= root.polyVertexRel + vcount
3673
- || // Too many vertices already signal the start of a new cache...
3674
- (is2D() && startStrokedTex(n))) { // ... or, in 2D, the beginning of line or points.
3730
+ if (PGL.MAX_VERTEX_INDEX1 <= root.polyVertexRel + vcount || // Too many vertices already signal the start of a new cache...
3731
+ (is2D() && startStrokedTex(n))) { // ... or, in 2D, the beginning of line or points.
3675
3732
  root.polyVertexRel = 0;
3676
3733
  root.polyVertexOffset = root.polyVertexAbs;
3677
3734
  cache.indexOffset[n] = root.polyIndexOffset;
3678
3735
  } else {
3679
3736
  tessGeo.incPolyIndices(ioffset, ioffset + icount - 1,
3680
- root.polyVertexRel);
3737
+ root.polyVertexRel);
3681
3738
  }
3682
3739
  cache.vertexOffset[n] = root.polyVertexOffset;
3683
3740
  if (is2D()) {
@@ -3696,11 +3753,13 @@ public class PShapeOpenGL extends PShape {
3696
3753
  }
3697
3754
  }
3698
3755
 
3756
+
3699
3757
  protected boolean startStrokedTex(int n) {
3700
- return image != null && (n == firstLineIndexCache
3701
- || n == firstPointIndexCache);
3758
+ return image != null && (n == firstLineIndexCache ||
3759
+ n == firstPointIndexCache);
3702
3760
  }
3703
3761
 
3762
+
3704
3763
  protected void setFirstStrokeVertex(int n, int vert) {
3705
3764
  if (n == firstLineIndexCache && firstLineVertex == -1) {
3706
3765
  firstLineVertex = lastLineVertex = vert;
@@ -3737,7 +3796,7 @@ public class PShapeOpenGL extends PShape {
3737
3796
  } else {
3738
3797
  if (cache.vertexOffset[gindex] == cache.vertexOffset[n]) {
3739
3798
  cache.incCounts(gindex, cache.indexCount[n],
3740
- cache.vertexCount[n]);
3799
+ cache.vertexCount[n]);
3741
3800
  } else {
3742
3801
  gindex = cache.addNew(n);
3743
3802
  }
@@ -3746,9 +3805,7 @@ public class PShapeOpenGL extends PShape {
3746
3805
 
3747
3806
  // Updating the first and last line vertices for this group shape.
3748
3807
  if (-1 < child.firstLineVertex) {
3749
- if (firstLineVertex == -1) {
3750
- firstLineVertex = Integer.MAX_VALUE;
3751
- }
3808
+ if (firstLineVertex == -1) firstLineVertex = Integer.MAX_VALUE;
3752
3809
  firstLineVertex = PApplet.min(firstLineVertex, child.firstLineVertex);
3753
3810
  }
3754
3811
  if (-1 < child.lastLineVertex) {
@@ -3757,8 +3814,8 @@ public class PShapeOpenGL extends PShape {
3757
3814
  }
3758
3815
  lastLineIndexCache = gindex;
3759
3816
  } else {
3760
- firstLineVertex = lastLineVertex
3761
- = cache.vertexOffset[firstLineIndexCache];
3817
+ firstLineVertex = lastLineVertex =
3818
+ cache.vertexOffset[firstLineIndexCache];
3762
3819
  for (int n = firstLineIndexCache; n <= lastLineIndexCache; n++) {
3763
3820
  int ioffset = cache.indexOffset[n];
3764
3821
  int icount = cache.indexCount[n];
@@ -3770,7 +3827,7 @@ public class PShapeOpenGL extends PShape {
3770
3827
  cache.indexOffset[n] = root.lineIndexOffset;
3771
3828
  } else {
3772
3829
  tessGeo.incLineIndices(ioffset, ioffset + icount - 1,
3773
- root.lineVertexRel);
3830
+ root.lineVertexRel);
3774
3831
  }
3775
3832
  cache.vertexOffset[n] = root.lineVertexOffset;
3776
3833
 
@@ -3783,6 +3840,7 @@ public class PShapeOpenGL extends PShape {
3783
3840
  }
3784
3841
  }
3785
3842
 
3843
+
3786
3844
  protected void updatePointIndexCache() {
3787
3845
  IndexCache cache = tessGeo.pointIndexCache;
3788
3846
  if (family == GROUP) {
@@ -3806,7 +3864,7 @@ public class PShapeOpenGL extends PShape {
3806
3864
  // This is a result of how the indices are updated for the
3807
3865
  // leaf shapes in aggregateImpl().
3808
3866
  cache.incCounts(gindex, cache.indexCount[n],
3809
- cache.vertexCount[n]);
3867
+ cache.vertexCount[n]);
3810
3868
  } else {
3811
3869
  gindex = cache.addNew(n);
3812
3870
  }
@@ -3815,11 +3873,9 @@ public class PShapeOpenGL extends PShape {
3815
3873
 
3816
3874
  // Updating the first and last point vertices for this group shape.
3817
3875
  if (-1 < child.firstPointVertex) {
3818
- if (firstPointVertex == -1) {
3819
- firstPointVertex = Integer.MAX_VALUE;
3820
- }
3876
+ if (firstPointVertex == -1) firstPointVertex = Integer.MAX_VALUE;
3821
3877
  firstPointVertex = PApplet.min(firstPointVertex,
3822
- child.firstPointVertex);
3878
+ child.firstPointVertex);
3823
3879
  }
3824
3880
  if (-1 < child.lastPointVertex) {
3825
3881
  lastPointVertex = PApplet.max(lastPointVertex, child.lastPointVertex);
@@ -3827,8 +3883,8 @@ public class PShapeOpenGL extends PShape {
3827
3883
  }
3828
3884
  lastPointIndexCache = gindex;
3829
3885
  } else {
3830
- firstPointVertex = lastPointVertex
3831
- = cache.vertexOffset[firstPointIndexCache];
3886
+ firstPointVertex = lastPointVertex =
3887
+ cache.vertexOffset[firstPointIndexCache];
3832
3888
  for (int n = firstPointIndexCache; n <= lastPointIndexCache; n++) {
3833
3889
  int ioffset = cache.indexOffset[n];
3834
3890
  int icount = cache.indexCount[n];
@@ -3840,7 +3896,7 @@ public class PShapeOpenGL extends PShape {
3840
3896
  cache.indexOffset[n] = root.pointIndexOffset;
3841
3897
  } else {
3842
3898
  tessGeo.incPointIndices(ioffset, ioffset + icount - 1,
3843
- root.pointVertexRel);
3899
+ root.pointVertexRel);
3844
3900
  }
3845
3901
  cache.vertexOffset[n] = root.pointVertexOffset;
3846
3902
 
@@ -3853,9 +3909,14 @@ public class PShapeOpenGL extends PShape {
3853
3909
  }
3854
3910
  }
3855
3911
 
3912
+
3856
3913
  ///////////////////////////////////////////////////////////
3914
+
3857
3915
  //
3916
+
3858
3917
  // Buffer initialization
3918
+
3919
+
3859
3920
  protected void initBuffers() {
3860
3921
  boolean outdated = contextIsOutdated();
3861
3922
  context = pgl.getCurrentContext();
@@ -3875,186 +3936,171 @@ public class PShapeOpenGL extends PShape {
3875
3936
  needBufferInit = false;
3876
3937
  }
3877
3938
 
3939
+
3878
3940
  protected void initPolyBuffers() {
3879
3941
  int size = tessGeo.polyVertexCount;
3880
3942
  int sizef = size * PGL.SIZEOF_FLOAT;
3881
3943
  int sizei = size * PGL.SIZEOF_INT;
3882
3944
 
3883
3945
  tessGeo.updatePolyVerticesBuffer();
3884
- if (bufPolyVertex == null) {
3946
+ if (bufPolyVertex == null)
3885
3947
  bufPolyVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT);
3886
- }
3887
3948
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyVertex.glId);
3888
3949
  pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
3889
- tessGeo.polyVerticesBuffer, glUsage);
3950
+ tessGeo.polyVerticesBuffer, glUsage);
3890
3951
 
3891
3952
  tessGeo.updatePolyColorsBuffer();
3892
- if (bufPolyColor == null) {
3953
+ if (bufPolyColor == null)
3893
3954
  bufPolyColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
3894
- }
3895
3955
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyColor.glId);
3896
3956
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
3897
- tessGeo.polyColorsBuffer, glUsage);
3957
+ tessGeo.polyColorsBuffer, glUsage);
3898
3958
 
3899
3959
  tessGeo.updatePolyNormalsBuffer();
3900
- if (bufPolyNormal == null) {
3960
+ if (bufPolyNormal == null)
3901
3961
  bufPolyNormal = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 3, PGL.SIZEOF_FLOAT);
3902
- }
3903
3962
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyNormal.glId);
3904
3963
  pgl.bufferData(PGL.ARRAY_BUFFER, 3 * sizef,
3905
- tessGeo.polyNormalsBuffer, glUsage);
3964
+ tessGeo.polyNormalsBuffer, glUsage);
3906
3965
 
3907
3966
  tessGeo.updatePolyTexCoordsBuffer();
3908
- if (bufPolyTexcoord == null) {
3967
+ if (bufPolyTexcoord == null)
3909
3968
  bufPolyTexcoord = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT);
3910
- }
3911
3969
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyTexcoord.glId);
3912
3970
  pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
3913
- tessGeo.polyTexCoordsBuffer, glUsage);
3971
+ tessGeo.polyTexCoordsBuffer, glUsage);
3914
3972
 
3915
3973
  tessGeo.updatePolyAmbientBuffer();
3916
- if (bufPolyAmbient == null) {
3974
+ if (bufPolyAmbient == null)
3917
3975
  bufPolyAmbient = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
3918
- }
3919
3976
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyAmbient.glId);
3920
3977
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
3921
- tessGeo.polyAmbientBuffer, glUsage);
3978
+ tessGeo.polyAmbientBuffer, glUsage);
3922
3979
 
3923
3980
  tessGeo.updatePolySpecularBuffer();
3924
- if (bufPolySpecular == null) {
3981
+ if (bufPolySpecular == null)
3925
3982
  bufPolySpecular = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
3926
- }
3927
3983
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolySpecular.glId);
3928
3984
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
3929
- tessGeo.polySpecularBuffer, glUsage);
3985
+ tessGeo.polySpecularBuffer, glUsage);
3930
3986
 
3931
3987
  tessGeo.updatePolyEmissiveBuffer();
3932
- if (bufPolyEmissive == null) {
3988
+ if (bufPolyEmissive == null)
3933
3989
  bufPolyEmissive = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
3934
- }
3935
3990
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyEmissive.glId);
3936
3991
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
3937
- tessGeo.polyEmissiveBuffer, glUsage);
3992
+ tessGeo.polyEmissiveBuffer, glUsage);
3938
3993
 
3939
3994
  tessGeo.updatePolyShininessBuffer();
3940
- if (bufPolyShininess == null) {
3995
+ if (bufPolyShininess == null)
3941
3996
  bufPolyShininess = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_FLOAT);
3942
- }
3943
3997
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyShininess.glId);
3944
3998
  pgl.bufferData(PGL.ARRAY_BUFFER, sizef,
3945
- tessGeo.polyShininessBuffer, glUsage);
3999
+ tessGeo.polyShininessBuffer, glUsage);
3946
4000
 
3947
- polyAttribs.keySet().forEach((_name) -> {
3948
- VertexAttribute attrib = polyAttribs.get(_name);
4001
+ for (String name: polyAttribs.keySet()) {
4002
+ VertexAttribute attrib = polyAttribs.get(name);
3949
4003
  tessGeo.updateAttribBuffer(attrib.name);
3950
- if (!attrib.bufferCreated()) {
3951
- attrib.createBuffer(pgl);
3952
- }
4004
+ if (!attrib.bufferCreated()) attrib.createBuffer(pgl);
3953
4005
  pgl.bindBuffer(PGL.ARRAY_BUFFER, attrib.buf.glId);
3954
4006
  pgl.bufferData(PGL.ARRAY_BUFFER, attrib.sizeInBytes(size),
3955
- tessGeo.polyAttribBuffers.get(_name), glUsage);
3956
- });
4007
+ tessGeo.polyAttribBuffers.get(name), glUsage);
4008
+ }
3957
4009
 
3958
4010
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
3959
4011
 
3960
4012
  tessGeo.updatePolyIndicesBuffer();
3961
- if (bufPolyIndex == null) {
4013
+ if (bufPolyIndex == null)
3962
4014
  bufPolyIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, true);
3963
- }
3964
4015
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufPolyIndex.glId);
3965
4016
  pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
3966
- tessGeo.polyIndexCount * PGL.SIZEOF_INDEX,
3967
- tessGeo.polyIndicesBuffer, glUsage);
4017
+ tessGeo.polyIndexCount * PGL.SIZEOF_INDEX,
4018
+ tessGeo.polyIndicesBuffer, glUsage);
3968
4019
 
3969
4020
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
3970
4021
  }
3971
4022
 
4023
+
3972
4024
  protected void initLineBuffers() {
3973
4025
  int size = tessGeo.lineVertexCount;
3974
4026
  int sizef = size * PGL.SIZEOF_FLOAT;
3975
4027
  int sizei = size * PGL.SIZEOF_INT;
3976
4028
 
3977
4029
  tessGeo.updateLineVerticesBuffer();
3978
- if (bufLineVertex == null) {
4030
+ if (bufLineVertex == null)
3979
4031
  bufLineVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT);
3980
- }
3981
4032
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineVertex.glId);
3982
4033
  pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
3983
- tessGeo.lineVerticesBuffer, glUsage);
4034
+ tessGeo.lineVerticesBuffer, glUsage);
3984
4035
 
3985
4036
  tessGeo.updateLineColorsBuffer();
3986
- if (bufLineColor == null) {
4037
+ if (bufLineColor == null)
3987
4038
  bufLineColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
3988
- }
3989
4039
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineColor.glId);
3990
4040
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
3991
- tessGeo.lineColorsBuffer, glUsage);
4041
+ tessGeo.lineColorsBuffer, glUsage);
3992
4042
 
3993
4043
  tessGeo.updateLineDirectionsBuffer();
3994
- if (bufLineAttrib == null) {
4044
+ if (bufLineAttrib == null)
3995
4045
  bufLineAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT);
3996
- }
3997
4046
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineAttrib.glId);
3998
4047
  pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
3999
- tessGeo.lineDirectionsBuffer, glUsage);
4048
+ tessGeo.lineDirectionsBuffer, glUsage);
4000
4049
 
4001
4050
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4002
4051
 
4003
4052
  tessGeo.updateLineIndicesBuffer();
4004
- if (bufLineIndex == null) {
4053
+ if (bufLineIndex == null)
4005
4054
  bufLineIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, true);
4006
- }
4007
4055
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufLineIndex.glId);
4008
4056
  pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
4009
- tessGeo.lineIndexCount * PGL.SIZEOF_INDEX,
4010
- tessGeo.lineIndicesBuffer, glUsage);
4057
+ tessGeo.lineIndexCount * PGL.SIZEOF_INDEX,
4058
+ tessGeo.lineIndicesBuffer, glUsage);
4011
4059
 
4012
4060
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
4013
4061
  }
4014
4062
 
4063
+
4015
4064
  protected void initPointBuffers() {
4016
4065
  int size = tessGeo.pointVertexCount;
4017
4066
  int sizef = size * PGL.SIZEOF_FLOAT;
4018
4067
  int sizei = size * PGL.SIZEOF_INT;
4019
4068
 
4020
4069
  tessGeo.updatePointVerticesBuffer();
4021
- if (bufPointVertex == null) {
4070
+ if (bufPointVertex == null)
4022
4071
  bufPointVertex = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 4, PGL.SIZEOF_FLOAT);
4023
- }
4024
4072
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointVertex.glId);
4025
4073
  pgl.bufferData(PGL.ARRAY_BUFFER, 4 * sizef,
4026
- tessGeo.pointVerticesBuffer, glUsage);
4074
+ tessGeo.pointVerticesBuffer, glUsage);
4027
4075
 
4028
4076
  tessGeo.updatePointColorsBuffer();
4029
- if (bufPointColor == null) {
4077
+ if (bufPointColor == null)
4030
4078
  bufPointColor = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 1, PGL.SIZEOF_INT);
4031
- }
4032
4079
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointColor.glId);
4033
4080
  pgl.bufferData(PGL.ARRAY_BUFFER, sizei,
4034
- tessGeo.pointColorsBuffer, glUsage);
4081
+ tessGeo.pointColorsBuffer, glUsage);
4035
4082
 
4036
4083
  tessGeo.updatePointOffsetsBuffer();
4037
- if (bufPointAttrib == null) {
4084
+ if (bufPointAttrib == null)
4038
4085
  bufPointAttrib = new VertexBuffer(pg, PGL.ARRAY_BUFFER, 2, PGL.SIZEOF_FLOAT);
4039
- }
4040
4086
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointAttrib.glId);
4041
4087
  pgl.bufferData(PGL.ARRAY_BUFFER, 2 * sizef,
4042
- tessGeo.pointOffsetsBuffer, glUsage);
4088
+ tessGeo.pointOffsetsBuffer, glUsage);
4043
4089
 
4044
4090
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4045
4091
 
4046
4092
  tessGeo.updatePointIndicesBuffer();
4047
- if (bufPointIndex == null) {
4093
+ if (bufPointIndex == null)
4048
4094
  bufPointIndex = new VertexBuffer(pg, PGL.ELEMENT_ARRAY_BUFFER, 1, PGL.SIZEOF_INDEX, true);
4049
- }
4050
4095
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, bufPointIndex.glId);
4051
4096
  pgl.bufferData(PGL.ELEMENT_ARRAY_BUFFER,
4052
- tessGeo.pointIndexCount * PGL.SIZEOF_INDEX,
4053
- tessGeo.pointIndicesBuffer, glUsage);
4097
+ tessGeo.pointIndexCount * PGL.SIZEOF_INDEX,
4098
+ tessGeo.pointIndicesBuffer, glUsage);
4054
4099
 
4055
4100
  pgl.bindBuffer(PGL.ELEMENT_ARRAY_BUFFER, 0);
4056
4101
  }
4057
4102
 
4103
+
4058
4104
  protected boolean contextIsOutdated() {
4059
4105
  boolean outdated = !pgl.contextIsCurrent(context);
4060
4106
  if (outdated) {
@@ -4084,9 +4130,14 @@ public class PShapeOpenGL extends PShape {
4084
4130
  return outdated;
4085
4131
  }
4086
4132
 
4133
+
4087
4134
  ///////////////////////////////////////////////////////////
4135
+
4088
4136
  //
4137
+
4089
4138
  // Geometry update
4139
+
4140
+
4090
4141
  protected void updateGeometry() {
4091
4142
  root.initBuffers();
4092
4143
  if (root.modified) {
@@ -4094,6 +4145,7 @@ public class PShapeOpenGL extends PShape {
4094
4145
  }
4095
4146
  }
4096
4147
 
4148
+
4097
4149
  protected void updateGeometryImpl() {
4098
4150
  if (modifiedPolyVertices) {
4099
4151
  int offset = firstModifiedPolyVertex;
@@ -4159,20 +4211,17 @@ public class PShapeOpenGL extends PShape {
4159
4211
  firstModifiedPolyShininess = PConstants.MAX_INT;
4160
4212
  lastModifiedPolyShininess = PConstants.MIN_INT;
4161
4213
  }
4162
- polyAttribs.keySet().stream().map((_name) -> polyAttribs.get(_name)).filter((attrib) -> (attrib.modified)).map((attrib) -> {
4163
- int offset = firstModifiedPolyVertex;
4164
- int size = lastModifiedPolyVertex - offset + 1;
4165
- copyPolyAttrib(attrib, offset, size);
4166
- return attrib;
4167
- }).map((attrib) -> {
4168
- attrib.modified = false;
4169
- return attrib;
4170
- }).map((attrib) -> {
4171
- attrib.firstModified = PConstants.MAX_INT;
4172
- return attrib;
4173
- }).forEachOrdered((attrib) -> {
4174
- attrib.lastModified = PConstants.MIN_INT;
4175
- });
4214
+ for (String name: polyAttribs.keySet()) {
4215
+ VertexAttribute attrib = polyAttribs.get(name);
4216
+ if (attrib.modified) {
4217
+ int offset = firstModifiedPolyVertex;
4218
+ int size = lastModifiedPolyVertex - offset + 1;
4219
+ copyPolyAttrib(attrib, offset, size);
4220
+ attrib.modified = false;
4221
+ attrib.firstModified = PConstants.MAX_INT;
4222
+ attrib.lastModified = PConstants.MIN_INT;
4223
+ }
4224
+ }
4176
4225
 
4177
4226
  if (modifiedLineVertices) {
4178
4227
  int offset = firstModifiedLineVertex;
@@ -4227,325 +4276,300 @@ public class PShapeOpenGL extends PShape {
4227
4276
  modified = false;
4228
4277
  }
4229
4278
 
4279
+
4230
4280
  protected void copyPolyVertices(int offset, int size) {
4231
4281
  tessGeo.updatePolyVerticesBuffer(offset, size);
4232
4282
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyVertex.glId);
4233
4283
  tessGeo.polyVerticesBuffer.position(4 * offset);
4234
4284
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4235
- 4 * size * PGL.SIZEOF_FLOAT, tessGeo.polyVerticesBuffer);
4285
+ 4 * size * PGL.SIZEOF_FLOAT, tessGeo.polyVerticesBuffer);
4236
4286
  tessGeo.polyVerticesBuffer.rewind();
4237
4287
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4238
4288
  }
4239
4289
 
4290
+
4240
4291
  protected void copyPolyColors(int offset, int size) {
4241
4292
  tessGeo.updatePolyColorsBuffer(offset, size);
4242
4293
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyColor.glId);
4243
4294
  tessGeo.polyColorsBuffer.position(offset);
4244
4295
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4245
- size * PGL.SIZEOF_INT, tessGeo.polyColorsBuffer);
4296
+ size * PGL.SIZEOF_INT, tessGeo.polyColorsBuffer);
4246
4297
  tessGeo.polyColorsBuffer.rewind();
4247
4298
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4248
4299
  }
4249
4300
 
4301
+
4250
4302
  protected void copyPolyNormals(int offset, int size) {
4251
4303
  tessGeo.updatePolyNormalsBuffer(offset, size);
4252
4304
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyNormal.glId);
4253
4305
  tessGeo.polyNormalsBuffer.position(3 * offset);
4254
4306
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 3 * offset * PGL.SIZEOF_FLOAT,
4255
- 3 * size * PGL.SIZEOF_FLOAT, tessGeo.polyNormalsBuffer);
4307
+ 3 * size * PGL.SIZEOF_FLOAT, tessGeo.polyNormalsBuffer);
4256
4308
  tessGeo.polyNormalsBuffer.rewind();
4257
4309
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4258
4310
  }
4259
4311
 
4312
+
4260
4313
  protected void copyPolyTexCoords(int offset, int size) {
4261
4314
  tessGeo.updatePolyTexCoordsBuffer(offset, size);
4262
4315
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyTexcoord.glId);
4263
4316
  tessGeo.polyTexCoordsBuffer.position(2 * offset);
4264
4317
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT,
4265
- 2 * size * PGL.SIZEOF_FLOAT, tessGeo.polyTexCoordsBuffer);
4318
+ 2 * size * PGL.SIZEOF_FLOAT, tessGeo.polyTexCoordsBuffer);
4266
4319
  tessGeo.polyTexCoordsBuffer.rewind();
4267
4320
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4268
4321
  }
4269
4322
 
4323
+
4270
4324
  protected void copyPolyAmbient(int offset, int size) {
4271
4325
  tessGeo.updatePolyAmbientBuffer(offset, size);
4272
4326
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyAmbient.glId);
4273
4327
  tessGeo.polyAmbientBuffer.position(offset);
4274
4328
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4275
- size * PGL.SIZEOF_INT, tessGeo.polyAmbientBuffer);
4329
+ size * PGL.SIZEOF_INT, tessGeo.polyAmbientBuffer);
4276
4330
  tessGeo.polyAmbientBuffer.rewind();
4277
4331
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4278
4332
  }
4279
4333
 
4334
+
4280
4335
  protected void copyPolySpecular(int offset, int size) {
4281
4336
  tessGeo.updatePolySpecularBuffer(offset, size);
4282
4337
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolySpecular.glId);
4283
4338
  tessGeo.polySpecularBuffer.position(offset);
4284
4339
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4285
- size * PGL.SIZEOF_INT, tessGeo.polySpecularBuffer);
4340
+ size * PGL.SIZEOF_INT, tessGeo.polySpecularBuffer);
4286
4341
  tessGeo.polySpecularBuffer.rewind();
4287
4342
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4288
4343
  }
4289
4344
 
4345
+
4290
4346
  protected void copyPolyEmissive(int offset, int size) {
4291
4347
  tessGeo.updatePolyEmissiveBuffer(offset, size);
4292
4348
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyEmissive.glId);
4293
4349
  tessGeo.polyEmissiveBuffer.position(offset);
4294
4350
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4295
- size * PGL.SIZEOF_INT, tessGeo.polyEmissiveBuffer);
4351
+ size * PGL.SIZEOF_INT, tessGeo.polyEmissiveBuffer);
4296
4352
  tessGeo.polyEmissiveBuffer.rewind();
4297
4353
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4298
4354
  }
4299
4355
 
4356
+
4300
4357
  protected void copyPolyShininess(int offset, int size) {
4301
4358
  tessGeo.updatePolyShininessBuffer(offset, size);
4302
4359
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPolyShininess.glId);
4303
4360
  tessGeo.polyShininessBuffer.position(offset);
4304
4361
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_FLOAT,
4305
- size * PGL.SIZEOF_FLOAT, tessGeo.polyShininessBuffer);
4362
+ size * PGL.SIZEOF_FLOAT, tessGeo.polyShininessBuffer);
4306
4363
  tessGeo.polyShininessBuffer.rewind();
4307
4364
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4308
4365
  }
4309
4366
 
4367
+
4310
4368
  protected void copyPolyAttrib(VertexAttribute attrib, int offset, int size) {
4311
4369
  tessGeo.updateAttribBuffer(attrib.name, offset, size);
4312
4370
  pgl.bindBuffer(PGL.ARRAY_BUFFER, attrib.buf.glId);
4313
4371
  Buffer buf = tessGeo.polyAttribBuffers.get(attrib.name);
4314
4372
  buf.position(attrib.size * offset);
4315
4373
  pgl.bufferSubData(PGL.ARRAY_BUFFER, attrib.sizeInBytes(offset),
4316
- attrib.sizeInBytes(size), buf);
4374
+ attrib.sizeInBytes(size), buf);
4317
4375
  buf.rewind();
4318
4376
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4319
4377
  }
4320
4378
 
4379
+
4321
4380
  protected void copyLineVertices(int offset, int size) {
4322
4381
  tessGeo.updateLineVerticesBuffer(offset, size);
4323
4382
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineVertex.glId);
4324
4383
  tessGeo.lineVerticesBuffer.position(4 * offset);
4325
4384
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4326
- 4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineVerticesBuffer);
4385
+ 4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineVerticesBuffer);
4327
4386
  tessGeo.lineVerticesBuffer.rewind();
4328
4387
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4329
4388
  }
4330
4389
 
4390
+
4331
4391
  protected void copyLineColors(int offset, int size) {
4332
4392
  tessGeo.updateLineColorsBuffer(offset, size);
4333
4393
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineColor.glId);
4334
4394
  tessGeo.lineColorsBuffer.position(offset);
4335
4395
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4336
- size * PGL.SIZEOF_INT, tessGeo.lineColorsBuffer);
4396
+ size * PGL.SIZEOF_INT, tessGeo.lineColorsBuffer);
4337
4397
  tessGeo.lineColorsBuffer.rewind();
4338
4398
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4339
4399
  }
4340
4400
 
4401
+
4341
4402
  protected void copyLineAttributes(int offset, int size) {
4342
4403
  tessGeo.updateLineDirectionsBuffer(offset, size);
4343
4404
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufLineAttrib.glId);
4344
4405
  tessGeo.lineDirectionsBuffer.position(4 * offset);
4345
4406
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4346
- 4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineDirectionsBuffer);
4407
+ 4 * size * PGL.SIZEOF_FLOAT, tessGeo.lineDirectionsBuffer);
4347
4408
  tessGeo.lineDirectionsBuffer.rewind();
4348
4409
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4349
4410
  }
4350
4411
 
4412
+
4351
4413
  protected void copyPointVertices(int offset, int size) {
4352
4414
  tessGeo.updatePointVerticesBuffer(offset, size);
4353
4415
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointVertex.glId);
4354
4416
  tessGeo.pointVerticesBuffer.position(4 * offset);
4355
4417
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 4 * offset * PGL.SIZEOF_FLOAT,
4356
- 4 * size * PGL.SIZEOF_FLOAT, tessGeo.pointVerticesBuffer);
4418
+ 4 * size * PGL.SIZEOF_FLOAT, tessGeo.pointVerticesBuffer);
4357
4419
  tessGeo.pointVerticesBuffer.rewind();
4358
4420
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4359
4421
  }
4360
4422
 
4423
+
4361
4424
  protected void copyPointColors(int offset, int size) {
4362
4425
  tessGeo.updatePointColorsBuffer(offset, size);
4363
4426
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointColor.glId);
4364
4427
  tessGeo.pointColorsBuffer.position(offset);
4365
4428
  pgl.bufferSubData(PGL.ARRAY_BUFFER, offset * PGL.SIZEOF_INT,
4366
- size * PGL.SIZEOF_INT, tessGeo.pointColorsBuffer);
4429
+ size * PGL.SIZEOF_INT,tessGeo.pointColorsBuffer);
4367
4430
  tessGeo.pointColorsBuffer.rewind();
4368
4431
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4369
4432
  }
4370
4433
 
4434
+
4371
4435
  protected void copyPointAttributes(int offset, int size) {
4372
4436
  tessGeo.updatePointOffsetsBuffer(offset, size);
4373
4437
  pgl.bindBuffer(PGL.ARRAY_BUFFER, bufPointAttrib.glId);
4374
4438
  tessGeo.pointOffsetsBuffer.position(2 * offset);
4375
4439
  pgl.bufferSubData(PGL.ARRAY_BUFFER, 2 * offset * PGL.SIZEOF_FLOAT,
4376
- 2 * size * PGL.SIZEOF_FLOAT, tessGeo.pointOffsetsBuffer);
4440
+ 2 * size * PGL.SIZEOF_FLOAT, tessGeo.pointOffsetsBuffer);
4377
4441
  tessGeo.pointOffsetsBuffer.rewind();
4378
4442
  pgl.bindBuffer(PGL.ARRAY_BUFFER, 0);
4379
4443
  }
4380
4444
 
4445
+
4381
4446
  protected void setModifiedPolyVertices(int first, int last) {
4382
- if (first < firstModifiedPolyVertex) {
4383
- firstModifiedPolyVertex = first;
4384
- }
4385
- if (last > lastModifiedPolyVertex) {
4386
- lastModifiedPolyVertex = last;
4387
- }
4447
+ if (first < firstModifiedPolyVertex) firstModifiedPolyVertex = first;
4448
+ if (last > lastModifiedPolyVertex) lastModifiedPolyVertex = last;
4388
4449
  modifiedPolyVertices = true;
4389
4450
  modified = true;
4390
4451
  }
4391
4452
 
4453
+
4392
4454
  protected void setModifiedPolyColors(int first, int last) {
4393
- if (first < firstModifiedPolyColor) {
4394
- firstModifiedPolyColor = first;
4395
- }
4396
- if (last > lastModifiedPolyColor) {
4397
- lastModifiedPolyColor = last;
4398
- }
4455
+ if (first < firstModifiedPolyColor) firstModifiedPolyColor = first;
4456
+ if (last > lastModifiedPolyColor) lastModifiedPolyColor = last;
4399
4457
  modifiedPolyColors = true;
4400
4458
  modified = true;
4401
4459
  }
4402
4460
 
4461
+
4403
4462
  protected void setModifiedPolyNormals(int first, int last) {
4404
- if (first < firstModifiedPolyNormal) {
4405
- firstModifiedPolyNormal = first;
4406
- }
4407
- if (last > lastModifiedPolyNormal) {
4408
- lastModifiedPolyNormal = last;
4409
- }
4463
+ if (first < firstModifiedPolyNormal) firstModifiedPolyNormal = first;
4464
+ if (last > lastModifiedPolyNormal) lastModifiedPolyNormal = last;
4410
4465
  modifiedPolyNormals = true;
4411
4466
  modified = true;
4412
4467
  }
4413
4468
 
4469
+
4414
4470
  protected void setModifiedPolyTexCoords(int first, int last) {
4415
- if (first < firstModifiedPolyTexcoord) {
4416
- firstModifiedPolyTexcoord = first;
4417
- }
4418
- if (last > lastModifiedPolyTexcoord) {
4419
- lastModifiedPolyTexcoord = last;
4420
- }
4471
+ if (first < firstModifiedPolyTexcoord) firstModifiedPolyTexcoord = first;
4472
+ if (last > lastModifiedPolyTexcoord) lastModifiedPolyTexcoord = last;
4421
4473
  modifiedPolyTexCoords = true;
4422
4474
  modified = true;
4423
4475
  }
4424
4476
 
4477
+
4425
4478
  protected void setModifiedPolyAmbient(int first, int last) {
4426
- if (first < firstModifiedPolyAmbient) {
4427
- firstModifiedPolyAmbient = first;
4428
- }
4429
- if (last > lastModifiedPolyAmbient) {
4430
- lastModifiedPolyAmbient = last;
4431
- }
4479
+ if (first < firstModifiedPolyAmbient) firstModifiedPolyAmbient = first;
4480
+ if (last > lastModifiedPolyAmbient) lastModifiedPolyAmbient = last;
4432
4481
  modifiedPolyAmbient = true;
4433
4482
  modified = true;
4434
4483
  }
4435
4484
 
4485
+
4436
4486
  protected void setModifiedPolySpecular(int first, int last) {
4437
- if (first < firstModifiedPolySpecular) {
4438
- firstModifiedPolySpecular = first;
4439
- }
4440
- if (last > lastModifiedPolySpecular) {
4441
- lastModifiedPolySpecular = last;
4442
- }
4487
+ if (first < firstModifiedPolySpecular) firstModifiedPolySpecular = first;
4488
+ if (last > lastModifiedPolySpecular) lastModifiedPolySpecular = last;
4443
4489
  modifiedPolySpecular = true;
4444
4490
  modified = true;
4445
4491
  }
4446
4492
 
4493
+
4447
4494
  protected void setModifiedPolyEmissive(int first, int last) {
4448
- if (first < firstModifiedPolyEmissive) {
4449
- firstModifiedPolyEmissive = first;
4450
- }
4451
- if (last > lastModifiedPolyEmissive) {
4452
- lastModifiedPolyEmissive = last;
4453
- }
4495
+ if (first < firstModifiedPolyEmissive) firstModifiedPolyEmissive = first;
4496
+ if (last > lastModifiedPolyEmissive) lastModifiedPolyEmissive = last;
4454
4497
  modifiedPolyEmissive = true;
4455
4498
  modified = true;
4456
4499
  }
4457
4500
 
4501
+
4458
4502
  protected void setModifiedPolyShininess(int first, int last) {
4459
- if (first < firstModifiedPolyShininess) {
4460
- firstModifiedPolyShininess = first;
4461
- }
4462
- if (last > lastModifiedPolyShininess) {
4463
- lastModifiedPolyShininess = last;
4464
- }
4503
+ if (first < firstModifiedPolyShininess) firstModifiedPolyShininess = first;
4504
+ if (last > lastModifiedPolyShininess) lastModifiedPolyShininess = last;
4465
4505
  modifiedPolyShininess = true;
4466
4506
  modified = true;
4467
4507
  }
4468
4508
 
4509
+
4469
4510
  protected void setModifiedPolyAttrib(VertexAttribute attrib, int first, int last) {
4470
- if (first < attrib.firstModified) {
4471
- attrib.firstModified = first;
4472
- }
4473
- if (last > attrib.lastModified) {
4474
- attrib.lastModified = last;
4475
- }
4511
+ if (first < attrib.firstModified) attrib.firstModified = first;
4512
+ if (last > attrib.lastModified) attrib.lastModified = last;
4476
4513
  attrib.modified = true;
4477
4514
  modified = true;
4478
4515
  }
4479
4516
 
4517
+
4480
4518
  protected void setModifiedLineVertices(int first, int last) {
4481
- if (first < firstModifiedLineVertex) {
4482
- firstModifiedLineVertex = first;
4483
- }
4484
- if (last > lastModifiedLineVertex) {
4485
- lastModifiedLineVertex = last;
4486
- }
4519
+ if (first < firstModifiedLineVertex) firstModifiedLineVertex = first;
4520
+ if (last > lastModifiedLineVertex) lastModifiedLineVertex = last;
4487
4521
  modifiedLineVertices = true;
4488
4522
  modified = true;
4489
4523
  }
4490
4524
 
4525
+
4491
4526
  protected void setModifiedLineColors(int first, int last) {
4492
- if (first < firstModifiedLineColor) {
4493
- firstModifiedLineColor = first;
4494
- }
4495
- if (last > lastModifiedLineColor) {
4496
- lastModifiedLineColor = last;
4497
- }
4527
+ if (first < firstModifiedLineColor) firstModifiedLineColor = first;
4528
+ if (last > lastModifiedLineColor) lastModifiedLineColor = last;
4498
4529
  modifiedLineColors = true;
4499
4530
  modified = true;
4500
4531
  }
4501
4532
 
4533
+
4502
4534
  protected void setModifiedLineAttributes(int first, int last) {
4503
- if (first < firstModifiedLineAttribute) {
4504
- firstModifiedLineAttribute = first;
4505
- }
4506
- if (last > lastModifiedLineAttribute) {
4507
- lastModifiedLineAttribute = last;
4508
- }
4535
+ if (first < firstModifiedLineAttribute) firstModifiedLineAttribute = first;
4536
+ if (last > lastModifiedLineAttribute) lastModifiedLineAttribute = last;
4509
4537
  modifiedLineAttributes = true;
4510
4538
  modified = true;
4511
4539
  }
4512
4540
 
4541
+
4513
4542
  protected void setModifiedPointVertices(int first, int last) {
4514
- if (first < firstModifiedPointVertex) {
4515
- firstModifiedPointVertex = first;
4516
- }
4517
- if (last > lastModifiedPointVertex) {
4518
- lastModifiedPointVertex = last;
4519
- }
4543
+ if (first < firstModifiedPointVertex) firstModifiedPointVertex = first;
4544
+ if (last > lastModifiedPointVertex) lastModifiedPointVertex = last;
4520
4545
  modifiedPointVertices = true;
4521
4546
  modified = true;
4522
4547
  }
4523
4548
 
4549
+
4524
4550
  protected void setModifiedPointColors(int first, int last) {
4525
- if (first < firstModifiedPointColor) {
4526
- firstModifiedPointColor = first;
4527
- }
4528
- if (last > lastModifiedPointColor) {
4529
- lastModifiedPointColor = last;
4530
- }
4551
+ if (first < firstModifiedPointColor) firstModifiedPointColor = first;
4552
+ if (last > lastModifiedPointColor) lastModifiedPointColor = last;
4531
4553
  modifiedPointColors = true;
4532
4554
  modified = true;
4533
4555
  }
4534
4556
 
4557
+
4535
4558
  protected void setModifiedPointAttributes(int first, int last) {
4536
- if (first < firstModifiedPointAttribute) {
4537
- firstModifiedPointAttribute = first;
4538
- }
4539
- if (last > lastModifiedPointAttribute) {
4540
- lastModifiedPointAttribute = last;
4541
- }
4559
+ if (first < firstModifiedPointAttribute) firstModifiedPointAttribute = first;
4560
+ if (last > lastModifiedPointAttribute) lastModifiedPointAttribute = last;
4542
4561
  modifiedPointAttributes = true;
4543
4562
  modified = true;
4544
4563
  }
4545
4564
 
4565
+
4546
4566
  ///////////////////////////////////////////////////////////
4567
+
4547
4568
  //
4569
+
4548
4570
  // Style handling
4571
+
4572
+
4549
4573
  @Override
4550
4574
  public void disableStyle() {
4551
4575
  if (openShape) {
@@ -4572,6 +4596,7 @@ public class PShapeOpenGL extends PShape {
4572
4596
  super.disableStyle();
4573
4597
  }
4574
4598
 
4599
+
4575
4600
  @Override
4576
4601
  public void enableStyle() {
4577
4602
  if (savedStroke) {
@@ -4608,6 +4633,7 @@ public class PShapeOpenGL extends PShape {
4608
4633
  super.enableStyle();
4609
4634
  }
4610
4635
 
4636
+
4611
4637
  @Override
4612
4638
  protected void styles(PGraphics g) {
4613
4639
  if (g instanceof PGraphicsOpenGL) {
@@ -4646,18 +4672,25 @@ public class PShapeOpenGL extends PShape {
4646
4672
  }
4647
4673
  }
4648
4674
 
4675
+
4649
4676
  ///////////////////////////////////////////////////////////
4677
+
4650
4678
  //
4679
+
4651
4680
  // Rendering methods
4681
+
4682
+
4652
4683
  /*
4653
4684
  public void draw() {
4654
4685
  draw(pg);
4655
4686
  }
4656
- */
4687
+ */
4688
+
4689
+
4657
4690
  @Override
4658
4691
  public void draw(PGraphics g) {
4659
4692
  if (g instanceof PGraphicsOpenGL) {
4660
- PGraphicsOpenGL gl = (PGraphicsOpenGL) g;
4693
+ PGraphicsOpenGL gl = (PGraphicsOpenGL)g;
4661
4694
  if (visible) {
4662
4695
  pre(gl);
4663
4696
 
@@ -4672,7 +4705,7 @@ public class PShapeOpenGL extends PShape {
4672
4705
  } else {
4673
4706
  PImage tex = null;
4674
4707
  if (textures != null && textures.size() == 1) {
4675
- tex = (PImage) textures.toArray()[0];
4708
+ tex = (PImage)textures.toArray()[0];
4676
4709
  }
4677
4710
  render(gl, tex);
4678
4711
  }
@@ -4691,6 +4724,7 @@ public class PShapeOpenGL extends PShape {
4691
4724
  }
4692
4725
  }
4693
4726
 
4727
+
4694
4728
  private void inGeoToVertices() {
4695
4729
  vertexCount = 0;
4696
4730
  vertexCodeCount = 0;
@@ -4698,7 +4732,7 @@ public class PShapeOpenGL extends PShape {
4698
4732
  for (int i = 0; i < inGeo.vertexCount; i++) {
4699
4733
  int index = 3 * i;
4700
4734
  float x = inGeo.vertices[index++];
4701
- float y = inGeo.vertices[index];
4735
+ float y = inGeo.vertices[index ];
4702
4736
  super.vertex(x, y);
4703
4737
  }
4704
4738
  } else {
@@ -4712,63 +4746,63 @@ public class PShapeOpenGL extends PShape {
4712
4746
  for (int j = 0; j < inGeo.codeCount; j++) {
4713
4747
  switch (inGeo.codes[j]) {
4714
4748
 
4715
- case VERTEX:
4716
- v = 3 * idx;
4717
- x = inGeo.vertices[v++];
4718
- y = inGeo.vertices[v];
4719
- super.vertex(x, y);
4749
+ case VERTEX:
4750
+ v = 3 * idx;
4751
+ x = inGeo.vertices[v++];
4752
+ y = inGeo.vertices[v ];
4753
+ super.vertex(x, y);
4720
4754
 
4721
- idx++;
4722
- break;
4755
+ idx++;
4756
+ break;
4723
4757
 
4724
- case QUADRATIC_VERTEX:
4725
- v = 3 * idx;
4726
- cx = inGeo.vertices[v++];
4727
- cy = inGeo.vertices[v];
4758
+ case QUADRATIC_VERTEX:
4759
+ v = 3 * idx;
4760
+ cx = inGeo.vertices[v++];
4761
+ cy = inGeo.vertices[v];
4728
4762
 
4729
- v = 3 * (idx + 1);
4730
- x3 = inGeo.vertices[v++];
4731
- y3 = inGeo.vertices[v];
4763
+ v = 3 * (idx + 1);
4764
+ x3 = inGeo.vertices[v++];
4765
+ y3 = inGeo.vertices[v];
4732
4766
 
4733
- super.quadraticVertex(cx, cy, x3, y3);
4767
+ super.quadraticVertex(cx, cy, x3, y3);
4734
4768
 
4735
- idx += 2;
4736
- break;
4769
+ idx += 2;
4770
+ break;
4737
4771
 
4738
- case BEZIER_VERTEX:
4739
- v = 3 * idx;
4740
- x2 = inGeo.vertices[v++];
4741
- y2 = inGeo.vertices[v];
4772
+ case BEZIER_VERTEX:
4773
+ v = 3 * idx;
4774
+ x2 = inGeo.vertices[v++];
4775
+ y2 = inGeo.vertices[v ];
4742
4776
 
4743
- v = 3 * (idx + 1);
4744
- x3 = inGeo.vertices[v++];
4745
- y3 = inGeo.vertices[v];
4777
+ v = 3 * (idx + 1);
4778
+ x3 = inGeo.vertices[v++];
4779
+ y3 = inGeo.vertices[v ];
4746
4780
 
4747
- v = 3 * (idx + 2);
4748
- x4 = inGeo.vertices[v++];
4749
- y4 = inGeo.vertices[v];
4781
+ v = 3 * (idx + 2);
4782
+ x4 = inGeo.vertices[v++];
4783
+ y4 = inGeo.vertices[v ];
4750
4784
 
4751
- super.bezierVertex(x2, y2, x3, y3, x4, y4);
4785
+ super.bezierVertex(x2, y2, x3, y3, x4, y4);
4752
4786
 
4753
- idx += 3;
4754
- break;
4787
+ idx += 3;
4788
+ break;
4755
4789
 
4756
- case CURVE_VERTEX:
4757
- v = 3 * idx;
4758
- x = inGeo.vertices[v++];
4759
- y = inGeo.vertices[v];
4790
+ case CURVE_VERTEX:
4791
+ v = 3 * idx;
4792
+ x = inGeo.vertices[v++];
4793
+ y = inGeo.vertices[v ];
4760
4794
 
4761
- super.curveVertex(x, y);
4795
+ super.curveVertex(x, y);
4762
4796
 
4763
- idx++;
4764
- break;
4797
+ idx++;
4798
+ break;
4765
4799
 
4766
- case BREAK:
4767
- if (insideContour) {
4768
- super.endContourImpl();
4769
- }
4770
- super.beginContourImpl();
4771
- insideContour = true;
4800
+ case BREAK:
4801
+ if (insideContour) {
4802
+ super.endContourImpl();
4803
+ }
4804
+ super.beginContourImpl();
4805
+ insideContour = true;
4772
4806
  }
4773
4807
  }
4774
4808
  if (insideContour) {
@@ -4777,6 +4811,7 @@ public class PShapeOpenGL extends PShape {
4777
4811
  }
4778
4812
  }
4779
4813
 
4814
+
4780
4815
  // Returns true if some child shapes below this one either
4781
4816
  // use different texture maps (or only one texture is used by some while
4782
4817
  // others are untextured), or have stroked textures,
@@ -4784,11 +4819,12 @@ public class PShapeOpenGL extends PShape {
4784
4819
  // Or accurate 2D mode is enabled, which forces each
4785
4820
  // shape to be rendered separately.
4786
4821
  protected boolean fragmentedGroup(PGraphicsOpenGL g) {
4787
- return g.getHint(DISABLE_OPTIMIZED_STROKE)
4788
- || (textures != null && (1 < textures.size() || untexChild))
4789
- || strokedTexture;
4822
+ return g.getHint(DISABLE_OPTIMIZED_STROKE) ||
4823
+ (textures != null && (1 < textures.size() || untexChild)) ||
4824
+ strokedTexture;
4790
4825
  }
4791
4826
 
4827
+
4792
4828
  @Override
4793
4829
  protected void pre(PGraphics g) {
4794
4830
  if (g instanceof PGraphicsOpenGL) {
@@ -4800,6 +4836,7 @@ public class PShapeOpenGL extends PShape {
4800
4836
  }
4801
4837
  }
4802
4838
 
4839
+
4803
4840
  @Override
4804
4841
  protected void post(PGraphics g) {
4805
4842
  if (g instanceof PGraphicsOpenGL) {
@@ -4808,6 +4845,7 @@ public class PShapeOpenGL extends PShape {
4808
4845
  }
4809
4846
  }
4810
4847
 
4848
+
4811
4849
  @Override
4812
4850
  protected void drawGeometry(PGraphics g) {
4813
4851
  vertexCount = inGeo.vertexCount;
@@ -4819,13 +4857,14 @@ public class PShapeOpenGL extends PShape {
4819
4857
  vertices = null;
4820
4858
  }
4821
4859
 
4860
+
4822
4861
  // Render the geometry stored in the root shape as VBOs, for the vertices
4823
4862
  // corresponding to this shape. Sometimes we can have root == this.
4824
4863
  protected void render(PGraphicsOpenGL g, PImage texture) {
4825
4864
  if (root == null) {
4826
4865
  // Some error. Root should never be null. At least it should be 'this'.
4827
- throw new RuntimeException("Error rendering PShapeOpenGL, root shape is "
4828
- + "null");
4866
+ throw new RuntimeException("Error rendering PShapeOpenGL, root shape is " +
4867
+ "null");
4829
4868
  }
4830
4869
 
4831
4870
  if (hasPolys) {
@@ -4854,6 +4893,7 @@ public class PShapeOpenGL extends PShape {
4854
4893
  }
4855
4894
  }
4856
4895
 
4896
+
4857
4897
  protected void renderPolys(PGraphicsOpenGL g, PImage textureImage) {
4858
4898
  boolean customShader = g.polyShader != null;
4859
4899
  boolean needNormals = customShader ? g.polyShader.accessNormals() : false;
@@ -4865,10 +4905,10 @@ public class PShapeOpenGL extends PShape {
4865
4905
  PShader shader = null;
4866
4906
  IndexCache cache = tessGeo.polyIndexCache;
4867
4907
  for (int n = firstPolyIndexCache; n <= lastPolyIndexCache; n++) {
4868
- if (is3D() || (tex != null && (firstLineIndexCache == -1
4869
- || n < firstLineIndexCache)
4870
- && (firstPointIndexCache == -1
4871
- || n < firstPointIndexCache))) {
4908
+ if (is3D() || (tex != null && (firstLineIndexCache == -1 ||
4909
+ n < firstLineIndexCache) &&
4910
+ (firstPointIndexCache == -1 ||
4911
+ n < firstPointIndexCache))) {
4872
4912
  // Rendering fill triangles, which can be lit and textured.
4873
4913
  if (!renderingFill) {
4874
4914
  shader = g.getPolyShader(g.lights, tex != null);
@@ -4902,56 +4942,53 @@ public class PShapeOpenGL extends PShape {
4902
4942
  int voffset = cache.vertexOffset[n];
4903
4943
 
4904
4944
  shader.setVertexAttribute(root.bufPolyVertex.glId, 4, PGL.FLOAT,
4905
- 0, 4 * voffset * PGL.SIZEOF_FLOAT);
4945
+ 0, 4 * voffset * PGL.SIZEOF_FLOAT);
4906
4946
  shader.setColorAttribute(root.bufPolyColor.glId, 4, PGL.UNSIGNED_BYTE,
4907
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
4947
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
4908
4948
 
4909
4949
  if (g.lights) {
4910
4950
  shader.setNormalAttribute(root.bufPolyNormal.glId, 3, PGL.FLOAT,
4911
- 0, 3 * voffset * PGL.SIZEOF_FLOAT);
4951
+ 0, 3 * voffset * PGL.SIZEOF_FLOAT);
4912
4952
  shader.setAmbientAttribute(root.bufPolyAmbient.glId, 4, PGL.UNSIGNED_BYTE,
4913
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
4953
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
4914
4954
  shader.setSpecularAttribute(root.bufPolySpecular.glId, 4, PGL.UNSIGNED_BYTE,
4915
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
4955
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
4916
4956
  shader.setEmissiveAttribute(root.bufPolyEmissive.glId, 4, PGL.UNSIGNED_BYTE,
4917
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
4957
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
4918
4958
  shader.setShininessAttribute(root.bufPolyShininess.glId, 1, PGL.FLOAT,
4919
- 0, voffset * PGL.SIZEOF_FLOAT);
4959
+ 0, voffset * PGL.SIZEOF_FLOAT);
4920
4960
  }
4921
4961
  if (g.lights || needNormals) {
4922
4962
  shader.setNormalAttribute(root.bufPolyNormal.glId, 3, PGL.FLOAT,
4923
- 0, 3 * voffset * PGL.SIZEOF_FLOAT);
4963
+ 0, 3 * voffset * PGL.SIZEOF_FLOAT);
4924
4964
  }
4925
4965
 
4926
4966
  if (tex != null || needTexCoords) {
4927
4967
  shader.setTexcoordAttribute(root.bufPolyTexcoord.glId, 2, PGL.FLOAT,
4928
- 0, 2 * voffset * PGL.SIZEOF_FLOAT);
4968
+ 0, 2 * voffset * PGL.SIZEOF_FLOAT);
4929
4969
  shader.setTexture(tex);
4930
4970
  }
4931
4971
 
4932
- for (VertexAttribute attrib : polyAttribs.values()) {
4933
- if (!attrib.active(shader)) {
4934
- continue;
4935
- }
4972
+ for (VertexAttribute attrib: polyAttribs.values()) {
4973
+ if (!attrib.active(shader)) continue;
4936
4974
  attrib.bind(pgl);
4937
4975
  shader.setAttributeVBO(attrib.glLoc, attrib.buf.glId,
4938
- attrib.tessSize, attrib.type,
4939
- attrib.isColor(), 0, attrib.sizeInBytes(voffset));
4976
+ attrib.tessSize, attrib.type,
4977
+ attrib.isColor(), 0, attrib.sizeInBytes(voffset));
4940
4978
  }
4941
4979
 
4942
4980
  shader.draw(root.bufPolyIndex.glId, icount, ioffset);
4943
4981
  }
4944
4982
 
4945
- for (VertexAttribute attrib : polyAttribs.values()) {
4946
- if (attrib.active(shader)) {
4947
- attrib.unbind(pgl);
4948
- }
4983
+ for (VertexAttribute attrib: polyAttribs.values()) {
4984
+ if (attrib.active(shader)) attrib.unbind(pgl);
4949
4985
  }
4950
4986
  if (shader != null && shader.bound()) {
4951
4987
  shader.unbind();
4952
4988
  }
4953
4989
  }
4954
4990
 
4991
+
4955
4992
  protected void rawPolys(PGraphicsOpenGL g, PImage textureImage) {
4956
4993
  PGraphics raw = g.getRaw();
4957
4994
 
@@ -5046,6 +5083,7 @@ public class PShapeOpenGL extends PShape {
5046
5083
  raw.endShape();
5047
5084
  }
5048
5085
 
5086
+
5049
5087
  protected void renderLines(PGraphicsOpenGL g) {
5050
5088
  PShader shader = g.getLineShader();
5051
5089
  shader.bind();
@@ -5057,11 +5095,11 @@ public class PShapeOpenGL extends PShape {
5057
5095
  int voffset = cache.vertexOffset[n];
5058
5096
 
5059
5097
  shader.setVertexAttribute(root.bufLineVertex.glId, 4, PGL.FLOAT,
5060
- 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5098
+ 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5061
5099
  shader.setColorAttribute(root.bufLineColor.glId, 4, PGL.UNSIGNED_BYTE,
5062
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
5100
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
5063
5101
  shader.setLineAttribute(root.bufLineAttrib.glId, 4, PGL.FLOAT,
5064
- 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5102
+ 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5065
5103
 
5066
5104
  shader.draw(root.bufLineIndex.glId, icount, ioffset);
5067
5105
  }
@@ -5069,6 +5107,7 @@ public class PShapeOpenGL extends PShape {
5069
5107
  shader.unbind();
5070
5108
  }
5071
5109
 
5110
+
5072
5111
  protected void rawLines(PGraphicsOpenGL g) {
5073
5112
  PGraphics raw = g.getRaw();
5074
5113
 
@@ -5100,9 +5139,8 @@ public class PShapeOpenGL extends PShape {
5100
5139
  float sw0 = 2 * attribs[4 * i0 + 3];
5101
5140
  float sw1 = 2 * attribs[4 * i1 + 3];
5102
5141
 
5103
- if (PGraphicsOpenGL.zero(sw0)) {
5104
- continue; // Bevel triangles, skip.
5105
- }
5142
+ if (PGraphicsOpenGL.zero(sw0)) continue; // Bevel triangles, skip.
5143
+
5106
5144
  float[] src0 = {0, 0, 0, 0};
5107
5145
  float[] src1 = {0, 0, 0, 0};
5108
5146
  float[] pt0 = {0, 0, 0, 0};
@@ -5142,6 +5180,7 @@ public class PShapeOpenGL extends PShape {
5142
5180
  raw.endShape();
5143
5181
  }
5144
5182
 
5183
+
5145
5184
  protected void renderPoints(PGraphicsOpenGL g) {
5146
5185
  PShader shader = g.getPointShader();
5147
5186
  shader.bind();
@@ -5153,11 +5192,11 @@ public class PShapeOpenGL extends PShape {
5153
5192
  int voffset = cache.vertexOffset[n];
5154
5193
 
5155
5194
  shader.setVertexAttribute(root.bufPointVertex.glId, 4, PGL.FLOAT,
5156
- 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5195
+ 0, 4 * voffset * PGL.SIZEOF_FLOAT);
5157
5196
  shader.setColorAttribute(root.bufPointColor.glId, 4, PGL.UNSIGNED_BYTE,
5158
- 0, 4 * voffset * PGL.SIZEOF_BYTE);
5197
+ 0, 4 * voffset * PGL.SIZEOF_BYTE);
5159
5198
  shader.setPointAttribute(root.bufPointAttrib.glId, 2, PGL.FLOAT,
5160
- 0, 2 * voffset * PGL.SIZEOF_FLOAT);
5199
+ 0, 2 * voffset * PGL.SIZEOF_FLOAT);
5161
5200
 
5162
5201
  shader.draw(root.bufPointIndex.glId, icount, ioffset);
5163
5202
  }
@@ -5165,6 +5204,7 @@ public class PShapeOpenGL extends PShape {
5165
5204
  shader.unbind();
5166
5205
  }
5167
5206
 
5207
+
5168
5208
  protected void rawPoints(PGraphicsOpenGL g) {
5169
5209
  PGraphics raw = g.getRaw();
5170
5210
 
@@ -5192,9 +5232,9 @@ public class PShapeOpenGL extends PShape {
5192
5232
  if (0 < size) { // round point
5193
5233
  weight = +size / 0.5f;
5194
5234
  perim = PApplet.min(PGraphicsOpenGL.MAX_POINT_ACCURACY,
5195
- PApplet.max(PGraphicsOpenGL.MIN_POINT_ACCURACY,
5196
- (int) (TWO_PI * weight
5197
- / PGraphicsOpenGL.POINT_ACCURACY_FACTOR))) + 1;
5235
+ PApplet.max(PGraphicsOpenGL.MIN_POINT_ACCURACY,
5236
+ (int) (TWO_PI * weight /
5237
+ PGraphicsOpenGL.POINT_ACCURACY_FACTOR))) + 1;
5198
5238
  } else { // Square point
5199
5239
  weight = -size / 0.5f;
5200
5240
  perim = 5;