The best way is to use a btGhostObject, and then iterate over its overlapping pairs (not ALL pairs in the world), and get the contact manifolds from each overlapping pair. The Bullet/Demos/CharacterDemo shows how to use the btGhostObject. It would be nice to have another demo that shows how to use the btGhostObject.
The second best is to iterate over ALL contact manifolds, as described in Bullet/Demos/CollisionInterfaceDemo.
Using the contact added callback is not designed for triggering (game) logic, but mainly to override internal settings such as friction values or contact normals etc. Such callbacks might not even be available, especially when the collision detection happens on SPU (PlayStation 3) or GPU (upcoming OpenCL version of Bullet 3.x).
The Bullet/Demos/MultiMaterialDemo is an example how to use those callbacks to adjust friction.
garvek wrote:
My question is still about a collision detect signal. I'm using 2 std::maps in order to store new and old contacts
Each contact point has a m_lifeTime variable, you should be able to use that to determine if the contact is new or not. Searching a map shouldn't be necessary.
Fred_FS wrote:
but I get some problems with rigid bodys that are within other bodys.
What kind of collision shape are those 'other bodies' using? If an object is entirely embedded inside a hollow concave shape such as a Gimpact, btCompoundShape or btBvhTriangleMeshShape, without touching any of its triangles/children, no collision is reported.
So the main problem is that people refuse to iterate over ALL contact manifolds, because of performance issues?
If so, do you have some profiling info that shows that shows the cost of iterating over ALL contact manifolds one single time?
Thanks,
Erwin