Collision detection and scenegraph.

mathijsB
Posts: 1
Joined: Tue Mar 24, 2009 7:29 pm

Collision detection and scenegraph.

Post by mathijsB »

Hey all,

I am trying to use Bullet for collision detection ( I won't use dynamics ) in my game and I was hoping to get some help implementing it correctly. I have taken a look at the collisioninterface demo that comes with the sdk. I also came across the following code snippet to check collision between 2 objects.

Code: Select all

btCollisionAlgorithm* pAlgorithm = pBtWorld->getDispatcher()->findAlgorithm( pBulletObj1, pBulletObj2 );
btManifoldResult oManifoldResult( pBulletObj1, pBulletObj2 );
pAlgorithm->processCollision( pBulletObj1, pBulletObj2, pBtWorld->getDispatchInfo(), &oManifoldResult );
btPersistentManifold* pManifold = oManifoldResult.getPersistentManifold();
I was wondering if the above code snippet is very slow performance wise? I currently see two ways to do the collision detection, one is using collisionWorld->performDiscreteCollisionDetection(); as explained in the collisioninterface demo. This would actually not use any of the information stored in my scenegraph.

I could also use the above code snippet and manually perform collision between different objects in my scene graph. This way I could use the scene graph tree to reject a lot of collision detection queries for child tree member objects when the bounding box of a parent element in the scenegraph tree doesn't collide. Can anyone tell me if this is a good idea, or am I going to kill performance when I do this? If so, are there any other ways to provide the my scenegraph information to Bullet allowing it to reject collision queries based on scenegraph information?

Thanks in advance for your help,
Mathijs