[1963] | 1 | /* |
---|
| 2 | Bullet Continuous Collision Detection and Physics Library |
---|
| 3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
| 4 | |
---|
| 5 | This software is provided 'as-is', without any express or implied warranty. |
---|
| 6 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
| 7 | Permission is granted to anyone to use this software for any purpose, |
---|
| 8 | including commercial applications, and to alter it and redistribute it freely, |
---|
| 9 | subject to the following restrictions: |
---|
| 10 | |
---|
| 11 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. |
---|
| 12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
| 13 | 3. This notice may not be removed or altered from any source distribution. |
---|
| 14 | */ |
---|
| 15 | |
---|
| 16 | |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | #ifndef GJK_PAIR_DETECTOR_H |
---|
| 20 | #define GJK_PAIR_DETECTOR_H |
---|
| 21 | |
---|
| 22 | #include "btDiscreteCollisionDetectorInterface.h" |
---|
| 23 | #include "BulletCollision/CollisionShapes/btCollisionMargin.h" |
---|
| 24 | |
---|
| 25 | class btConvexShape; |
---|
| 26 | #include "btSimplexSolverInterface.h" |
---|
| 27 | class btConvexPenetrationDepthSolver; |
---|
| 28 | |
---|
| 29 | /// btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface |
---|
| 30 | class btGjkPairDetector : public btDiscreteCollisionDetectorInterface |
---|
| 31 | { |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | btVector3 m_cachedSeparatingAxis; |
---|
| 35 | btConvexPenetrationDepthSolver* m_penetrationDepthSolver; |
---|
| 36 | btSimplexSolverInterface* m_simplexSolver; |
---|
| 37 | const btConvexShape* m_minkowskiA; |
---|
| 38 | const btConvexShape* m_minkowskiB; |
---|
| 39 | bool m_ignoreMargin; |
---|
[2430] | 40 | btScalar m_cachedSeparatingDistance; |
---|
[1963] | 41 | |
---|
| 42 | |
---|
| 43 | public: |
---|
| 44 | |
---|
| 45 | //some debugging to fix degeneracy problems |
---|
| 46 | int m_lastUsedMethod; |
---|
| 47 | int m_curIter; |
---|
| 48 | int m_degenerateSimplex; |
---|
| 49 | int m_catchDegeneracies; |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver); |
---|
| 53 | virtual ~btGjkPairDetector() {}; |
---|
| 54 | |
---|
| 55 | virtual void getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults=false); |
---|
| 56 | |
---|
| 57 | void setMinkowskiA(btConvexShape* minkA) |
---|
| 58 | { |
---|
| 59 | m_minkowskiA = minkA; |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | void setMinkowskiB(btConvexShape* minkB) |
---|
| 63 | { |
---|
| 64 | m_minkowskiB = minkB; |
---|
| 65 | } |
---|
| 66 | void setCachedSeperatingAxis(const btVector3& seperatingAxis) |
---|
| 67 | { |
---|
| 68 | m_cachedSeparatingAxis = seperatingAxis; |
---|
| 69 | } |
---|
| 70 | |
---|
[2430] | 71 | const btVector3& getCachedSeparatingAxis() const |
---|
| 72 | { |
---|
| 73 | return m_cachedSeparatingAxis; |
---|
| 74 | } |
---|
| 75 | btScalar getCachedSeparatingDistance() const |
---|
| 76 | { |
---|
| 77 | return m_cachedSeparatingDistance; |
---|
| 78 | } |
---|
| 79 | |
---|
[1963] | 80 | void setPenetrationDepthSolver(btConvexPenetrationDepthSolver* penetrationDepthSolver) |
---|
| 81 | { |
---|
| 82 | m_penetrationDepthSolver = penetrationDepthSolver; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | ///don't use setIgnoreMargin, it's for Bullet's internal use |
---|
| 86 | void setIgnoreMargin(bool ignoreMargin) |
---|
| 87 | { |
---|
| 88 | m_ignoreMargin = ignoreMargin; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | }; |
---|
| 93 | |
---|
| 94 | #endif //GJK_PAIR_DETECTOR_H |
---|