Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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
1  
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

2 Answers 2

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

btCollisionWorld::rayTest

btCollisionWorld::convexSweepTest

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:

http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Collision_Callbacks_and_Triggers

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

share|improve this answer

Your Answer

 
discard

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.