Salut, I’m currently working on a pool game in flash, using box2d for physics simulations and i’m stuck with collision filtering.
What i try to do is to change the colision mask bit of a ball when it enter a pocket, so that it won’t collide the other balls (I don’t want to delete the physic object because I need to do some effect before).
The collision mask bit seems changed well, but it doesn’t take effect immediatly ans the pocketed ball still colide some time before getting fully uncolisionable.
I don’t know why, is it really possible to change the mask bit at run time?
thank you.
When two fixtures become near each other (specifically, when their AABBs begin to overlap) a b2Contact is created to managed the interaction between them. The relevant data for the collision (friction, restitution etc) is copied into this b2Contact and it persists until the AABBs have stopped overlapping. This is done for efficiency but a side effect is that as long as the two AABBs remain overlapping the collision mask bits are not checked anymore.
One way you could work around this is to manually cancel the default collision response by calling contact->SetEnabled(false) in the PreSolve callback for any collisions with the pocketed ball. This would need to be done every time you got a PreSolve call.