0
\$\begingroup\$

enter image description here

I'm solving simple 3D sphere collisions by checking the sphere for overlap with a mesh, finding the nearest point on that mesh's surface to the center of the sphere, and then resolving the collision by moving the sphere out of the mesh using the normal and the penetration distance.

To find the normal, I'm using the normalized vector from the nearest point on the mesh to the center of the sphere.

Now I'm trying to resolve a collision where the sphere has overlapped more than one collider. How I'm currently solving it is by iterating through all the meshes and checking to see if the last correction solved the collision.

In the scenario shown in the bottom image, this can cause a problem when trying to determine a collision normal. The two collisions return two different normals, as they should (Though, Depending on which collision was resolved first, the correction from the right box would solve the collision with the left box, in which case there would only be one normal).

Now, mathematically, that all makes sense, but visually causes a problem. If I'm trying to determine a single normal to, say, bounce the ball off the surface create by those two meshes, any normal that takes both collision normals into effect would be inaccurate. Visually, one would expect the collision normal to be straight op, but since one of the collision normals is at an angle, I would need to somehow determine that that is a sort of "false" normal.

The solution that comes to mind is to order the collision checks by their distance from the sphere, thereby ensuring that, in that scenario, the angled normal never even comes into play. Is this an accurate way to do this, or would that cause other problems I'm not seeing?

\$\endgroup\$
  • \$\begingroup\$ Your proposed solution sounds like it's worth a try. \$\endgroup\$ – DMGregory Sep 8 '18 at 11:43
  • \$\begingroup\$ In Box2d, there is a class called EdgeShape that you might want to have a look at. It is obviously 2D but it might help. It keeps track of the neighboring edges and it chooses only one normal if a circle collides with more than one edge. github.com/erincatto/Box2D/blob/… \$\endgroup\$ – schteppe Sep 10 '18 at 6:56
  • \$\begingroup\$ What you are looking for has been implemented and presented by Kasper Fauerby in his paper "Improved Collision detection and Response". See here: peroxide.dk/papers/collision/collision.pdf \$\endgroup\$ – Tara Mar 20 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.