@@ -891,20 +891,24 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf,
891
891
892
892
auto &meshManager = *common::MeshManager::Instance ();
893
893
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
+ }
894
901
if (_meshSdf.Optimization () == sdf::MeshOptimization::CONVEX_HULL)
895
902
{
896
903
// / create 1 convex hull for the whole submesh
897
904
maxConvexHulls = 1u ;
898
905
}
899
- else if (_meshSdf.ConvexDecomposition ())
900
- {
901
- // limit max number of convex hulls to generate
902
- maxConvexHulls = _meshSdf.ConvexDecomposition ()->MaxConvexHulls ();
903
- }
906
+
904
907
// Check if MeshManager contains the decomposed mesh already. If not
905
908
// add it to the MeshManager so we do not need to decompose it again.
906
909
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);
908
912
auto *optimizedMesh = meshManager.MeshByName (convexMeshName);
909
913
if (!optimizedMesh)
910
914
{
@@ -916,7 +920,7 @@ const common::Mesh *optimizeMesh(const sdf::Mesh &_meshSdf,
916
920
auto mergedSubmesh = mergedMesh->SubMeshByIndex (0u ).lock ();
917
921
std::vector<common::SubMesh> decomposed =
918
922
gz::common::MeshManager::ConvexDecomposition (
919
- *mergedSubmesh.get (), maxConvexHulls);
923
+ *mergedSubmesh.get (), maxConvexHulls, voxelResolution );
920
924
gzdbg << " Optimizing mesh (" << _meshSdf.OptimizationStr () << " ): "
921
925
<< _mesh.Name () << std::endl;
922
926
// Create decomposed mesh and add it to MeshManager
0 commit comments