import bpy, bmesh from mathutils import Vector from mathutils.bvhtree import BVHTree objs = [o for o in bpy.data.objects if o.type == 'MESH' and o.name.startswith("SM_DNR_") and o.name not in ("SM_DNR_Decals",)] data = {} for o in objs: bm = bmesh.new(); bm.from_mesh(o.data); bm.transform(o.matrix_world) bmesh.ops.triangulate(bm, faces=bm.faces[:]) data[o.name] = (BVHTree.FromBMesh(bm, epsilon=1e-6), [v.co.copy() for v in bm.verts]) bm.free() names = list(data) flag = [] for a in names: for b in names: if a == b: continue tb, _ = data[b]; _, va = data[a] bad = [] for p in va: r = tb.find_nearest(p, 0.03) if r[0] is None: continue loc, nrm, idx, dist = r s = (p - loc).dot(nrm) if s < -0.0010 and dist < 0.03: bad.append((round(p.x,3), round(p.y,3), round(p.z,3), round(s,4))) if bad: flag.append((a, b, len(bad), bad[:3])) result = {"penetrating_vertices": flag}