Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions genesis/engine/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,15 @@ def decimate(self, decimate_face_num, decimate_aggressiveness, convexify):
"""
if self._mesh.vertices.shape[0] > 3 and self._mesh.faces.shape[0] > decimate_face_num:
self._mesh.process(validate=True)
# TODO: lossless option support is pending on fast_simplification package.
# NOTE: https://github.com/pyvista/fast-simplification/pull/71
if decimate_aggressiveness == 0:
gs.logger.debug("Lossless simplification is not supported yet. Not applying simplification.")
self._mesh = trimesh.Trimesh(
vertices=self._mesh.vertices,
faces=self._mesh.faces,
)
else:
self._mesh = trimesh.Trimesh(
*fast_simplification.simplify(
self._mesh.vertices,
self._mesh.faces,
target_count=decimate_face_num,
agg=decimate_aggressiveness,
)
self._mesh = trimesh.Trimesh(
*fast_simplification.simplify(
self._mesh.vertices,
self._mesh.faces,
target_count=decimate_face_num,
agg=decimate_aggressiveness,
lossless=(decimate_aggressiveness == 0),
)
)

# need to run convexify again after decimation, because sometimes decimating a convex-mesh can make it non-convex...
if convexify:
Expand Down
14 changes: 6 additions & 8 deletions genesis/utils/terrain.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,12 @@ def convert_heightfield_to_watertight_trimesh(

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

if uvs is not None:
idx_map = np.empty(len(v_simp), dtype=np.int64)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ dependencies = [
# Native batch renderer specifically designed for Genesis
"gs-madrona>=0.0.2; platform_system == 'Linux' and (platform_machine == 'x86_64' or platform_machine == 'AMD64')",
# Used for mesh simplification
"fast_simplification",
"fast_simplification>=0.1.12",
]

[project.optional-dependencies]
Expand Down