Skip to main content
GameDev.net gamedev.net
🔒 Locked

Stacking objects

Started by jag_oes Mar 5, 2002 at 11:49 PM 3 replies 1.1k views
Original Post
jag_oes
jag_oes
I am trying to create a 2d physics engine mainly dealing with simulating rigid bodies. Everything seems to work fine except for when objects stack up on each other. In my simulations the top object always seems to "sink" inside the other. Or worse, when an object is sliding down another, one of its vertices will slip inside the structure of the other body, thus haulting the entire simulation. I know this is a really general question, and you dont even know anything about the structure of my engine, but do any of you have some general methods of fixing this that I can try out? The demos that Chris Hecker made for his articles on rigid body dynamics dont have the problem but I cant really see why his works and mine doesnt. I would be happy if mine would handle like his (even with the crazy jumpiness of the objects when they are resting on the floor). Thanks
Timkin
Timkin
This affect is probably being caused by numerical instability in your computational scheme. What integration method are you using? If you are not already using one, might I suggest you implement a predictor-corrector scheme?

Cheers,

Timkin
jag_oes
jag_oes
Actually, the engine already employs three different integrators: Euler, Midpoint, and a 4th order Runge Kutta method. However, you were pretty much right ... I was only testing with the Euler integrator and I was taking a much larger time step than I thought. Thanks.

But, I have another question for you or anyone else you knows. I''m using the impulse model for collisions shown in Chris Hecker''s articles and I have a question about the resitution value in the equations. What if the two bodies that are colliding have different coeffecients of restitution? What value do you plug into the equation, or what new value do you derive from the bodies'' restitutions to plug into the equation?

Thanks.
grhodes_at_work
grhodes_at_work
Are you using a penalty method to deal with contact forces? If so, then you should just through your simpler Euler integrator out the window. It is unstable for situations where you have forces that are a function of a displacement, such as interpenetration distance. Smaller time steps can delay the problem, but unless you explicitly stop the integration before things get out-of-hand, they will get out-of-hand.

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
Persian_Gamer
Persian_Gamer
very simple ya caculate the average of the 2 coef of restitutions and plug it into the function to get the impulse

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.