Context:
I am working on a tree generation script and I am pretty happy with how it turned out, but I encountered an issue when adding leaves to my tree. The leaves themselves have no modifiers and for for the sake of this question could be replaced with the default cube(their vertice number does not exceed 30).
The Problem:
Initially I thought that the coping and placing the leaves to their respective branches on the tree took the longest to complete, but after I ran some tests it turns out that actually joining the leaves to the tree is what took the longest. (Almost 3 or 4 times more than copying and moving them around)
I used the below function to join my leaves to the tree:
def JoinTreeObjectsWithTree(tree):
global treeObjects
#join leaf with Trunk
tree.select_set(True)
bpy.context.view_layer.objects.active = tree
for treeObject in treeObjects:
treeObject.select_set(True)
bpy.ops.object.join()
bpy.ops.object.select_all(action='DESELECT')
treeObjects = []
The tree objects array is the actual array where the leaves reside and the tree is well the main body of the tree as an object.
Is there a way to speed this up?