You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The below code sample has a copy of the implementation .
The below code also has a fix (one line), removing the mesh copies after use.
Minimal code example
importblenderprocasbproc# noqaimportmathutils# type: ignorefromtypingimportListfromblenderproc.python.types.MeshObjectUtilityimportMeshObject, bmesh, Matrixdefcreate_bvh_tree_multi_objects(
mesh_objects: List[MeshObject],
) ->mathutils.bvhtree.BVHTree:
"""Creates a bvh tree which contains multiple mesh objects. Such a tree is later used for fast raycasting. :param mesh_objects: The list of mesh objects that should be put into the BVH tree. :return: The built BVH tree. """# Create bmesh which will contain the meshes of all objectsbm=bmesh.new()
# Go through all mesh objectsforobjinmesh_objects:
# Get a copy of the meshmesh=obj.get_mesh().copy()
# Apply world matrixmesh.transform(Matrix(obj.get_local2world_mat()))
# Add object mesh to bmeshbm.from_mesh(mesh)
# Uncomment below line to avoid leaving orphan meshes# bpy.data.meshes.remove(mesh)# Create tree from bmeshbvh_tree=mathutils.bvhtree.BVHTree.FromBMesh(bm)
bm.free()
returnbvh_treebproc.init()
mesh=bproc.object.create_primitive("SPHERE")
foriinrange(500):
create_bvh_tree_multi_objects([mesh] *100)
Files required to run the code
No response
Expected behavior
Would expect that create_bvh_tree_multi_objects frees any temporary objects that it might create, but memory usage increases when called multiple times.
BlenderProc version
v2.7.1
The text was updated successfully, but these errors were encountered:
Describe the issue
Observing increasing memory usage when calling create_bvh_tree_multi_objects multiple times.
The below code sample has a copy of the implementation .
The below code also has a fix (one line), removing the mesh copies after use.
Minimal code example
Files required to run the code
No response
Expected behavior
Would expect that create_bvh_tree_multi_objects frees any temporary objects that it might create, but memory usage increases when called multiple times.
BlenderProc version
v2.7.1
The text was updated successfully, but these errors were encountered: