G'day,
Just curious as to the proper method of putting a callback for knowing when objects collide. For example, a bullet will do damage to a person, but not really much to a wall. For the moment, I'm checking all manifolds from a collision dispatcher, and if there are contact points, using the user data pointer to point to my own data.
Just curious as to if there is a better method of doing this? Or am I going the right way about it?
Thanks for you time!
collision callback
-
- Posts: 13
- Joined: Wed Jun 07, 2006 12:55 pm
Well, ideally you only want to have to process a collision you're actually interested in. Generally it'd be nice to only receive a callback when the collision classes of two colliding objects have a callback collision response defined.
An additional callback I'd be very interested in is an "object leaves world" callback. No matter how accurate the simulation, in game reality objects do occasionally leave the expected environment and then generally tend to fall forever, until they reach the end of the defined three dimensional space (at which point they might wrap around) or until the simulation crashes.
An additional callback I'd be very interested in is an "object leaves world" callback. No matter how accurate the simulation, in game reality objects do occasionally leave the expected environment and then generally tend to fall forever, until they reach the end of the defined three dimensional space (at which point they might wrap around) or until the simulation crashes.
-
- Posts: 7
- Joined: Tue Sep 19, 2006 3:14 am
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
How do you plan to use this exactly?
The easiest option is to just traverse all contact points after the simulation step finishes. See Demos/CollisionInterfaceDemo for this. This is what the addTouchCallback did.
Another option is using the new collision nearCallback. This is called for every overlapping pair, before the actual nearphase collision detection. You have the option to register your own nearCallback with the collision dispatcher.
See Demos/CcdPhysicsDemo, and make sure USE_CUSTOM_NEAR_CALLBACK is defined at the top, see
You can override this method in btManifoldResult (but still call the base implementation if needed):
Does this help, or do you prefer the old style touchCallback?
Erwin
The easiest option is to just traverse all contact points after the simulation step finishes. See Demos/CollisionInterfaceDemo for this. This is what the addTouchCallback did.
Another option is using the new collision nearCallback. This is called for every overlapping pair, before the actual nearphase collision detection. You have the option to register your own nearCallback with the collision dispatcher.
See Demos/CcdPhysicsDemo, and make sure USE_CUSTOM_NEAR_CALLBACK is defined at the top, see
Code: Select all
//implement your own version of the near callback:
void customNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, btDispatcherInfo& dispatchInfo);
//and register it to the dispatcher:
dispatcher->setNearCallback(customNearCallback);
One option is to check for contact points in the
Code: Select all
virtual void addContactPoint(const btVector3& normalOnBInWorld,const btVector3& pointInWorld,btScalar depth);
Erwin
Sheikh Dawood wrote:Hi, I'm using version 2.40. Is the touch callback or collision callback implemented yet?
I can't find any functions such as "addTouchCallback" like from the previous versions.
-
- Posts: 7
- Joined: Tue Sep 19, 2006 3:14 am
-
- Posts: 7
- Joined: Tue Sep 19, 2006 3:14 am
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA