I'm new to Bullet Physics and I'm planning to use the Java JBullet port in one of my applications.
I'd like to know if there is a way to receive a notification when a collision happens, so that I may perform a custom action instead of having Bullet apply it's physics calculations. For example, I want to know when a RigidBody of my custom type "Balloon" collides with a RigidBody of the type "Needle" so that instead of having Bullet bounce these objects off another, I can make the "Baloon" disappear.
I'm thinking about something like this (pseudocode):
Code: Select all
CollisionObserver myObserver = new CustomCollisionObserver();
dynamicsWorld.addCollisionObserver(myObserver)
interface CollisionObserver {
// return true if Bullet should perform its collision calculations, otherwise false
boolean collision(RigidBody collider1, RigidBody collider2);
}
class CustomCollisionObserver implements CollisionObserver{
boolean collision(RigidBody collider1, RigidBody collider2){
... [perform custom collision action]...
// tell Bullet not to perform any collision actions
return false;
}
}
So for some RigidBodies, I'm only interested in when they collide and not in the physics calculations resulting from that collision.
Is there any way to perform this in Bullet?