Limit on number of bodies in the world?

Hi,

I'm using Box2D for a game we're developing. I'm trying to add bullets to the world, such that each character has a certain number of bullets. I'm getting an error when the number crosses a limit, as shown in the file attached.

Attachment:
Error.jpg
Error.jpg [ 97.15 KiB | Viewed 212 times ]


I read another post on the forum which suggested changing b2_maxProxies in b2Settings.h from 512 to a higher value. I did that and I'm still getting the same error. The number shown changes every time too. In the attachment, it's 373 but I've also seen 446, 449 and 442.

Could someone please tell me what the problem might be? Could it be the way I'm setting the position of the bullets? I'm doing it like this:

b2Vec2 aiPosition = aiCharacters[i]->body->GetPosition();
aiCharacters[i]->projectiles[j]->bodyDef.position.Set(aiPosition.x, aiPosition.y);

The aiCharacters are in random positions in my world (within world boundaries, though).

Any help would be much appreciated.
maxproxies and maxpairs are different. Boris recently told me that one proxy = one shape. one pair = one pair of fixtures overlapping aabbs. So if you have many objects overlapping many other objects, you could have a very high number of pairs( up to n^2)

either raise the number of max pairs in the settings file or find another way to limit the number of colliding objects.( filters for items that shouldn't collide, limit number or objects, spread them out more, etc )
Thanks a lot. I did a bit of both things you suggested. Limited the number of colliding bodies and changed the settings. Worked now.

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