It has been an hardcore saturday evening: i’ve struggled with Bullet for 3 hours, and, finally, i’m able to get all bullet events in my code, without having to “manually” asking to each object “are you touching somebody?”.

It’s a bit weird, but to achieve this you have to plug a static method on the C callbacks of Bullet, called ContactAddedCallback, ContactProcessedCallback and ContactDestroyedCallback.

To avoid ever doing this again, PBullet class has now 3 static methods to set these 3 callbacks,

  • static void setContactAddedCallback( ContactAddedCallback callbackFunction);
  • static void setContactProcessedCallback( ContactProcessedCallback callbackFunction);
  • static void setContactDestroyedCallback( ContactDestroyedCallback callbackFunction);

In your class, you declare one method like this (.h):

static bool myContactProcessedCallback(
btManifoldPoint& cp,
void* body0, void* body1) {
std::cout << “myContactProcessedCallback: ” << body0 << ” <> ” << body1 << std::endl;

You link it to PBullet like this (easy):

PBullet::setContactProcessedCallback( myContactProcessedCallback );

And it works! Result is absolutely NOT visual…

The bullet documentation is a bit too subtle for me, I lost a lot of time to implement a ContactResultCallback before understanding that this is a one timer, the link between objects and the callback is lost at the next update…

For the braves and the curious, here is the urls i’ve used to complete this: