I am currently looping through all the Persistent Manifolds from the dispatcher. I know I could use btGhostObject, but I'm actually am looking for all collisions so that I can call per object onContact functions, and then the object can handle the collision as the programmer sees fit.
I want to also have an onInitialContact() function that gets called once and only once per collision. This would be mostly useful for sound playback. If a ball hits the floor, play a "dink" sound. But in my current implementation that sound is fired off every frame, cause the ball may hit the floor and the start rolling on it.
I know that manifolds are persistent. Thus the manifold will still be in the list even after the objects separate. I resolved this problem by simply testing if there are any contact points.
Code: Select all
//psuedo code
for(all manifolds in dispatcher)
{
if(initial collision) //this is what i need help with defining
{
objA->getUserPointer()->onInitialContact(objB);
objB->getUserPointer()->onInitialContact(objA);
}
if(manifold->getNumContactPoints() > 0)
{
objA->getUserPointer()->onContact(objB);
objB->getUserPointer()->onContact(objA);
}
}
~GameQ