Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Author: Irlan Robson
- * http://irlans.wordpress.com
- * Description: An implemetation of the GJK-SAT algorithm in 3D.
- */
- #ifndef __GJK_H__
- #define __GJK_H__
- #include "..\IRMathLib\CVector3.h"
- #include "CShapeInstance.h"
- #include "CPolyhedron.h"
- #ifndef GJK_ITERATIONS
- #define GJK_ITERATIONS 20UL
- #endif //#define GJK_ITERATIONS
- class CGjk {
- friend class CEpa;
- public :
- struct SIMPLEX_VERTEX {
- unsigned int ui32SupA;
- unsigned int ui32SupB;
- CVector3 vSupA;
- CVector3 vSupB;
- CVector3 vMinkSup;
- bool operator==(const SIMPLEX_VERTEX& _sOther) const {
- return ui32SupA == _sOther.ui32SupA && ui32SupB == _sOther.ui32SupB;
- }
- };
- struct SIMPLEX {
- enum S_SIMPLEX_TYPE {
- ST_POINT,
- ST_EDGE,
- ST_FACE,
- ST_TETRAHEDRON,
- ST_SIMPLEX_TOTALS
- };
- SIMPLEX_VERTEX vA;
- SIMPLEX_VERTEX vB;
- SIMPLEX_VERTEX vC;
- SIMPLEX_VERTEX vD;
- S_SIMPLEX_TYPE ssSimplexType;
- };
- CGjk();
- ~CGjk();
- bool Intersect(const CShapeInstance* _psiLeft, const CShapeInstance* _psiRight);
- protected :
- void GetSupportPoint(const CVector3& _vSearchDir, const CShapeInstance* _psiLeft, const CShapeInstance* _psiRight, SIMPLEX_VERTEX& _vRet) const;
- bool UpdateSimplex();
- bool UpdateSimplexTetrahedronFace(const CVector3& _vAo);
- bool SimplexEdgeUpdate();
- bool SimplexFaceUpdate();
- bool SimplexTetrahedronUpdate();
- typedef bool (CGjk::*SimplexFunc)();
- SimplexFunc m_psfpSimplexUpdateFuncs[SIMPLEX::ST_SIMPLEX_TOTALS];
- SIMPLEX m_sSimplex;
- CVector3 m_vSearchDir;
- };
- #endif //#ifndef __GJK_H__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement