In addition to this discussion:
How to check if two meshes intersect in python?
I would like to know if the new mathutils.bvhtree module may help to detect intersections of two meshes.
In addition to this discussion:
How to check if two meshes intersect in python?
I would like to know if the new mathutils.bvhtree module may help to detect intersections of two meshes.
yes, overlap in mathutils.bvhtree does show pairs of polygons that are intersecting if any.
You will have to create 2 bvh trees, for each mesh, using one of the methods given in the api (from Object, from Bmesh, from Polygons), then use those as pairs = bvhA.overlap(bvhB)
So a basic check would just see if that list is [] or something. Or may further use the pairs of poly to do something.
Note that there are some limitations
Suzanne = bpy.data.objects["Suzanne"] Cone = bpy.data.objects["Cone"]
Tree_Suzanne = BVHTree.FromObject(Suzanne, scene, deform = False,
render = False, cage = False, epsilon = 0.01)
Tree_Cone = BVHTree.FromObject(Cone, scene, deform = True,
render = False, cage = False, epsilon = 0.01)
overlap_pairs = Tree_Cone.overlap(Tree_Suzanne)
print(len(overlap_pairs)). The result: Always 96 independent of the position of objects ??
– Peter Hilgers Jan 29 '16 at 09:20