situation of colliding but no contact points

li9s
Posts: 3
Joined: Mon Sep 06, 2010 3:35 am

situation of colliding but no contact points

Post by li9s »

I have searched for the situation but it seems there are no relative topics.
In my scene I have a btCollisionObject with btCompoundShape, and a btRigidBody with a btBoxShape, they are both running in the only btDiscreteDynamicsWorld. And when they collide, I got numManifolds(which is not 0), but I cannot get contact points since numContacts is always 0.
my code for collision detection:

Code: Select all

	int numManifolds = sDynamicsWorld->getDispatcher()->getNumManifolds();
	for(int i=0;i<numManifolds;i++)
	{
		btPersistentManifold * contactManifold = sDynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
		int numContacts= contactManifold->getNumContacts();
		if(numContacts>0)
		{
			btCollisionObject * obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
			btCollisionObject * obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
			type_obj1 = obA->getUserPointer();
			type_obj2 = obB->getUserPointer();
			...
		}
	}
I'm still not clear about the relation of contactManifold and contactPoints.
Non-zero contactManifold means collision, am I right?

thanks.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: situation of colliding but no contact points

Post by Dirk Gregorius »

Well, the first thing you should do is to render your scene. The nice thing about collision detection and physics is that you can easily visualize everything. Secondly, I would guess that Bullet creates a manifold as soon as the associated AABBs of the collision shapes overlap. This doesn't necessarily mean that the actual shapes are in contact which explains that the number of contact points is zero.

HTH,
-Dirk
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: situation of colliding but no contact points

Post by Erwin Coumans »

Indeed, as Dirk mentioned Bullet pre-allocates contact manifolds ahead of time, when the AABB overlaps.

This means, a btPersistentManifold might be empty/have zero contact points. A non-zero contactManifold means collision indeed.
Thanks,
Erwin
li9s
Posts: 3
Joined: Mon Sep 06, 2010 3:35 am

Re: situation of colliding but no contact points

Post by li9s »

Dirk Gregorius wrote:Well, the first thing you should do is to render your scene. The nice thing about collision detection and physics is that you can easily visualize everything. Secondly, I would guess that Bullet creates a manifold as soon as the associated AABBs of the collision shapes overlap. This doesn't necessarily mean that the actual shapes are in contact which explains that the number of contact points is zero.

HTH,
-Dirk
Hi Dirk,
Yes I did some rendering works, I can see the AABBs but the real shape is very small, I guess there's something wrong with the units.
finally it works. I use meters instead of centimeters,then the collision shape's size seems to be correct.

Thanks!
-James Lee.
li9s
Posts: 3
Joined: Mon Sep 06, 2010 3:35 am

Re: situation of colliding but no contact points

Post by li9s »

Erwin Coumans wrote:Indeed, as Dirk mentioned Bullet pre-allocates contact manifolds ahead of time, when the AABB overlaps.

This means, a btPersistentManifold might be empty/have zero contact points. A non-zero contactManifold means collision indeed.
Thanks,
Erwin
thanks Erwin! It really helps.
-James Lee