Rejecting contacts in collision handlers
Posted: Mon Oct 15, 2012 4:18 am
Hi,
Is there a way to reject a contact after it has been created, but before it has an impact on the scene? I would like to be able to have a contact's info be created and then run some logic that might decide to throw away (ignore) the contact. When this happens, two bodies would pass right through each other.
I've tried calling ClearContacts() on the CollidablePairHandler inside the DetectingInitialCollision event. That works for non-compound collisions, but for a compound collision, there is a "leak" in the call "this.Parent.AddSolverUpdatable(...)" inside StandardPairHandler::UpdateCollision(). RemoveSolverUpdatable() does not get called and so an exception is thrown on the next update because the updatable is still attached to the parent solver.
I also tried calling ClearContacts() inside the CreatingContact event. This works, but causes an out of bounds exception during the call to this.Remove(0) inside SphereContactManifold::Update() because the contact was removed but the manifold is tracking it as if it were added.
Is there a better way to go about this? Alternatively, is there a way to just listen to when contacts would be created, but not have them created at all?
Thanks.
Is there a way to reject a contact after it has been created, but before it has an impact on the scene? I would like to be able to have a contact's info be created and then run some logic that might decide to throw away (ignore) the contact. When this happens, two bodies would pass right through each other.
I've tried calling ClearContacts() on the CollidablePairHandler inside the DetectingInitialCollision event. That works for non-compound collisions, but for a compound collision, there is a "leak" in the call "this.Parent.AddSolverUpdatable(...)" inside StandardPairHandler::UpdateCollision(). RemoveSolverUpdatable() does not get called and so an exception is thrown on the next update because the updatable is still attached to the parent solver.
I also tried calling ClearContacts() inside the CreatingContact event. This works, but causes an out of bounds exception during the call to this.Remove(0) inside SphereContactManifold::Update() because the contact was removed but the manifold is tracking it as if it were added.
Is there a better way to go about this? Alternatively, is there a way to just listen to when contacts would be created, but not have them created at all?
Thanks.