Created
June 17, 2021 15:16
-
-
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
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 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