NcStudios / NcEngine

NcEngine: 3D game engine written in modern C++ and Vulkan
https://ncstudios.itch.io/
MIT License
36 stars 2 forks source link

Fix projection failure for curved objects #631

Closed McCallisterRomer closed 2 months ago

McCallisterRomer commented 2 months ago

resolves #613

Fixing occasional nan/divide by 0 issue when finding contact points for sphere and capsules. The issue comes up when when epa generates a tiny triangle and we try to project somewhere on it. Since the vertices are so close, it doesn't visually matter which point we choose, we just have to pick something so we don't divide by 0. In the future, we could look into adding more special case handling for collision/contact generation to avoid numerical instability issues like this. Its probably a bit overkill to use epa for sphere vs triangle list, etc.