Shortest Distance from a Body to an arbitrary Coordinate

Post Reply
Posts: 5
Joined: Mon Feb 01, 2010 8:27 pm

Shortest Distance from a Body to an arbitrary Coordinate

Post by Adler » Mon Jun 18, 2012 12:39 pm


I have some bodies with shapes in my scene. All shapes are triangle meshes (btGImpactMeshShape) but it would be okay
to use btConvexTriangleMeshShape instead.
How can i compute the closest distance of my Geometries / Bodies to a given point? I only found solutions to comute the closest Distance between shapes, but the point is just a simple coordinate - no shape no body.

In my Application i have critical points and i want to colour them if geometries of a collision category are approaching. They are not physical objects.

I tried it with something like this where trigger is my point of interesst

Code: Select all

btVector3 closestPoint( btConvexShape * shape, btRigidBody * body, btVector3 trigger)
   // perform move of body also to my trigger so they are defined in the same local coordinates
   btVector3 ptrigger = body->getWorldTransform() * trigger;  
   return shape->localGetSupportingVertex(ptrigger);

I have removed all the stuff about checking the collision masks so it is reduced the basics.

There must be an easier way - maybe using the btGImpactMeshShape and not only the hull.
By the way: the closest distance would be enough - the colosest point would be nice.

Thanks for an advice

Post Reply