zeux / meshoptimizer

Mesh optimization library that makes meshes smaller and faster to render
MIT License
5.73k stars 496 forks source link

Verify the triangles are not intersecting each others when simplifying #655

Closed Makio64 closed 6 days ago

Makio64 commented 9 months ago

It would improve a lot the quality if the triangles dont intersect each others :

Here an exemple before / after simplifying where the triangles intersect each other making bad result : image

image

Using this model from sketchfab, all credit to his author : https://sketchfab.com/3d-models/wakfu-fanart-female-iop-854b37afca0c44c9a0302b879a95bfca

zeux commented 8 months ago

This request makes sense but this is fairly unlikely to happen. The simplification reasoning process is local so the simplifier is not aware of the rest of the mesh - it's only making decisions with the knowledge of immediate vertex/triangle neighborhood. I'll keep this open for now, maybe it could be viable to explore at some point as an option; it would make simplification dramatically more expensive and more involved from the robustness perspective.

zeux commented 6 days ago

I'm going to close this for now; as noted above, it's very unlikely this will happen. Many meshes in practice have self intersecting geometry, so this would substantially constrain the simplification process as existing portions of the mesh will be locked. For meshes that don't have issues like this, the intersection check is very computationally intensive - all changed triangles need to be intersected against the original mesh, an acceleration structure needs to be updated throughout the collapse process, and there's a lot of numerical concerns. So this is just not on the roadmap in the foreseeable future.

If this ever changes I'll reopen the issue.