Page 1 of 1

Physics error (halp!)

Posted: Tue Jul 27, 2010 2:25 pm
by Chief
So i've been working on this game that requires "a lot" of physics bodies (and shapes) and when i hit a particular number (i think 30) i get this popup and love.exe shuts down:

Image

Any ideas on how fix this? (I would like a larger amount of bodies)

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 3:02 pm
by kikito
30 objects seems a very feasible number.

Are all your objects created the same way?

Your problem could be not related with the number of objects created, but with how they are created.

I've seen before a forum post in which box2d complained like this; what happened in that case was that the created objects were either impossible or just too small (a circle with radius 0 or a polygon with an area of less than 3 units, if I remember correctly).

If you have several ways of creating objects, try "deactivating" some of them until you detect the one that makes box2d go puff.

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 3:51 pm
by bartbes
I think it might be that there are too many collisions.

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 3:53 pm
by Chief
bartbes wrote:I think it might be that there are too many collisions.
That might be possible! My bodies are 32x32 blocks stuck together in a grid. That might be the problem, seems I have to make some space between them.

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 6:58 pm
by Chief
Update:

Okey, I've done a new test where I have not made collisions between the bodies ( i am monitoring it with the collision callbacks), but the error keeps coming.

Any other suggestions?

Ps. The program keeps running at the same amount of memory (17 000 kb), so nothing is stealing the memory.

EDIT:
I think i fixed, i basically put the bodies which doesn't do much to "sleep".

Stress test: (white lines = bodies)
Image

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 7:42 pm
by The Burrito
Pairs are something like collisions (from what I understand), theres a limit to how many it will create simultaneously, the pop up error is it reaching the limit. Pairs are created any time 2 objects overlap, so I guess your grid of boxes just makes a lot of them (perfect alignment would probably create 8 for each box in the middle of others), I'm not sure how you plan on using this grid of boxes, but theres a lot of tricks that may make it work better.

Theres a limit to the number of shapes you can have at a given time (I think its in the 150-200 range) but there doesn't seam to be a limit on bodies.

Oh yeah, and usually if you click ignore enough times box2d will work through the errors.

Re: Physics error (halp!)

Posted: Tue Jul 27, 2010 9:15 pm
by Chief
The Burrito wrote: Theres a limit to the number of shapes you can have at a given time
Are you sure about that? In the picture there are 600 shapes and bodies, and didn't even make it laggy

Re: Physics error (halp!)

Posted: Wed Jul 28, 2010 2:02 am
by The Burrito
my mistake, its at around 1200 shapes that I get errors, not 200. (I can math!)

Re: Physics error (halp!)

Posted: Wed Jul 28, 2010 8:31 pm
by Deecodeuh
I've had this problem in Lovely Mario Brothers. It's too many objects colliding in one space.