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.


1 Answer 1


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

  • it does not account for other info, if one obj is inside another, normals etc, only if they touch
  • it does not work for coplanar poly well, for example 2 blender default plane objects, one slightly shifted x (not reliable on this)
  • $\begingroup$ For a test I used the standard objects Suzanne and Cone with this code:import bpy from mathutils.bvhtree import BVHTree scene = bpy.context.scene 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 ?? $\endgroup$ Jan 29, 2016 at 9:20
  • 2
    $\begingroup$ I only used from polygon. Where you have vectors and poly indices. And I used obj.matrix_world * vector. And it worked very well. I guess this also goes for bmesh, as there is a bmesh transform (with matrix) that u can use first. $\endgroup$
    – o.g.
    Jan 29, 2016 at 9:56
  • $\begingroup$ You are completely right. If I use the bmesh transform it works! Thank you $\endgroup$ Jan 29, 2016 at 13:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.