New childs added to PShape after being displayed once won't show

Hello, in my sketch i continuesly add PShape childs to a group, but once i draw the group the newly added childs wont show up anymore, does anyone have a solution for this, or a workaround. I’d be very much appreciated.

below is an example, in my original code the problem occurs when i temporary add a child to the group when i press the mouseButton. perhaps this info is usefull.

Also, in my original code the group is quite large, and instead of just not showing the newly added childs, it crashes and gives the following error ‘BufferOverflowException’. Its also in 3d, but i dont know if that matters…

PShape shape;

void setup(){
  size(400, 400, P2D);
  
  frameRate(1);
  
  shape = createShape(GROUP);
}

void draw(){
  shape.addChild(createShape(RECT, random(0, width - 20), random(0, height - 20), 20, 20));
  
  if(mousePressed) shape(shape);
  
  println(frameCount);
}
1 Like

Hello @sem,

This code below works in Processing 3.5.4 but does NOT work as expected in Processing 4.1.3

PShape shape;

void setup()
  {
  size(400, 400, P3D);
  
  shape = createShape(GROUP);
  
  // Test to see if it worked in setup()
  for (int j=0; j<10; j++)
    {
    stroke(0, 255, 0);
    strokeWeight(3);
    mousePressed();
    }
  }

void draw()
  {
  background(255);
  stroke(255, 0, 0);
  strokeWeight(3);
  shape(shape);
  }

void mousePressed()
  {  
  shape.addChild(createShape(RECT, random(0, width - 20), random(0, height - 20), 20, 20));
  }
  

Processing 3.5.4 output:

image

Processing 4.1.3 output:

image

:)

2 Likes