ReactPhysics3D
v0.10.2
C++ Physics engine library
|
This class implements a narrow-phase collision detection algorithm. More...
#include <include/reactphysics3d/collision/narrowphase/GJK/GJKAlgorithm.h>
Public Types | |
enum class | GJKResult { SEPARATED , COLLIDE_IN_MARGIN , INTERPENETRATE } |
Public Member Functions | |
GJKAlgorithm ()=default | |
Constructor. | |
~GJKAlgorithm ()=default | |
Destructor. | |
GJKAlgorithm (const GJKAlgorithm &algorithm)=delete | |
Deleted copy-constructor. | |
GJKAlgorithm & | operator= (const GJKAlgorithm &algorithm)=delete |
Deleted assignment operator. | |
void | testCollision (NarrowPhaseInfoBatch &narrowPhaseInfoBatch, uint32 batchStartIndex, uint32 batchNbItems, Array< GJKResult > &gjkResults) |
Compute a contact info if the two bounding volumes collide. | |
This class implements a narrow-phase collision detection algorithm.
This algorithm uses the ISA-GJK algorithm. This implementation is based on the implementation discussed in the book "Collision Detection in Interactive 3D Environments" by Gino van den Bergen. This method implements the Hybrid Technique for calculating the penetration depth. The two objects are enlarged with a small margin. If the object intersects in their margins, the penetration depth is quickly computed using the GJK algorithm on the original objects (without margin). If the original objects (without margin) intersect, we exit GJK and run the SAT algorithm to get contacts and collision data.
void GJKAlgorithm::testCollision | ( | NarrowPhaseInfoBatch & | narrowPhaseInfoBatch, |
uint32 | batchStartIndex, | ||
uint32 | batchNbItems, | ||
Array< GJKResult > & | gjkResults | ||
) |
Compute a contact info if the two bounding volumes collide.
This method implements the Hybrid Technique for computing the penetration depth by running the GJK algorithm on original objects (without margin).
If the shapes intersect only in the margins, the method compute the penetration depth and contact points (of enlarged objects). If the original objects (without margin) intersect, we call the computePenetrationDepthForEnlargedObjects() method that run the GJK algorithm on the enlarged object to obtain a simplex polytope that contains the origin, they we give that simplex polytope to the EPA algorithm which will compute the correct penetration depth and contact points between the enlarged objects.