I'm trying to register a callback that runs whenever two objects collide, but I can't figure out how. I don't want to prevent collision, or interfere with collision response in any way, just run some arbitrary code on each pair of colliding objects with their collision information. I feel certain that this is possible, but in searching the documentation I can't find any callbacks that do what I want, or virtual functions to override either. btCollisionDispatcher::setNearCallback() comes closest of everything I've found, but I don't want to check each object for collision myself. What am I looking for?
Also, is there a better source for information about Bullet than the official documentation? It serves quite well when I'm trying to find information on a specific class, but when I'm looking for a specific feature - like, say, a particular sort of callback - it falls down completely.
OnCollision callback
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: OnCollision callback
You should iterate over all contact manifolds. Check out the CollisionInterfaceDemo how to do this.
Each pair of objects that has AABB overlap has a contact manifold, and it can contain 0, 1, 2, 3 or 4 contact points.
Use the Bullet demos or those forums for a feature. if there is a popular request, we usually write a demo for it.
Hope this helps,
Erwin
Each pair of objects that has AABB overlap has a contact manifold, and it can contain 0, 1, 2, 3 or 4 contact points.
Use the Bullet demos or those forums for a feature. if there is a popular request, we usually write a demo for it.
Hope this helps,
Erwin
-
- Posts: 32
- Joined: Fri Aug 31, 2007 6:36 am
Re: OnCollision callback
It would really help if there was a simple interface to receive information about collisions.
Something like
btDynamicsWorld::addCollisionCallback(btCollisionCallback * callback)
and
btDynamicsWorld::removeCollisionCallback(btCollisionCallback * callback)
People are used to this type of interface. It would make collisions a lot easier to deal with IMO.
Something like
btDynamicsWorld::addCollisionCallback(btCollisionCallback * callback)
and
btDynamicsWorld::removeCollisionCallback(btCollisionCallback * callback)
People are used to this type of interface. It would make collisions a lot easier to deal with IMO.
-
- Posts: 4
- Joined: Thu Apr 17, 2008 7:50 pm
Re: OnCollision callback
Erwin: I considered that, but couldn't figure out how to get the collision force from the contact points (the collision normal would be the average of the contact normals, I guess). Is there some way to infer that from btManifoldPoint::getDistance()?
-
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: OnCollision callback
You can use btManifoldPoint m_appliedImpulse member, as a measure for the collision impact.Saucetenuto wrote:Erwin: I considered that, but couldn't figure out how to get the collision force from the contact points (the collision normal would be the average of the contact normals, I guess). Is there some way to infer that from btManifoldPoint::getDistance()?
Agreed. Not all developers use Bullet the same way, and that is why there are several different points inside the collision pipeline to intercept collision information. (near callback, ContactAdded/Processed/Removed Callbacks)It would really help if there was a simple interface to receive information about collisions.
[...]
btDynamicsWorld::addCollisionCallback(btCollisionCallback * callback)
We can add another btCollisionCallback at the end of each simulation sub step (that is called for each overlapping pair that has contact points.)
Also, we should provide a mechanism to easily iterate over all btPersistentManifold, give an overlapping pair of objects.
Thanks for the callback, eh, feedback,
Erwin
-
- Posts: 4
- Joined: Thu Apr 17, 2008 7:50 pm
Re: OnCollision callback
Long story short: I was on bullet 2.66b, which doesn't have m_appliedImpulse. bullet 2.68 does, and now that I've upgraded my life is much simpler. Thanks for your help!