I’m generating mazes in blender with a python script, and I’ve noticed it gets REALLY slow. The script works by adding cubes using primitve_add_cube() in copious amounts. I’ve noticed though that python can create about 100 ish cubes per second, but after several thousand, it slows to a crawl, around 5 per second. It would probably get even slower when approaching the hundreds of thousands of cubes or so which I am planning to do.
The script works first by generating the maze information, then it runs through a triple for-loop to place all the cubes in the right places. It is essentially this code:
for x in range(m.w):
for y in range(m.d):
me.update() # I have tried both with and without this line. It didn’t really change much.
for z in range(m.h):
# some stuff happens here to move the cubes to the right location
but it is pretty simple
primitive_add_cube(location = (x, y, z))
I’m wondering if anyone has any tips on how to make it faster.
Here’s some examples of what I’ve done so far. The cube took around 2 hours to add all the cubes.