Collision test

cutecutekid

06-11-2012 07:32:36

Hi.

I am sorry if this question has been asked before.

Is there a function that help me check when two objects collide with each other? For example, i have 2 rigid bodies moving in a world. i want to know when these two bodies collide so that i can do my post-collision by myself.

I've tried
inline bool checkCollideWith(btCollisionObject* co)

in btCollisionObject. But somehow it always return true for me, even though the two objects' wireframe rigid body are really far apart.

Thanks alot!

SethRightmer

30-12-2012 18:46:17

There are several ways of doing this. You can create a simulation tick callback and iterate over all the pairs in the contact manifold, if you want to do your own collision testing every tick of the simulation. You can also use a btGhostObject: this keeps track of it's own overlapping pairs. Finally, there is the "contactTest" query. This only checks for collisions when you ask it to, you can even create a custom object just for that test.

For more info, see here: http://bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Callbacks_and_Triggers