mikedh / trimesh

Python library for loading and using triangular meshes.

Home Page:https://trimesh.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Boolean difference does not work with manifold

JeffreyWardman opened this issue · comments

manifold3d==2.3.1
trimesh==4.1.3

The operation silently outputs an empty Trimesh even when trying to subtract a shifted 1x1x1 cube from another cube of 1x1x1 positioned 0.5 away in z axis.

import vedo
import trimesh

mesh1_tri = vedo.utils.vedo2trimesh(vedo.Rectangle().extrude(1))
mesh2_tri = vedo.utils.vedo2trimesh(vedo.Rectangle().extrude(1).shift(0.5))

mesh = trimesh.boolean.boolean_manifold([mesh1_tri, mesh2_tri], operation=operation, debug=True)

Turns out it was because of missing/inverted normals. Feel free to close if this is expected but there were no errors or any clear way to determine the cause.

Thanks for the report! I added a check for mesh.is_volume to all boolean operations by default which would have raised an exception on the negative volume/inverted normals. The only downside is the check can potentially be expensive. Although boolean operations are almost certainly much slower than this check so it's probably worth doing in most cases.

Great. Thanks!