From 1eedcab149d66a5b0592de9ea2f233e266474f88 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Mon, 25 Mar 2013 09:27:37 -0400 Subject: [PATCH] Fix #1671 --- core/src/processing/opengl/PShapeOpenGL.java | 52 ++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/core/src/processing/opengl/PShapeOpenGL.java b/core/src/processing/opengl/PShapeOpenGL.java index 92a59b6ca..ab9afd6dd 100644 --- a/core/src/processing/opengl/PShapeOpenGL.java +++ b/core/src/processing/opengl/PShapeOpenGL.java @@ -357,10 +357,10 @@ public class PShapeOpenGL extends PShape { @Override - public void addChild(PShape child) { - if (child instanceof PShapeOpenGL) { + public void addChild(PShape who) { + if (who instanceof PShapeOpenGL) { if (family == GROUP) { - PShapeOpenGL c3d = (PShapeOpenGL)child; + PShapeOpenGL c3d = (PShapeOpenGL)who; super.addChild(c3d); c3d.updateRoot(root); @@ -388,11 +388,55 @@ public class PShapeOpenGL extends PShape { PGraphics.showWarning("Cannot add child shape to non-group shape."); } } else { - PGraphics.showWarning("Shape must be 3D to be added to the group."); + PGraphics.showWarning("Shape must be OpenGL to be added to the group."); } } + @Override + public void addChild(PShape who, int idx) { + if (who instanceof PShapeOpenGL) { + if (family == GROUP) { + PShapeOpenGL c3d = (PShapeOpenGL)who; + + super.addChild(c3d, idx); + c3d.updateRoot(root); + markForTessellation(); + + if (c3d.family == GROUP) { + if (c3d.textures != null) { + for (PImage tex: c3d.textures) { + addTexture(tex); + } + } + if (c3d.strokedTexture) { + strokedTexture(true); + } + } else { + if (c3d.image != null) { + addTexture(c3d.image); + if (c3d.stroke) { + strokedTexture(true); + } + } + } + + } else { + PGraphics.showWarning("Cannot add child shape to non-group shape."); + } + } else { + PGraphics.showWarning("Shape must be OpenGL to be added to the group."); + } + } + + + @Override + public void removeChild(int idx) { + super.removeChild(idx); + markForTessellation(); + } + + protected void updateRoot(PShape root) { this.root = (PShapeOpenGL) root; if (family == GROUP) {