# Convex decomposition

V-REP allows calculating and adding the convex decomposition of specified shapes. Convex shapes perform faster and are more stable that random shapes, in regards to dynamic collision response calculation. They are however not as fast nor as stable as pure shapes!

[Non-convex model (left) and corresponding convex-decomposed model (right)]

You can either add the convex decomposition of selected shapes, or you can morph selected shapes into their convex decomposition equivalent:

• morphing into convex decomp. : [Menu bar --> Edit --> Morph selection into its convex decomposition...]
• Following dialog pops open and allows adjusting the way shapes are decomposed:

[Convex decomposition parameter dialog]

Following parameters are applied for each individual shape:

• Handle compound shape components individually: when checked, then each individual mesh of a compound shape will be handled on its own during decomposition, otherwise the compound shape is considered as a single mesh.
• Max. iterations: the convex decomposition algorithm operates in an approximate way, which means that created shapes might be more or less convex. V-REP uses its own convexivity measure: a shape is considered convex only if all of its vertices lie within the half-volumes defines by all triangular faces, and this with a tolerance of 1.5% of the shape's average bounding box side length. The max. iterations parameter allows to iterate several times over the created meshes if they don't appear as convex enough to V-REP.
• HACD convex decomposition: enable the HACD algorithm.
• Add extra points: specifies whether extra points should be added when computing the concavity.
• Add extra face points: specifies whether faces points should be added when computing the concavity.
• Min. nb of clusters: specifies the minimum number of clusters to be generated
• Max. concavity: specifies the maximum allowed concavity.
• Max. connection distance: specifies the maximum allowed distance to get convex clusters connected.
• Target nb of triangles of decimated mesh: specifies the targeted number of triangles of the decimated mesh.
• Max. nb of vertices / convex hull: specifies the maximum number of vertices for each generated convex hull.
• Small cluster detection threshold (%): specifies the threshold to detect small clusters. The threshold is expressed as a percentage of the total mesh surface.
• V-HACD convex decomposition: enable the V-HACD algorithm.
• PCA enabled: enable/disable normalizing the mesh before applying the convex decomposition.
• Voxel-based: if enabled, then voxel-based approximate convex decomposition is used, otherwise a tetrahedron-based approximate convex decomposition is used.
• Resolution: maximum number of voxels generated during the voxelization stage.
• Depth: maximum number of clipping stages. During each split stage, all the model parts (with a concavity higher than the user defined threshold) are clipped according the best clipping plane.
• Concavity: maximum concavity.
• Plane downsampling: controls the granularity of the search for the best clipping plane.
• Convex hull downsampling: controls the precision of the convex-hull generation process during the clipping plane selection stage.
• Alpha: controls the bias toward clipping along symmetry planes.
• Beta: controls the bias toward clipping along revolution axes.
• Gamma: maximum allowed concavity during the merge stage.
• Max. number of vertices / convex hull: controls the maximum number of triangles per convex-hull.
• Min. volume / convex hull: controls the adaptive sampling of the generated convex-hulls.

• ### Recommended topics

• Related API function
• Convex hull calculation