Collision detection
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Collision detection
Hi i want use bullet to detect whether some of my object are colliding. I dont need physic simulation, just collision detection. Im not sure how exactly do this. What Im trying now is that I create btDiscreteDynamicsWorld, setup my method gContactAddedCallback in which Im collecting objects which impacts, then insert some btRigidBodyes and then I call btDiscreteDynamicsWorld.stepSimulation. This does not work Is there a better way to do what I need? pls help
-
- Posts: 14
- Joined: Fri Oct 24, 2008 3:32 pm
Re: Collision detection
Hi,
I am not sure I fully understand your problem. If you just want to use the collision part of Bullet, you can choose to do so. Look in the Bullet manual. Step 5 under Quickstart touches on this.
As far as I know, you then use the callbacks to check whether you have a collision.
In my application, I do use the physics, but I also use kinematic objects, which are not affected by any other objects, but I can add a flag, so that when my object "collides", my callback function is called.
Is that what you are looking for?
I am not sure I fully understand your problem. If you just want to use the collision part of Bullet, you can choose to do so. Look in the Bullet manual. Step 5 under Quickstart touches on this.
As far as I know, you then use the callbacks to check whether you have a collision.
In my application, I do use the physics, but I also use kinematic objects, which are not affected by any other objects, but I can add a flag, so that when my object "collides", my callback function is called.
Is that what you are looking for?
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Re: Collision detection
yes, that looks like what i need. thx
-
- Posts: 14
- Joined: Thu May 15, 2008 6:09 pm
Re: Collision detection
I'm still experiencing some problems... my code looks like this..
_world->performDiscreteCollisionDetection();
int numManifolds = _dispatcher->getNumManifolds();
for (int i = 0; i < numManifolds; i++)
{
btPersistentManifold* contactManifold = _dispatcher->getManifoldByIndexInternal(i);
btCollisionObject* a = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* b = static_cast<btCollisionObject*>(contactManifold->getBody1());
... some code
}
is this test correct? Does this mean that a collided with b? or do I have to check if contactManifold->getNumContacts() is greater then 1? Without checking contacts, detection looks like there is only AABB overlap test... But if i check contacts count, not all collisions are recognised
And another question... is there any settings that can change detection precision? I do not care about speed...
_world->performDiscreteCollisionDetection();
int numManifolds = _dispatcher->getNumManifolds();
for (int i = 0; i < numManifolds; i++)
{
btPersistentManifold* contactManifold = _dispatcher->getManifoldByIndexInternal(i);
btCollisionObject* a = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* b = static_cast<btCollisionObject*>(contactManifold->getBody1());
... some code
}
is this test correct? Does this mean that a collided with b? or do I have to check if contactManifold->getNumContacts() is greater then 1? Without checking contacts, detection looks like there is only AABB overlap test... But if i check contacts count, not all collisions are recognised
And another question... is there any settings that can change detection precision? I do not care about speed...