Created
April 29, 2025 06:22
-
-
Save giobel/d96eca85945e50b59ccd43e5b3a5122f to your computer and use it in GitHub Desktop.
*BLENDER*
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blender Python Scripts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
from mathutils.bvhtree import BVHTree | |
# Set the frame range | |
start_frame = 100 | |
end_frame = 150 | |
# Get the objects you want to test | |
obj1 = bpy.data.objects['walkway'] | |
#obj2 = bpy.data.objects['Ex Bridge'] | |
obj2 = bpy.data.objects['Handrail'] | |
def get_bvh(obj): | |
mesh = obj.to_mesh() | |
bm = bmesh.new() | |
bm.from_mesh(mesh) | |
bm.transform(obj.matrix_world) | |
bvh = BVHTree.FromBMesh(bm) | |
bm.free() | |
obj.to_mesh_clear() | |
return bvh | |
#check every 2 frames for faster | |
for frame in range(start_frame, end_frame, 2): | |
print ('analyzing frame ' + str(frame) + '...') | |
bpy.context.scene.frame_set(frame) | |
bvh1 = get_bvh(obj1) | |
bvh2 = get_bvh(obj2) | |
inters = bvh1.overlap(bvh2) | |
if inters: | |
print(f"⚠️ ⚠️ Intersection detected at frame {frame}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment