Proximity query on btCollisionWorld

User avatar
jann.poppinga
Posts: 12
Joined: Wed Aug 26, 2009 3:32 pm

Proximity query on btCollisionWorld

Post by jann.poppinga »

Dear all,

I have a btCollisionWorld filled with some btCollisionShapes. Now I'd like to query for the closest btCollisionShape to a given point. There seems to be no easy way to do this, or am I overlooking something? Would btDbvt::nearest (const int *i, const btDbvt::sStkNPS *a, btScalar v, int l, int h) be of any use? Unfortunately it is completely undocumented.

(I find it really strange that it is so completely unmentioned: no search hits in the wiki (http://www.google.de/search?as_q=proxim ... afe=images) or in the user manual, only two pages of (irrelevant) search results in the forum, no method in btCollisionWorld, no obviously named class, ... Is this such an exotic application?)
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Proximity query on btCollisionWorld

Post by pico »

Hi, its just a couple of lines to do that with Bullet.

1. Cast a sphere with the radius you need on that specific point (you need a small translation on the cast otherwise bullet breaks)
2. Now in the convex cast callback you get all the bodies back that intersect that sphere.
3. Sort the contacts by distance to the sphere center.