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 "LinearMath/btPoint3.h" |
---|
24 | #include "BulletCollision/CollisionShapes/btCollisionMargin.h" |
---|
25 | |
---|
26 | class btConvexShape; |
---|
27 | #include "btSimplexSolverInterface.h" |
---|
28 | class btConvexPenetrationDepthSolver; |
---|
29 | |
---|
30 | /// btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface |
---|
31 | class btGjkPairDetector : public btDiscreteCollisionDetectorInterface |
---|
32 | { |
---|
33 | |
---|
34 | |
---|
35 | btVector3 m_cachedSeparatingAxis; |
---|
36 | btConvexPenetrationDepthSolver* m_penetrationDepthSolver; |
---|
37 | btSimplexSolverInterface* m_simplexSolver; |
---|
38 | const btConvexShape* m_minkowskiA; |
---|
39 | const btConvexShape* m_minkowskiB; |
---|
40 | bool m_ignoreMargin; |
---|
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 | |
---|
71 | void setPenetrationDepthSolver(btConvexPenetrationDepthSolver* penetrationDepthSolver) |
---|
72 | { |
---|
73 | m_penetrationDepthSolver = penetrationDepthSolver; |
---|
74 | } |
---|
75 | |
---|
76 | ///don't use setIgnoreMargin, it's for Bullet's internal use |
---|
77 | void setIgnoreMargin(bool ignoreMargin) |
---|
78 | { |
---|
79 | m_ignoreMargin = ignoreMargin; |
---|
80 | } |
---|
81 | |
---|
82 | |
---|
83 | }; |
---|
84 | |
---|
85 | #endif //GJK_PAIR_DETECTOR_H |
---|