Crash on Polygon Shapes Testbed

Hi,

Firstly, I have to say that this is something the indie industry has needed for a looooong time. Three thumbs up, Erin.

Okay bug time, I haven't started implementing b2D into my project, but I will be soon, but I have found a crash in the TestBed.exe.

If you go into the Polygon Shapes demo and spawn a whole lot of triangles then start knocking them off the ground box eventually the software crashes, I haven't explored the software in depth yet, but my first guess would be that some sort of world limit is being hit, or something.

I hope that this helps b2D kick ass more than it already does.
Thanks for the bug report.

I reproduced this crash so it should be an easy fix. It seems to be a problem when a bunch of objects go outside the world boundary and too many collision pairs are created. I think I'll just freeze bodies that reach the border.
It's the least I could do 😀

Thanks for the prompt reply Erin 🙂
Hi,

Of course I love Box2D, and I hope the tiny glitch I've noticed can help it towards perfection.

I wanted to see when things slowed down, so I first changed the 'k_maxBodies' variable from 256 to 2048 (in PolyShapes.h).

I then held in the number 4, creating lots of boxes. When there were about 512 boxes, newly created ones fall like ghosts - through the pile and the floor.

Is this a bug? Or should I change another variable?

Thanks,
Paul
Paul,

I use a fixed size pool for collision pairs. So what happens is that with a very large number of objects, the collision code runs out of collision pairs and ignores the collisions. You can find settings for this in b2Settings.h.

Thanks for the note. I'll try to come up with a less error prone system for dealing with large numbers of objects.
Thanks Erin, that's exactly what I was looking for.
Erin Catto wrote:
Thanks for the bug report.

I reproduced this crash so it should be an easy fix. It seems to be a problem when a bunch of objects go outside the world boundary and too many collision pairs are created. I think I'll just freeze bodies that reach the border.


I did this in my demoes, but it still crashes sometimes... what I did was to randomize the x position of the frozen objects and I've never seen a crash since. I've just updated to the latest code and will check if this still happens (I have a test case that definitely crashes).
FYI, the current fix doesn't freeze bodies. Bodies that cross the border don't receive new collisions.

I'm still undecided on the best approach for this.

I should probably freeze the body, stop adding new collisions, and notify the client. I should notify the client at a point where it is safe for them to destroy the body.

Original thread: https://box2d.org/forum/viewtopic.php?t=14