COACD provides a Python interface for Approximate Convex Decomposition (ACD) of 3D meshes, using collision-aware concavity and a tree search algorithm. It's particularly useful for preparing complex geometries for physics simulations or collision detection by breaking them down into simpler convex hulls. The current version is 1.0.10, and releases are typically driven by updates to the underlying C++ library or improvements in the decomposition algorithms.
pip install coacdVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a simple 3D mesh using `trimesh` and then decompose it into convex parts using `coacd.run_coacd`. The output `parts` is a list where each element is a tuple containing the vertices and faces of a single convex component. The `resolution` parameter is crucial for balancing speed and accuracy.
Ensure you have a C++ compiler and build tools installed (e.g., `build-essential` on Debian/Ubuntu, Xcode Command Line Tools on macOS, Visual C++ Build Tools on Windows). If issues persist, refer to the COACD GitHub repository for specific build instructions or pre-compiled binaries.
Always convert your mesh data to `numpy.ndarray` before passing it to `coacd.run_coacd`. If using libraries like `trimesh`, you can directly access `mesh.vertices` and `mesh.faces` which are already NumPy arrays.
Start with a lower `resolution` (e.g., 32 or 64) for initial tests and simpler meshes. Gradually increase it if higher detail is required. Monitor memory and CPU usage. For very large meshes, consider pre-processing steps like mesh decimation or simplifying the input before decomposition.