I tried to use contactTest function to test if an object collides with a collision world. However, it did not work correctly if I do not call performDiscreteCollisionDetection first. For example, just like the collisioninterfacedemo, the collision world has only one big box (box A). A small object (box B) is falling from the top of box A. If I do not call performDiscreteCollisionDetection first, the callback functions passed to contactTest don't get called when box B initially collides with box A, but get called when box B is in the middle of box A. If I call performDiscreteCollisionDetection first, then the callback functions get called as soon as box B collides with box A.
The demo application calls the performDiscreteCollisionDetection function.
Is it always necessary to call performDiscreteCollisionDetection before calling contactTest? If it is true, then the performDiscreteCollisionDetection always detects the collision world itself first and what is the advantage to call contactTest?
Thanks,
question about contactTest
-
laoyun
- Posts: 5
- Joined: Tue Mar 16, 2010 4:00 pm
Re: question about contactTest
I guess I did not explain myself clear so that no one answers the question.
Anyhow, the question is
In collision world, do I have to call performDiscreteCollisionDetection before calling contactTest?
The CollisionInterfaceDemo calls performDiscreteCollisionDetection. If I remove it, it looks that contactTest did not work correctly.
Thanks,
Anyhow, the question is
In collision world, do I have to call performDiscreteCollisionDetection before calling contactTest?
The CollisionInterfaceDemo calls performDiscreteCollisionDetection. If I remove it, it looks that contactTest did not work correctly.
Thanks,
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: question about contactTest
Indeed, the acceleration structures need to be up-to-date.
Instead of calling world->performDiscreteCollisionDetection(), you can also call world->updateAabbs();
(calling world->updateAabbs() a second time, or after performDiscreteCollisionDetection, should be very cheap)
Does that help?
Thanks,
Erwin
Instead of calling world->performDiscreteCollisionDetection(), you can also call world->updateAabbs();
(calling world->updateAabbs() a second time, or after performDiscreteCollisionDetection, should be very cheap)
Does that help?
Thanks,
Erwin