I have 1 Wall :
wallSd.categoryBits = 1;
wallSd.maskBits = 0xffff;
Another circle with mass 0f 0.5:
sd.categoryBits = 4;
sd.maskBits = 0xffff;
Another circle with mass of 1.5:
b2CircleDef sd;
b2BodyDef bd;
b2Body* body = NULL;
bd.AddShape(&sd);
sd.density = 1.0;
sd.radius = (Random(1.0) * 5 + 85);
sd.categoryBits = 2;
sd.maskBits = 0xffff & ~0x0002; <--****
bd.position.Set(100,100);
body = m_world->CreateBody(&bd);
body->m_mass = 1.5;
It only crashes if the line with **** is in.
Debug says this line is causing it
b2PairManage.cpp
b2Pair* b2PairManager::AddPair(int proxyId1, int proxyId2)
m_freePair = pair->next;//Line 121
Can you provide a complete setup? Is this version 1.4.3?
Thanks!
Visual Studio C++ Express 2005, WindowsXP SP2, Box2D C++ 1.4.3
I notice that now even if I remove those category and mask it is still crashing.
And I discovered that, adding new bodies during simulation will cause a crash.
If I simulate without adding new bodies during simulation is fine.
I also observe that addPairs is new in 1.4.3. seems to be new function 1.4.2 does not have one.
Please provide a complete setup (shapes and bodies) that causes the crash.
4 square as walls
Circle definition - density = 1.0, friction = 0.3, restitution = 0.2, radius = 20
10 Circles - mass 0.5
10 Circles - mass = 0.55
10 Circles - mass = 0.6
Circle definition - density = 1.0, friction = 0.6, restitution = 0.3, radius = (Random(1.0) * 5 + 100)
CreateBody of mass 1.5
Hope that helps
Do you think you can reproduce this in a simple testbed example? That would be a huge help.
Yup, manage to do that. I found out the root cause.
When the body created during simulation reaches between 95 to 100 with masking on. It crashes.
Is there suppose to be a limit to the number of bodies? How many objects can the mask take?
Okay, this crash crops up a lot. You will find many posts about this on the forum. What is happening is that you are creating a bunch of overlapping shapes and this leads a large number of collision pairs being created, O(n*n). The pairs come from a pool and that pool is being emptied. You can change the pool size in b2Settings.h.
Erin, would you be opposed to setting up b2Assert so that it can pass a message to the user (or at least the console) when the crash happens? In Java you can add a string to an assert and it will pop it up when the assert is triggered, usually to explain what went wrong. A lot of "bugs" showing up are actually things the user did wrong, but without some internal knowledge of the engine it can be tricky to figure out what's a real bug and what's just improper use of the engine.
What I've been doing in 2.0 is putting a comment right above the assertion that explains to the user what they did wrong and how to fix it. We'll see if this helps. If not I'll start adding strings to the assertions themselves.