Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We are trying to determine the distance (a scalar, double) between two objects' surfaces in Bullet. We are new to the Bullet engine, and we've been looking into the demo projects, but couldn't find any good examples.

The closest we have come to implementing this is using the following:

btManifoldPoint& pt = contactManifold->getContactPoint(j);
double dist = pt.getDistance();

But where do we get the contactManifold object? (We're not even sure this is the right approach.)

We want to calculate distance when a key is pressed, so this is done in the specialKeyboard() function, a function in the Bullet demo framework.

Can anyone provide us with a clear, simple example?

share|improve this question
Are you trying to find the distance between the objects pivots, or the objects surface? And what with all the "we"? – Laurent Couvidou Mar 8 '13 at 10:30
I imagine bullet uses a callback system or something similar to support custom behavior as part of the collision resolution process. However you hook into that process, the framework should provide you with information on the colliding bodies. – Evan May 7 '13 at 15:11

Bullet's btCollisionWorld has member functions for ray casts and sweep tests:



Those should get you started, they are used in bullet's demos.

share|improve this answer

If you want it to only work on collision:

Otherwise I think you will need to use raytests etc like Maik says.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.