Skip to content

Commit 150488a

Browse files
committed
repair+only_watertight arguments to submesh didn't work as described
1 parent 6dd6c9c commit 150488a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

trimesh/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,11 @@ def split(
384384
if adjacency is None:
385385
adjacency = mesh.face_adjacency
386386

387-
# if only watertight the shortest thing we can split has 3 triangles
388387
if only_watertight:
388+
# the smallest watertight mesh has 4 faces
389389
min_len = 4
390390
else:
391+
# allow any size of connected component
391392
min_len = 1
392393

393394
components = connected_components(

trimesh/util.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,14 +1657,20 @@ def submesh(
16571657
for v, f, n, c in zip(vertices, faces, normals, visuals)
16581658
]
16591659

1660+
# assign the "source" information summarizing where a mesh was
1661+
# loaded from (i.e. file name) to each submesh of the result
16601662
[setattr(r, "_source", deepcopy(mesh.source)) for r in result]
16611663

1662-
if only_watertight or repair:
1664+
if repair:
16631665
# fill_holes will attempt a repair and returns the
16641666
# watertight status at the end of the repair attempt
1665-
watertight = [i.fill_holes() and len(i.faces) >= 4 for i in result]
1667+
watertight = [len(i.faces) >= 4 and i.fill_holes() for i in result]
1668+
elif only_watertight:
1669+
# calculate watertightness without repairing
1670+
watertight = [i.is_watertight for i in result]
1671+
16661672
if only_watertight:
1667-
# remove unrepairable meshes
1673+
# return only the watertight meshes
16681674
return [i for i, w in zip(result, watertight) if w]
16691675

16701676
return result

0 commit comments

Comments
 (0)