Computing distance

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
ngbinh
Posts: 117
Joined: Fri Aug 12, 2005 3:47 pm
Location: Newyork, USA

Computing distance

Post by ngbinh »

Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Computing distance

Post by Erwin Coumans »

ngbinh wrote:Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks
Bullet GJK gives you already the closest distance. See in ConvexHullDistance demo:

Code: Select all

	PointCollector gjkOutput;
	GjkPairDetector::ClosestPointInput input;
	input.m_transformA = tr[0];
	input.m_transformB = tr[1];
	convexConvex.GetClosestPoints(input ,gjkOutput);

Code: Select all

struct PointCollector : public DiscreteCollisionDetectorInterface::Result
{
	SimdVector3 m_normalOnBInWorld;
	SimdVector3 m_pointInWorld;
	SimdScalar	m_distance;//negative means penetration
...

There is currently penetration depth estimation, and a EPA implementation is contributed but not added to CVS yet. And more high-level interfaces, but in those cases there is broadphase culling, which prevents calculation of closest distance if objects are too far apart.

Erwin
ngbinh
Posts: 117
Joined: Fri Aug 12, 2005 3:47 pm
Location: Newyork, USA

Post by ngbinh »

OK. That's great!
I didn't really dwell into Bullet, just messing around with higher level interfaces.

Thanks alot.
gino
Physics Researcher
Posts: 22
Joined: Mon Jun 27, 2005 9:28 am
Location: Helmond, Netherlands
Contact:

Re: Computing distance

Post by gino »

ngbinh wrote:Hi!
Anyone know of algorithm that compute the distances between two bodies as well as the penetration depth?
Could I modify Bullet to get the distances?

I need that distance because some time steppers use "prevent penetration" not "penetration correction" approach, so the distances are needed.

I'd guess SWIFT++ could return distance but no penetration
thanks
SOLID 3.5 computes both the distance and the penetration depth for any combination of convex shape types. SOLID 3.5 can be downloaded from http://www.dtecta.com.

Cheers,

Gino
ngbinh
Posts: 117
Joined: Fri Aug 12, 2005 3:47 pm
Location: Newyork, USA

Post by ngbinh »

Hi!
Another question:

Let me describe the scenario first:
Two body A,B are close (or already) in contact, I'd like to get all the features distance that < some epsilon not just the closet one?

That features of collision detection are essential for my current time stepper to prevent intepenetrations, not just recover from penetration.

A side question: Anyone know of any physics engine implementation using that technique?

Thanks
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Post by Erwin Coumans »

This is called contact manifold generation. There have been a couple of similar postings/questions recently.
When using GJK, you need to gather multiple points. Several methods exist, Bullet uses currently Persistent Manifold that adds one closest point at a time, and keeps a small point set persistent over frames. Please see other postings about this:

http://continuousphysics.com/Bullet/php ... .php?t=288

Another approach, very suitable for polyhedra and in combination with Separating Axis Test based collision detection: you can explicitly build the manifold by finding two parallel planes and perform clipping using edge-planes.
If I got time I might start writing some white-paper about Contact Manifold generation in combination with GJK.
ngbinh
Posts: 117
Joined: Fri Aug 12, 2005 3:47 pm
Location: Newyork, USA

Post by ngbinh »

Thanks for the quick response!
It's really hard to work on the dynamics part alone (without knowing about stuff in CD).
Post Reply