🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

2d Physics: Solving for 2 Contact Points

Started by
2 comments, last by SnackerB 6 years, 6 months ago

Hi All,

I have recently been programming a very rudimentary 2d Physics Engine. I implemented SAT to check for Collision between convex polygons, and this gives me one to two contact points.

Collisions between Objects where just one Contact Point is generated get resolved just fine, but if i have 2 Contact Points, The Object begins to shake. For example, if a box falls on the ground due to gravity, it starts tilting to the right and left very fast. I believe the problem is, that on contact an Impulse gets applied to one Contact Point, and the box turns in the other direction. Then in the next step it penetrates the ground in the other Direction and gets an Impule in the other direction, and so on. 

I tried several Methods by now, but nothing seems to fix the problem. Do i have to implement some kind of iterative solver?

How can you solve for 2 Contact Points efficiently? The way I am doing it right now, is to just resolve the Collision for each Contact Point, scaling the Impulse down by the ratio of the penetration depths.

If you know a possible Solution to my problem, or even just a hint in the right direction, please let me know!

Thank you in Advance.

Advertisement

Your solver currently treats each contact point in isolation. Given the first contact point is perfectly solved, the second contact point, once solved, invalidates the solution to the first, thus causing jitter. A very good way to reduce jitter is to implement an iterative solver where the various contact points communicate with one another to somehow converge upon an acceptable solution altogether.

My personal favorite resource for learning one good solution is under GDC 2006 here: http://box2d.org/downloads/. Specifically this link to the powerpoint and this link to the demo code.

Thanks, not only for the answer, but also for the Great Tutorial you've made on how to program a Physics Engine. Without it, it wouldve taken me much longer to even get here. Keep up the good work!

Ill try to implement this Arbiter mechanic from the Demo. If i have any more Questions, ill ask them here.

This topic is closed to new replies.

Advertisement