How to have gContactProcessedCallback called only once?

TheSHEEEP
Posts: 4
Joined: Fri Mar 07, 2014 11:13 am

How to have gContactProcessedCallback called only once?

Post by TheSHEEEP »

Hey,

Here's what I want to do:
Imagine a bunch of crates dropping down on a floor. Whenever a crate collides with another crate or the floor, I want to fire an event (like triggering a sound).

Currently, I registered my own function for gContactProcessedCallback to get a notification when something collides so I can react to this. This works rather well, but the function is called on each collision between two objects. So if the crate slides along the floor, I get numerous notifications along the way. But I only want to get notified when they collide for the first time or with a new object.

So, it currently works like this:
1. Crate A collides with crate B. Event is fired.
2. Crate A collides with crate B again. Event is fired.
3. Crate A collides with floor. Event is fired.
4. Crate A collides with floor. Event is fired.
5. Crate A collides with floor. Event is fired.
6. Crate A collides with floor. Event is fired.
7. Crate A collides with crate B again. Event is fired.
8. Crate A collides with crate B again. Event is fired.

I want it to work like this:
1. Crate A collides with crate B. Event is fired.
2. Crate A collides with crate B again.
3. Crate A collides with floor. Event is fired.
4. Crate A collides with floor.
5. Crate A collides with floor.
6. Crate A collides with floor.
7. Crate A collides with crate B again. Event is fired.
8. Crate A collides with crate B again.

Of course I could keep track of this myself, wouldn't be too hard (just remember the last collision "partner" and fire the event when that changes).
But as this automatically works like expected in PhysX, for example, I thought there may be a way to achieve this by applying some settings or flags to the rigid bodies or the world.