pmndrs / p2-es

JavaScript 2D physics library
https://p2-es.pmnd.rs
Other
123 stars 11 forks source link

Collision between Circle and Box can be missed #139

Open mqnc opened 9 months ago

mqnc commented 9 months ago

I just reported the issue here: https://github.com/schteppe/p2.js/issues/372 Then I found that the repo is no longer maintained so I looked for forks and found this one. However, I noticed that the problem is still there. Here is a sketch:

image

In the depicted case, the collision is missed. For each edge of the convex shape (box), the engine looks for the point on the circle that is furthest in the direction which is normal to the edge and checks whether it is inside the convex. This is not the case for any edge in the depicted scenario. It will successfully detect the collision if the circle slowly moves into the box but if the circle passes through the back wall of the box in one step, the collision will be missed.