0

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?

sam hocevar
  • 23,811
  • 2
  • 63
  • 95
user27160
  • 1
  • 1
  • 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 08 '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 07 '13 at 15:11

2 Answers2

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.

Maik Semder
  • 4,718
  • 1
  • 26
  • 24
0

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.

Lewis Wakeford
  • 799
  • 3
  • 13