Comparing Box2D and 'Rigid bodies with stacking'

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
oztune
Posts: 24
Joined: Tue Aug 21, 2007 12:13 am

Comparing Box2D and 'Rigid bodies with stacking'

Post by oztune »

Hey

Right now I'm at the point where I'm trying to completely understand how Box2D (and impulse based methods in general) works, and had a few questions. Any help will be appreciated

So I just finished going through 'nonconvex rigid bodies with stacking', and (I believe) I understand how the method described there works. What would really help me is to understand how that method is different from erin's, and what advantages/disadvantages it has.

To be a bit more specific:
From what I got, it looks like Guendelman uses corrective impulses to separate the velocities and account for friction and reinstitution (ie, the collision phase). Then he applies impulses with no reinstitution to fix the penetrating contacts... (please correct me if I'm wrong)

So is the second phase (contacts) similar to erin's position correction phase? How are they different?
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine
Contact:

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by Erin Catto »

I haven't implemented the NCRBWS algorithm, but my understanding is that they have no position correction.

Box2D combines collision and contact by using a velocity bias for restitution. Box2D also does not use shock propagation. Finally, Box2D clamps the accumulated impulse, which NCRBWS does not.
oztune
Posts: 24
Joined: Tue Aug 21, 2007 12:13 am

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by oztune »

Thanks for the reply Erin. few more questions, if you don't mind
Erin Catto wrote:I haven't implemented the NCRBWS algorithm, but my understanding is that they have no position correction.
How do they battle position drift then? If you happen to know..
How can it be done without some sort of stabilization/projection ?
Erin Catto wrote:Box2D combines collision and contact by using a velocity bias for restitution
Is that what's described by the split impulses method? From what I've read here it sounded like you gave up on that method and decided to go with a separate position correction sweep after velocity correction.. or am I totally off?
Erin Catto wrote:Box2D also does not use shock propagation
Do you think box2d could benefit from shock propagation? It's something I was thinking about implementing at some point, and was wondering why I haven't seen it used that much.
Erin Catto wrote:Box2D clamps the accumulated impulse, which NCRBWS does not.
So clamping the accumulated impulse makes sure that it's never negative, therefore satisfying the inequality constraint... is that about right?

Thanks for the help
Oz
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine
Contact:

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by Erin Catto »

oztune wrote:How do they battle position drift then? If you happen to know..
How can it be done without some sort of stabilization/projection ?
You can run without position stabilization, you will just get a little penetration. The amount of penetrations depends on the time step and the number of iterations in the velocity solver.
oztune wrote:Is that what's described by the split impulses method? From what I've read here it sounded like you gave up on that method and decided to go with a separate position correction sweep after velocity correction.. or am I totally off?
No restitution handling is independent of split impulses. Split impulses was an attempt to reduce the influence of Baumgarte style position correction on the momentum. With Baumgarte position correction you can get some bounce even when the restitution is zero. I did abandon split impulses in favor of a separate post projection of position errors.
oztune wrote:Do you think box2d could benefit from shock propagation? It's something I was thinking about implementing at some point, and was wondering why I haven't seen it used that much.
I tried shock propagation before and abandoned it because the results were often physically and visually incorrect. For example, this configuration is stable with SP:
Image
oztune wrote:So clamping the accumulated impulse makes sure that it's never negative, therefore satisfying the inequality constraint... is that about right?
By clamping the accumulated impulse you allow individual corrective impulses in the solver loop to become negative. This allows us to reduce overly large impulses down to the correct level. The accumulated impulse remains positive.
oztune
Posts: 24
Joined: Tue Aug 21, 2007 12:13 am

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by oztune »

Thanks for all your responses Erin. I feel closer to being a physics master with every post :)
(Sorry for all the long questions...)
Erin Catto wrote:You can run without position stabilization, you will just get a little penetration. The amount of penetrations depends on the time step and the number of iterations in the velocity solver.
So just solving all the velocity constraints enough times 'should' resolve all penetration..
Erin Catto wrote:No restitution handling is independent of split impulses.
I see.. I guess I over simplified things a bit. What then is the real difference between collision and contact solving? and where does reinstitution handling come in?
Erin Catto wrote:Split impulses was an attempt to reduce the influence of Baumgarte style position correction on the momentum. With Baumgarte position correction you can get some bounce even when the restitution is zero. I did abandon split impulses in favor of a separate post projection of position errors.
So you still use Baumgarte stabilization then? I'm actually having trouble grasping exactly what it does... I've looked for Baugarte's paper but I can't find more than it's citations (unpaid at least). Plus, the mathematical terms tend to over complicate things in my mind...
Erin Catto wrote:I tried shock propagation before and abandoned it because the results were often physically and visually incorrect. For example, this configuration is stable with SP:
Image
NCRBWS presents a technique which performs several regular iterations on stacks, followed by shock propegation.. wouldn't that make things a lot more stable, while keeping realistic behavior?
Erin Catto wrote:By clamping the accumulated impulse you allow individual corrective impulses in the solver loop to become negative. This allows us to reduce overly large impulses down to the correct level. The accumulated impulse remains positive.
Ok. Why would you encounter those overly large impulses in the first place? Do you know of any visual example of this?

Thank you,
Oz
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine
Contact:

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by Erin Catto »

oztune wrote:So just solving all the velocity constraints enough times 'should' resolve all penetration..
No, but it helps to prevent the penetrations from becoming larger.
oztune wrote:I see.. I guess I over simplified things a bit. What then is the real difference between collision and contact solving? and where does reinstitution handling come in?
In Box2D there is no difference between collision and contact solving except that restitution is handled with a velocity bias. Please see my 2008 presentation: http://www.gphysics.com/downloads.
oztune wrote:So you still use Baumgarte stabilization then? I'm actually having trouble grasping exactly what it does... I've looked for Baugarte's paper but I can't find more than it's citations (unpaid at least). Plus, the mathematical terms tend to over complicate things in my mind...
See the '08 presentation.
oztune wrote:NCRBWS presents a technique which performs several regular iterations on stacks, followed by shock propegation.. wouldn't that make things a lot more stable, while keeping realistic behavior?
Yet it still produces the artifact I showed. I encourage you to try it yourself.
oztune wrote:Ok. Why would you encounter those overly large impulses in the first place? Do you know of any visual example of this?
This happens because the solver is iterative. Constraints are not directly aware of each other and may over compensate. Again, I encourage you to experiment with your own code or Box2D_Lite. You can easily disable accumulated impulse clamping.
oztune
Posts: 24
Joined: Tue Aug 21, 2007 12:13 am

Re: Comparing Box2D and 'Rigid bodies with stacking'

Post by oztune »

I will go over those slides again. Thanks for all the help, I really appreciate it!
Post Reply