00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GJK_PAIR_DETECTOR_H
00020 #define GJK_PAIR_DETECTOR_H
00021
00022 #include "btDiscreteCollisionDetectorInterface.h"
00023 #include "BulletCollision/CollisionShapes/btCollisionMargin.h"
00024
00025 class btConvexShape;
00026 #include "btSimplexSolverInterface.h"
00027 class btConvexPenetrationDepthSolver;
00028
00030 class btGjkPairDetector : public btDiscreteCollisionDetectorInterface
00031 {
00032
00033
00034 btVector3 m_cachedSeparatingAxis;
00035 btConvexPenetrationDepthSolver* m_penetrationDepthSolver;
00036 btSimplexSolverInterface* m_simplexSolver;
00037 const btConvexShape* m_minkowskiA;
00038 const btConvexShape* m_minkowskiB;
00039 int m_shapeTypeA;
00040 int m_shapeTypeB;
00041 btScalar m_marginA;
00042 btScalar m_marginB;
00043
00044 bool m_ignoreMargin;
00045 btScalar m_cachedSeparatingDistance;
00046
00047
00048 public:
00049
00050
00051 int m_lastUsedMethod;
00052 int m_curIter;
00053 int m_degenerateSimplex;
00054 int m_catchDegeneracies;
00055
00056
00057 btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
00058 btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver);
00059 virtual ~btGjkPairDetector() {};
00060
00061 virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false);
00062
00063 void getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw);
00064
00065
00066 void setMinkowskiA(btConvexShape* minkA)
00067 {
00068 m_minkowskiA = minkA;
00069 }
00070
00071 void setMinkowskiB(btConvexShape* minkB)
00072 {
00073 m_minkowskiB = minkB;
00074 }
00075 void setCachedSeperatingAxis(const btVector3& seperatingAxis)
00076 {
00077 m_cachedSeparatingAxis = seperatingAxis;
00078 }
00079
00080 const btVector3& getCachedSeparatingAxis() const
00081 {
00082 return m_cachedSeparatingAxis;
00083 }
00084 btScalar getCachedSeparatingDistance() const
00085 {
00086 return m_cachedSeparatingDistance;
00087 }
00088
00089 void setPenetrationDepthSolver(btConvexPenetrationDepthSolver* penetrationDepthSolver)
00090 {
00091 m_penetrationDepthSolver = penetrationDepthSolver;
00092 }
00093
00095 void setIgnoreMargin(bool ignoreMargin)
00096 {
00097 m_ignoreMargin = ignoreMargin;
00098 }
00099
00100
00101 };
00102
00103 #endif //GJK_PAIR_DETECTOR_H