Skip to content

Commit 2c83a92

Browse files
authored
[FEATURE] Use fast-simplification 0.1.12. (#1508)
1 parent 3b8499c commit 2c83a92

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

genesis/engine/mesh.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,15 @@ def decimate(self, decimate_face_num, decimate_aggressiveness, convexify):
9393
"""
9494
if self._mesh.vertices.shape[0] > 3 and self._mesh.faces.shape[0] > decimate_face_num:
9595
self._mesh.process(validate=True)
96-
# TODO: lossless option support is pending on fast_simplification package.
97-
# NOTE: https://github.com/pyvista/fast-simplification/pull/71
98-
if decimate_aggressiveness == 0:
99-
gs.logger.debug("Lossless simplification is not supported yet. Not applying simplification.")
100-
self._mesh = trimesh.Trimesh(
101-
vertices=self._mesh.vertices,
102-
faces=self._mesh.faces,
103-
)
104-
else:
105-
self._mesh = trimesh.Trimesh(
106-
*fast_simplification.simplify(
107-
self._mesh.vertices,
108-
self._mesh.faces,
109-
target_count=decimate_face_num,
110-
agg=decimate_aggressiveness,
111-
)
96+
self._mesh = trimesh.Trimesh(
97+
*fast_simplification.simplify(
98+
self._mesh.vertices,
99+
self._mesh.faces,
100+
target_count=decimate_face_num,
101+
agg=decimate_aggressiveness,
102+
lossless=(decimate_aggressiveness == 0),
112103
)
104+
)
113105

114106
# need to run convexify again after decimation, because sometimes decimating a convex-mesh can make it non-convex...
115107
if convexify:

genesis/utils/terrain.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -386,14 +386,12 @@ def convert_heightfield_to_watertight_trimesh(
386386

387387
# This is the mesh used for non-sdf purposes.
388388
# It's losslessly simplified from the full mesh, to save memory cost for storing verts and faces.
389-
# TODO: lossless option support is pending on fast_simplification package.
390-
# v_simp, f_simp = fast_simplification.simplify(
391-
# sdf_mesh.vertices,
392-
# sdf_mesh.faces,
393-
# target_count=0,
394-
# lossless=True,
395-
# )
396-
v_simp, f_simp = sdf_mesh.vertices, sdf_mesh.faces
389+
v_simp, f_simp = fast_simplification.simplify(
390+
sdf_mesh.vertices,
391+
sdf_mesh.faces,
392+
target_count=0,
393+
lossless=True,
394+
)
397395

398396
if uvs is not None:
399397
idx_map = np.empty(len(v_simp), dtype=np.int64)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ dependencies = [
6060
# Native batch renderer specifically designed for Genesis
6161
"gs-madrona>=0.0.2; platform_system == 'Linux' and (platform_machine == 'x86_64' or platform_machine == 'AMD64')",
6262
# Used for mesh simplification
63-
"fast_simplification",
63+
"fast_simplification>=0.1.12",
6464
]
6565

6666
[project.optional-dependencies]

0 commit comments

Comments
 (0)