Box2D Demo & Tutorial

LonelyStar
Posts: 6
Joined: Sun Nov 26, 2006 2:56 pm

Post by LonelyStar »

Ok, that makes sense.

I have another question:

The accumulated normal impulse is clamped, not the normal impulse calculated in every iteration, correct?

I wondering about the following scenario:
A Box (A) is colliding head on with another Box (B) in free space.
Both boxes have a elasticity of 1.0:

A-> <-B

Collision is detected -> an Arbiter is created.
In The first iterarion, impulse is calculated and applied, the scene should now look like this:

<-A B->

(Which is already the correct outcome).
But now the second iteration comes.
The calculated impulse is negative! But since the accumulated impulse at this point should be zero, the impulse is not clamped.

The result is obvious wrong!

Thanks for clearing things up!
Nathan
stbuzer
Posts: 23
Joined: Fri Dec 08, 2006 10:16 am

Post by stbuzer »

The accumulated impulse is clamped to result in positive value, since collisions are inequality constraints. The original code from Box2D demo handles only cases with restitution=0.
BioSlayer
Posts: 5
Joined: Sat Dec 10, 2005 2:51 am

Post by BioSlayer »

Hi I?ve recently rewrote my physics engine called Physics 2D the newer version is called Physics2D.Net and it is completely written in C#.
The reason I?m posting about this in this thread is that it uses the Algorithms from Box2D. You can download a 2 day old version on SF.Net.


And I had a problem with making a large pyramid like the one in the demo, with the version that splits the impulses The problem was that if I added too many block the pyramid the blocks on the bottom and middle would start shaking very rapidly and the whole thing would start sliding and shifting. I realized this problem was do to the high bias factor but didn?t want to lower it for non-stacking objects. So this is how I solved the problem: during collision detection I have each Body count how many other bodies it is colliding with. Then during the prestep part I calculate a biasMultiplier:

float biasMultiplier = 1/Pow(Min(b1.CollisionCount, b2.CollisionCount),2);

And multiply it against bias for each contact in the arbiter.

This works rather well. The pyramid is a lot more stable.
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

was this using Baumgarte or split-impulses for penetration correction?
BioSlayer
Posts: 5
Joined: Sat Dec 10, 2005 2:51 am

Post by BioSlayer »

This is using Erin Cattos algorithm which I thought was called sequential impulses not split impulses.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Post by bone »

BioSlayer wrote:This is using Erin Cattos algorithm which I thought was called sequential impulses not split impulses.
To be honest, I've been getting confused between the definitions of these, too.
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Post by raigan2 »

sequential impulses are used to iteratively build the solution, but in a recent update he added "split-impulses", which separates position and velocity correction.
BioSlayer
Posts: 5
Joined: Sat Dec 10, 2005 2:51 am

Post by BioSlayer »

Well the code that?s on sourceforge uses the original version of sequential impulses. But I also have been working implementing his newer version (split impulses) and that is what this fix is for. Right now I have the split and non split versions of the Erin Catto?s solver algorithm. My engine supports more then one solver.
BioSlayer
Posts: 5
Joined: Sat Dec 10, 2005 2:51 am

Post by BioSlayer »

I have released a new version with split impulses.
and my project has moved to google code.

http://physics2d.googlepages.com/
Post Reply