Contact points and normals with Bullet

Jan Bender
Posts: 111
Joined: Fri Sep 08, 2006 1:26 pm
Location: Germany

Contact points and normals with Bullet

Post by Jan Bender »

Hi,

I just started with the CollisionInterfaceDemo which determines a collision between two boxes and delivers one pair of contact points.

My questions:

1. How do I get the corresponding contact normal?

2. When the boxes are parallel, does Bullet always deliver contact points in the center of the contact region?

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

Re: Contact points and normals with Bullet

Post by Erwin Coumans »

Jan Bender wrote:Hi,

I just started with the CollisionInterfaceDemo which determines a collision between two boxes and delivers one pair of contact points.

My questions:

1. How do I get the corresponding contact normal?

2. When the boxes are parallel, does Bullet always deliver contact points in the center of the contact region?

Jan
Hi,

For each contact point (up to 4) in the contact manifold between object A and object B, you can get the contact normal using pt.m_normalWorldOnB
This normal points from B towards A, and is defined in world space (hence its name). Make sure to call the 'refreshContactPoints' when objects move, and don't call the 'clearContactPoints' otherwise the manifold management can't accumulate new points.

No, if boxes are parallel you get one set of closest points that can be anywhere on the surface. When you simulate several frames, the orientation of the boxes will change due to the applied impulse, and GJK reports new closest points. Those get added to the existing points in the manifolds, and the area is maximized, to approximate the convex outline of the contact region by up to 4 points.

I would highly recommend to first integrate Bullet including its existing persistent contact management. Once that works fine, you can consider if you still want to rewrite this and adding your own contact clipping for polyhedra.

Thanks,
Erwin