I have the following code to check if two objects overlapping and it's works well, I don't understand how to check overlapping for objects in pose position

Source of this code: https://blender.stackexchange.com/a/150047/97742

import bpy
from mathutils.bvhtree import BVHTree

# Get the objects
obj1 = bpy.data.objects["Cube"]
obj2 = bpy.data.objects["Suzanne"]

# Get their world matrix
mat1 = obj1.matrix_world
mat2 = obj2.matrix_world

# Get the geometry in world coordinates
vert1 = [mat1 @ v.co for v in obj1.data.vertices] 
poly1 = [p.vertices for p in obj1.data.polygons]

vert2 = [mat2 @ v.co for v in obj2.data.vertices] 
poly2 = [p.vertices for p in obj2.data.polygons]

# Create the BVH trees
bvh1 = BVHTree.FromPolygons( vert1, poly1 )
bvh2 = BVHTree.FromPolygons( vert2, poly2 )

# Test if overlap
if bvh1.overlap( bvh2 ):
    print( "Overlap" )
    print( "No overlap" )

1 Answer 1


Try replacing the # Get the objects part of that script with the script below.

# Get the objects
ob1 = bpy.data.objects["Cube"]
ob2 = bpy.data.objects["Suzanne"]

# Get the evaluated objects
depsgraph = bpy.context.evaluated_depsgraph_get()
obj1 = ob1.evaluated_get(depsgraph)
obj2 = ob2.evaluated_get(depsgraph)

See types.Depsgraph

  • $\begingroup$ It's working! Thank you $\endgroup$
    – Roy Shmuli
    Nov 10, 2020 at 16:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .