I've been trying to make a sensor/trigger zone using ghost objects. The idea is that an event is generated in the game when an object enters the trigger zone, and when it leaves it. So I created a ghost object and generate the event when rigid bodies enter or leave it.
This works fine except that the events are triggered when objects enter the AABB of the ghost object, not the actual shape. I would like to be able to detect when they enter the actual shape. I feel like there is supposed to be a way of setting it up to do this... the documentation says, tantalizingly:
"The btGhostObject can keep track of all objects that are overlapping By default, this overlap is based on the AABB"
but how do I make it not based on the AABB? I've been searching the documentation and the forums and can't find it. Someone suggested calling:
Code: Select all
dynamics_world->getDispatcher()->dispatchAllCollisionPairs(ghost_object->getOverlappingPairCache(), dynamics_world->getDispatchInfo(), dynamics_world->getDispatcher())
I could manually, every frame, call contactPairTest between each rigid body in the AABB, and the collision shape of the ghost object, but I feel like I'm missing something? Is there a 'proper' way of doing it?
P.S. My trigger zone doesn't move between frames, it is always at the same position.