I am desperately trying to find a workaround for a problem I’ve had for quite a while now with a PShape group (thisModel) that has 60000 BOX PShapes in it in retained mode. When I translate each BOX the program is very slow. (15 fps) here is a simplified version of the problem, the variables w, h, r, g, b are not included
initialize
for (int i = 0; i < 60000; i++) {
PShape cube = createShape(BOX, w,h,w);
thisModel.addChild(cube)
}
draw
shapes = thisModel.getChildren();
for (int i = 0; i < shapes.length; i++) {
shapes[i].setFill(r, g, b);
shapes[i].resetMatrix();
shapes[i].translate(x, y, z);
}
translate is slowing everything down. i’ve read that there are probably problems with various aspects of the matrix transformations.
does anyone know how to do the same thing another faster way ? in opengl directly ?
i wrote it in 151 with GLGraphics and it runs very smoothly at 60fps but i need to port it to P3 (Java 8) as soon as possible. any help would be great !
again you post some sniplets ( from your very long code… )
but
a- could you format it using the
</> code formatter
b- could you make it a small but complete code what we can copy and run
( to verify it on other OS’s and hardware )
++like including variable settings, setup() / draw()
c- what is the difference to your last post?
besides you lost 2500 boxes?
the performance might not only go by the number of boxes ?children?
also with the canvas setup ( size / fullScreen / smooth )
i understand that you are disappointed ( testing several recent processing versions )
but did you check on the open points from https://github.com/processing/processing/issues ?
or report it there?
I’m not sure. The only other approach that comes to mind (not performance tested) is to call shape on the children directly, and specific the random location coordinates for each child shape at draw time. This means the child shape matrix is never updated and never needs to be reset – which might be faster…?:
void draw() {
background(0);
translate(0,0,-300);
for (int i = 0; i < shapes.length; i++) {
shape(shapes[i], random(width), random(height));
}
}