2

I created two default cubes, and offset one of them by 2m, so that they 'touch' perfectly.
Touching cubes

Running the following code returns an empty list:

def get_contact_polygons(self, obj1, obj2):
obj1_data = obj1.data
obj2_data = obj2.data

# Get a BMesh representation
bm1 = bmesh.new()  # create an empty BMesh
bm1.from_mesh(obj1_data)
bm1.transform(obj1.matrix_world)

bm2 = bmesh.new()  # create an empty BMesh
bm2.from_mesh(obj2_data)
bm2.transform(obj2.matrix_world)

tree1 = BVHTree.FromBMesh(bm1)
tree2 = BVHTree.FromBMesh(bm2)

# Returns: Returns a list of unique index pairs, the first index referencing tree1, the second referencing tree2.
return tree1.overlap(tree2)

Given that the two faces share exactly the same coordinates, I expected this to return a non-empty list. Playing around with the epsilon value also didn't help. Any help would be appreciated.

  • 1
    From what I know, overlap is unreliable for coplanar polygons. – Markus von Broady Sep 23 '22 at 13:28
  • @MarkusvonBroady oh ok, I didn't know that. Is that something that has been documented somewhere? I couldn't find any other posts related to this when googling. – Vukas Pajic Sep 23 '22 at 13:34
  • 1
    I've seen it mentioned e.g. here: https://blender.stackexchange.com/a/45834/60486 – Markus von Broady Sep 23 '22 at 13:41
  • I tried a workaround which involved slightly rotating the mesh - this led to the collision between the objects being identified, however the colliding or touching polygons are not returned in the list of indices, which is incredibly annoying. – Vukas Pajic Sep 26 '22 at 07:06

0 Answers0