Skip to content

Instantly share code, notes, and snippets.

@rondreas
Created June 17, 2021 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondreas/d0e1cf0e16be95a06a11a0e46acd2f4a to your computer and use it in GitHub Desktop.
Save rondreas/d0e1cf0e16be95a06a11a0e46acd2f4a to your computer and use it in GitHub Desktop.
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