[Feature]: Similar mesh files are not detected by convex decomposition caching
What feature or enhancement are you proposing?
Hello,
- I've noticed a performance drop and unnecessary mesh decomposition recalculation during setup.
[2025-06-30 17:08:45.460] [CoACD] [info] threshold 0.1
[2025-06-30 17:08:45.460] [CoACD] [info] max # convex hull -1
[2025-06-30 17:08:45.460] [CoACD] [info] preprocess mode auto
[2025-06-30 17:08:45.460] [CoACD] [info] preprocess resolution 30
[2025-06-30 17:08:45.460] [CoACD] [info] pca false
[2025-06-30 17:08:45.460] [CoACD] [info] mcts max depth 3
[2025-06-30 17:08:45.460] [CoACD] [info] mcts nodes 20
[2025-06-30 17:08:45.460] [CoACD] [info] mcts iterations 100
[2025-06-30 17:08:45.460] [CoACD] [info] merge true
[2025-06-30 17:08:45.460] [CoACD] [info] decimate false
[2025-06-30 17:08:45.460] [CoACD] [info] max_ch_vertex 256
[2025-06-30 17:08:45.460] [CoACD] [info] extrude false
[2025-06-30 17:08:45.460] [CoACD] [info] extrude margin 0.1
[2025-06-30 17:08:45.460] [CoACD] [info] approximate mode ch
[2025-06-30 17:08:45.460] [CoACD] [info] seed 0
[2025-06-30 17:08:45.468] [CoACD] [info] - Manifold Check
[2025-06-30 17:08:45.537] [CoACD] [info] Unclosed mesh
[2025-06-30 17:08:45.537] [CoACD] [info] Manifold Check Time: 0.070015s
[2025-06-30 17:08:45.588] [CoACD] [info] Mesh Manifoldness: false
[2025-06-30 17:08:45.589] [CoACD] [info] - Preprocess
[2025-06-30 17:08:45.589] [CoACD] [info] Preprocess resolution: 30
[2025-06-30 17:08:45.739] [CoACD] [info] Preprocess Time: 2.721761s
[2025-06-30 17:08:45.740] [CoACD] [info] # Points: 10102
[2025-06-30 17:08:45.740] [CoACD] [info] # Triangles: 20200
[2025-06-30 17:08:45.740] [CoACD] [info] - Decomposition (MCTS)
[2025-06-30 17:08:45.740] [CoACD] [info] iter 0 ---- waiting pool: 1
[2025-06-30 17:08:45.742] [CoACD] [info] Processing [0.0%]
[2025-06-30 17:08:52.360] [CoACD] [info] Processing [100.0%]
[2025-06-30 17:08:52.360] [CoACD] [info] iter 1 ---- waiting pool: 2
... (after 10 commands)
[2025-06-30 17:09:07.600] [CoACD] [info] Processing [100.0%]
[2025-06-30 17:09:07.601] [CoACD] [info] - Merge Convex Hulls
[2025-06-30 17:09:08.248] [CoACD] [info] Compute Time: 22.508172111120075s
22.5 seconds added to each run of my application.
Long story short, I've found that I've reexported the exact same meshes from my CAD application. The meshes are exactly similar every time, however decomposition was still triggered.
I know that the exported CAD models (and their meshes) meshes would have a tiny floating point error (1e-8 or less), so even though they were reasonably equal, decomposition was still triggered
Could it be that mesh cache hit/miss algorithms does not check for floating point errors? I know that there are exactly equally many triangles and points (20.2k and 10.1k respectively) in each mesh.
(Note: this is a significant narrow down of the original issue - the issue above was found to be the core problem)
Convex decomposition is already cached on main branch. If it does not work on your side, please let me know and I will reopen this issue. Closing for now.
Hello, Probably works, but. Something that I've found in my code is that mesh existence (file exists or not) failed, and I actually reexported my mesh every time. So genesis was receiving a new file on every run.
Still. The recompilation should not happen in this case, since meshes are equal and are non-random - reexporting them yields an exactly equal file every time, except the floating point errors caused by my CAD/mesher. Does your code not check for floating point errors perhaps?
Similar meshes should not be recompiled.
This makes more sense now. Could you update your Pr title and description accordingly?
Done. Though, I don't know if it is worth fixing - it's a bug most people will never ever run into, and if they do, it's their problem.
Still, let’s keep track of it.