Jump to content
  • Advertisement
SnackerB

2d Physics: Solving for 2 Contact Points

Recommended Posts

Posted (edited)

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.

Edited by SnackerB

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!