collisions not detected sometimes

gip
Posts: 1
Joined: Mon Jun 06, 2011 9:18 am

collisions not detected sometimes

Post by gip »

Hi,
We had a problem when colliding a large box and a small capsule: once in a while when the capsule was inside the box no collision would be returned.

It seems the function projectorigin(vector a,vector b,vector c,vector d, scalar w, int mask) in btGjkEpa2 would return a different mask (14 instead of 15 ) for no reasons in some bad configuration.
In our case we would get a very small mindist (around 10e-8) and not go into that code:

Code: Select all

	
if(mindist<0)
{
	mindist	=	0;
	m		=	15;
	w[0]	=	det(c,b,d)/vl;
	w[1]	=	det(a,c,d)/vl;
	w[2]	=	det(b,a,d)/vl;
	w[3]	=	1-(w[0]+w[1]+w[2]);
}
I changed the test by using an epsilon instead of zero and it solved our bug without breaking anything else in our runtime:

Code: Select all

if(mindist<GJK_MIN_DISTANCE)
{
	mindist	=	0;
	m		=	15;
	w[0]	=	det(c,b,d)/vl;
	w[1]	=	det(a,c,d)/vl;
	w[2]	=	det(b,a,d)/vl;
	w[3]	=	1-(w[0]+w[1]+w[2]);
}
It kinda makes sense but i'm not that familiar with the Gjk algorithm to be sure it doesn't actually break it, so i was looking for some more expert insight...

cheers,
Gilles