| 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 | #ifndef BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H | 
|---|
| 17 | #define BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H | 
|---|
| 18 |  | 
|---|
| 19 | #include "BulletCollision/CollisionDispatch/btActivatingCollisionAlgorithm.h" | 
|---|
| 20 | #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h" | 
|---|
| 21 | #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" | 
|---|
| 22 | #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" | 
|---|
| 23 | #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h" | 
|---|
| 24 | #include "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h" | 
|---|
| 25 | #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h" | 
|---|
| 26 | #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil | 
|---|
| 27 |  | 
|---|
| 28 | class btConvexPenetrationDepthSolver; | 
|---|
| 29 |  | 
|---|
| 30 |  | 
|---|
| 31 | ///The convex2dConvex2dAlgorithm collision algorithm support 2d collision detection for btConvex2dShape | 
|---|
| 32 | ///Currently it requires the btMinkowskiPenetrationDepthSolver, it has support for 2d penetration depth computation | 
|---|
| 33 | class btConvex2dConvex2dAlgorithm : public btActivatingCollisionAlgorithm | 
|---|
| 34 | { | 
|---|
| 35 | btSimplexSolverInterface*               m_simplexSolver; | 
|---|
| 36 | btConvexPenetrationDepthSolver* m_pdSolver; | 
|---|
| 37 |  | 
|---|
| 38 |  | 
|---|
| 39 | bool    m_ownManifold; | 
|---|
| 40 | btPersistentManifold*   m_manifoldPtr; | 
|---|
| 41 | bool                    m_lowLevelOfDetail; | 
|---|
| 42 |  | 
|---|
| 43 | int m_numPerturbationIterations; | 
|---|
| 44 | int m_minimumPointsPerturbationThreshold; | 
|---|
| 45 |  | 
|---|
| 46 | public: | 
|---|
| 47 |  | 
|---|
| 48 | btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold); | 
|---|
| 49 |  | 
|---|
| 50 |  | 
|---|
| 51 | virtual ~btConvex2dConvex2dAlgorithm(); | 
|---|
| 52 |  | 
|---|
| 53 | virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); | 
|---|
| 54 |  | 
|---|
| 55 | virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); | 
|---|
| 56 |  | 
|---|
| 57 | virtual void    getAllContactManifolds(btManifoldArray& manifoldArray) | 
|---|
| 58 | { | 
|---|
| 59 | ///should we use m_ownManifold to avoid adding duplicates? | 
|---|
| 60 | if (m_manifoldPtr && m_ownManifold) | 
|---|
| 61 | manifoldArray.push_back(m_manifoldPtr); | 
|---|
| 62 | } | 
|---|
| 63 |  | 
|---|
| 64 |  | 
|---|
| 65 | void    setLowLevelOfDetail(bool useLowLevel); | 
|---|
| 66 |  | 
|---|
| 67 |  | 
|---|
| 68 | const btPersistentManifold*     getManifold() | 
|---|
| 69 | { | 
|---|
| 70 | return m_manifoldPtr; | 
|---|
| 71 | } | 
|---|
| 72 |  | 
|---|
| 73 | struct CreateFunc :public       btCollisionAlgorithmCreateFunc | 
|---|
| 74 | { | 
|---|
| 75 |  | 
|---|
| 76 | btConvexPenetrationDepthSolver*         m_pdSolver; | 
|---|
| 77 | btSimplexSolverInterface*                       m_simplexSolver; | 
|---|
| 78 | int m_numPerturbationIterations; | 
|---|
| 79 | int m_minimumPointsPerturbationThreshold; | 
|---|
| 80 |  | 
|---|
| 81 | CreateFunc(btSimplexSolverInterface*                    simplexSolver, btConvexPenetrationDepthSolver* pdSolver); | 
|---|
| 82 |  | 
|---|
| 83 | virtual ~CreateFunc(); | 
|---|
| 84 |  | 
|---|
| 85 | virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) | 
|---|
| 86 | { | 
|---|
| 87 | void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvex2dConvex2dAlgorithm)); | 
|---|
| 88 | return new(mem) btConvex2dConvex2dAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); | 
|---|
| 89 | } | 
|---|
| 90 | }; | 
|---|
| 91 |  | 
|---|
| 92 |  | 
|---|
| 93 | }; | 
|---|
| 94 |  | 
|---|
| 95 | #endif //BT_CONVEX_2D_CONVEX_2D_ALGORITHM_H | 
|---|