mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
2.98k stars 577 forks source link

slice_mesh_plane no longer preserves masked faces #1861

Open ramtingh opened 1 year ago

ramtingh commented 1 year ago

Hi,

I've noticed a change in behaviour of slice_mesh_plane sometime between version 3.15 and 3.20. I believe the intent originally (#1369) was that if a boolean mask is provided, only those cases are cut and the remaining faces are preserved. But in 3.20 they are no longer preserved.

Here's simple example using this sphere mesh, where I attempt to cut the mesh along the xy plane but only modify the right half of the mesh:

mesh = trimesh.load("Sphere.stl")
mask = np.any((mesh.vertices[:,0]>0)[mesh.faces], axis=1)
mesh = trimesh.intersections.slice_mesh_plane(mesh, np.array([0,0,1]), np.array([0,0,0]), face_index=mask)

3.15 result: image

3.20 result: image

mikedh commented 1 year ago

Thanks for the report and reproducible test! Looks like this was probably broken in https://github.com/mikedh/trimesh/commit/e295de9cf1ffeaf74336e2afe8ef564ee664cf65 which was a fix for #1745. I may not be able to get to this all that soon but PR's welcome!