Skip to content

Commit cd9a855

Browse files
authored
Parse voxel resolution SDF param when decomposing meshes (gazebosim#2445)
Signed-off-by: Ian Chen <ichen@openrobotics.org>
1 parent ed2b64c commit cd9a855

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/Util.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -891,20 +891,24 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf,
891891

892892
auto &meshManager = *common::MeshManager::Instance();
893893
std::size_t maxConvexHulls = 16u;
894+
std::size_t voxelResolution = 200000u;
895+
if (_meshSdf.ConvexDecomposition())
896+
{
897+
// limit max number of convex hulls to generate
898+
maxConvexHulls = _meshSdf.ConvexDecomposition()->MaxConvexHulls();
899+
voxelResolution = _meshSdf.ConvexDecomposition()->VoxelResolution();
900+
}
894901
if (_meshSdf.Optimization() == sdf::MeshOptimization::CONVEX_HULL)
895902
{
896903
/// create 1 convex hull for the whole submesh
897904
maxConvexHulls = 1u;
898905
}
899-
else if (_meshSdf.ConvexDecomposition())
900-
{
901-
// limit max number of convex hulls to generate
902-
maxConvexHulls = _meshSdf.ConvexDecomposition()->MaxConvexHulls();
903-
}
906+
904907
// Check if MeshManager contains the decomposed mesh already. If not
905908
// add it to the MeshManager so we do not need to decompose it again.
906909
const std::string convexMeshName =
907-
_mesh.Name() + "_CONVEX_" + std::to_string(maxConvexHulls);
910+
_mesh.Name() + "_" + _meshSdf.Submesh() + "_CONVEX_" +
911+
std::to_string(maxConvexHulls) + "_" + std::to_string(voxelResolution);
908912
auto *optimizedMesh = meshManager.MeshByName(convexMeshName);
909913
if (!optimizedMesh)
910914
{
@@ -916,7 +920,7 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf,
916920
auto mergedSubmesh = mergedMesh->SubMeshByIndex(0u).lock();
917921
std::vector<common::SubMesh> decomposed =
918922
gz::common::MeshManager::ConvexDecomposition(
919-
*mergedSubmesh.get(), maxConvexHulls);
923+
*mergedSubmesh.get(), maxConvexHulls, voxelResolution);
920924
gzdbg << "Optimizing mesh (" << _meshSdf.OptimizationStr() << "): "
921925
<< _mesh.Name() << std::endl;
922926
// Create decomposed mesh and add it to MeshManager

0 commit comments

Comments
 (0)