I'm having some weirdness with the b2ContactListener, but it is likely that I just don't understand what is supposed to be happening. So let me describe what is happening:
I have a class, CContactManager, which inherits from b2ContactListener and an instance of this class gets set as the listener, mWorld->SetListener(gContactManager). My level is fairly complicated with some thing near 80 to 100 shapes being created just for the level. I have one dynamic body in the world, the character, and it is simply a box and I have the character assigned to the userdata of the body.
In CContactManager::Add(...) I am getting the bodies from the shapes and checking to see if the user data is my character, when it is I am doing some game logic. Similarly for Remove(...). The issue is that I get say 4 or 5 calls to Add in one frame causing my game logic to be called 4 or 5 times. Thing is, I don't see a way to identify the b2ContactPoints, so I'm not sure if I'm getting 4 or 5 different points or 4 or 5 calls with the same point. I've tried point->id.key, but in this case I do end up with 4 or 5 with the same 'keys'. And then in the Remove call I never see the key(s) that I see from Add, for example in Add I print out the key and its '16843009' which gets printed 4 or 5 times. The key that gets printed in remove is '3435973836' which gets printed 4 or 5 times as well.
So is this expected behavior, or have I misunderstood something somewhere?
I have a class, CContactManager, which inherits from b2ContactListener and an instance of this class gets set as the listener, mWorld->SetListener(gContactManager). My level is fairly complicated with some thing near 80 to 100 shapes being created just for the level. I have one dynamic body in the world, the character, and it is simply a box and I have the character assigned to the userdata of the body.
In CContactManager::Add(...) I am getting the bodies from the shapes and checking to see if the user data is my character, when it is I am doing some game logic. Similarly for Remove(...). The issue is that I get say 4 or 5 calls to Add in one frame causing my game logic to be called 4 or 5 times. Thing is, I don't see a way to identify the b2ContactPoints, so I'm not sure if I'm getting 4 or 5 different points or 4 or 5 calls with the same point. I've tried point->id.key, but in this case I do end up with 4 or 5 with the same 'keys'. And then in the Remove call I never see the key(s) that I see from Add, for example in Add I print out the key and its '16843009' which gets printed 4 or 5 times. The key that gets printed in remove is '3435973836' which gets printed 4 or 5 times as well.
So is this expected behavior, or have I misunderstood something somewhere?