Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if mesh is a cube that would be accepted as a unreal collision volume
import lx
import lxu
import modo
from math import isclose
mesh, = modo.Scene().selectedByType('mesh')
result = set()
with mesh.geometry as geo:
normals = set()
for polygon in geo.polygons:
normals.add(polygon.normal)
for a in normals:
for b in normals:
if a == b: continue
zero = isclose(abs(lxu.vector.dot(a,b)), 0.0, abs_tol=0.000001)
one = isclose(abs(lxu.vector.dot(a,b)), 1.0, abs_tol=0.000001)
result.add(zero or one)
if False in result:
print("Not nice box")
else:
print("Beautiful, beautiful box")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment