rti
09-08-2007 00:59:30
Hello.
I wondered whether OgreBullet provides a way to inform user defined code about collision events. I read a bit in the OgreBullet source, but i did not find anything about that.
To implement such a thing i would now add some code in void CollisionsWorld::discreteCollide() and inform every body about every contact with some contact parameters (like the collision partner, position, penetration, etc.).
How would you do it?
I thought about adding a method like collisionEvent(CollisionDetails& infos) to OgreBulletCollisions::Object and call this method from void CollisionsWorld::discreteCollide(). To get this working, btCollisionObject::setUserPointer() should be called in the OgreBulletCollisions::Object constructor to be able to resolve the OgreBullet object again when detecting collisions in Bullet.
Alternative would be to add a CollisionHandler Object to OgreBulletCollisions::Object. If it is not 0, call the appropriate event method on the handler. (This eliminates the need of inheriting OgreBulletCollisions::Object to add custom collision code, just plug in the handler).
Hmm, while writing i already like the second more. How would you do it?
Greeting, rTi
I wondered whether OgreBullet provides a way to inform user defined code about collision events. I read a bit in the OgreBullet source, but i did not find anything about that.
To implement such a thing i would now add some code in void CollisionsWorld::discreteCollide() and inform every body about every contact with some contact parameters (like the collision partner, position, penetration, etc.).
How would you do it?
I thought about adding a method like collisionEvent(CollisionDetails& infos) to OgreBulletCollisions::Object and call this method from void CollisionsWorld::discreteCollide(). To get this working, btCollisionObject::setUserPointer() should be called in the OgreBulletCollisions::Object constructor to be able to resolve the OgreBullet object again when detecting collisions in Bullet.
Alternative would be to add a CollisionHandler Object to OgreBulletCollisions::Object. If it is not 0, call the appropriate event method on the handler. (This eliminates the need of inheriting OgreBulletCollisions::Object to add custom collision code, just plug in the handler).
Hmm, while writing i already like the second more. How would you do it?
Greeting, rTi