btConvexConvexAlgorithm.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef BT_CONVEX_CONVEX_ALGORITHM_H
00017 #define BT_CONVEX_CONVEX_ALGORITHM_H
00018 
00019 #include "btActivatingCollisionAlgorithm.h"
00020 #include "BulletCollision/NarrowPhaseCollision/btGjkPairDetector.h"
00021 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00022 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00023 #include "BulletCollision/NarrowPhaseCollision/btVoronoiSimplexSolver.h"
00024 #include "btCollisionCreateFunc.h"
00025 #include "btCollisionDispatcher.h"
00026 #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil
00027 
00028 class btConvexPenetrationDepthSolver;
00029 
00034 
00035 //#define USE_SEPDISTANCE_UTIL2 1
00036 
00040 class btConvexConvexAlgorithm : public btActivatingCollisionAlgorithm
00041 {
00042 #ifdef USE_SEPDISTANCE_UTIL2
00043         btConvexSeparatingDistanceUtil  m_sepDistance;
00044 #endif
00045         btSimplexSolverInterface*               m_simplexSolver;
00046         btConvexPenetrationDepthSolver* m_pdSolver;
00047 
00048         
00049         bool    m_ownManifold;
00050         btPersistentManifold*   m_manifoldPtr;
00051         bool                    m_lowLevelOfDetail;
00052         
00053         int m_numPerturbationIterations;
00054         int m_minimumPointsPerturbationThreshold;
00055 
00056 
00058         
00059 
00060 public:
00061 
00062         btConvexConvexAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
00063 
00064         virtual ~btConvexConvexAlgorithm();
00065 
00066         virtual void processCollision (const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00067 
00068         virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00069 
00070         virtual void    getAllContactManifolds(btManifoldArray& manifoldArray)
00071         {
00073                 if (m_manifoldPtr && m_ownManifold)
00074                         manifoldArray.push_back(m_manifoldPtr);
00075         }
00076 
00077 
00078         void    setLowLevelOfDetail(bool useLowLevel);
00079 
00080 
00081         const btPersistentManifold*     getManifold()
00082         {
00083                 return m_manifoldPtr;
00084         }
00085 
00086         struct CreateFunc :public       btCollisionAlgorithmCreateFunc
00087         {
00088 
00089                 btConvexPenetrationDepthSolver*         m_pdSolver;
00090                 btSimplexSolverInterface*                       m_simplexSolver;
00091                 int m_numPerturbationIterations;
00092                 int m_minimumPointsPerturbationThreshold;
00093 
00094                 CreateFunc(btSimplexSolverInterface*                    simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
00095                 
00096                 virtual ~CreateFunc();
00097 
00098                 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, const btCollisionObjectWrapper* body0Wrap,const btCollisionObjectWrapper* body1Wrap)
00099                 {
00100                         void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm));
00101                         return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0Wrap,body1Wrap,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
00102                 }
00103         };
00104 
00105 
00106 };
00107 
00108 #endif //BT_CONVEX_CONVEX_ALGORITHM_H