Re: [Algorithms] Prism problems...
Brought to you by:
vexxed72
From: James L. <ja...@in...> - 2005-11-21 20:17:15
|
Diogo de Andrade wrote: > Yes, what I'm having are false negatives, basically everything that's > separated by an axis that is not one of the face-normal axis isn't being > detected... removing the " side0*side1 < 0" test gets me an almost ok > collision test, although in that case I get some false positives... Just checking this isn't a typo - my suggestion was to replace the return false on the two earlier tests with continue, you will need to keep the side0*side1 < 0 test. That is, change the algorithm to: for each pair of edges { int side0 = WhichSide(C0.V,D,C0.E(i).vertex); if ( side0 == 0 ) continue; // not return false int side1 = WhichSide(C1.V,D,C0.E(i).vertex); if ( side1 == 0 ) continue; // not return false if ( side0*side1 < 0 ) return false; } The first two tests just try for early outs in the case where the axis cannot separate the two polyhedra (though the second test doesn't save much). If you are still having problems, I would suggest it might come down to issues with numerical robustness. The definition of the WhichSide function given in the document is not very robust for points close to the plane being tested; try modifying the line: if ( t > 0 ) positive++; else if ( t < 0 ) negative++; to compare against a tolerance value rather than 0. At least one vertex is going to lie directly on the potential separating plane due to the way the algorithm works, and any numerical error could cause this axis to be dismissed as separating and thereby cause a false positive. HTH James |