Blender V2.61 - r43446

btConvex2dConvex2dAlgorithm.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 CONVEX_2D_CONVEX_2D_ALGORITHM_H
00017 #define CONVEX_2D_CONVEX_2D_ALGORITHM_H
00018 
00019 #include "BulletCollision/CollisionDispatch/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 "BulletCollision/CollisionDispatch/btCollisionCreateFunc.h"
00025 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
00026 #include "LinearMath/btTransformUtil.h" //for btConvexSeparatingDistanceUtil
00027 
00028 class btConvexPenetrationDepthSolver;
00029 
00030 
00033 class btConvex2dConvex2dAlgorithm : public btActivatingCollisionAlgorithm
00034 {
00035     btSimplexSolverInterface*       m_simplexSolver;
00036     btConvexPenetrationDepthSolver* m_pdSolver;
00037 
00038     
00039     bool    m_ownManifold;
00040     btPersistentManifold*   m_manifoldPtr;
00041     bool            m_lowLevelOfDetail;
00042     
00043     int m_numPerturbationIterations;
00044     int m_minimumPointsPerturbationThreshold;
00045 
00046 public:
00047 
00048     btConvex2dConvex2dAlgorithm(btPersistentManifold* mf,const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold);
00049 
00050 
00051     virtual ~btConvex2dConvex2dAlgorithm();
00052 
00053     virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00054 
00055     virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut);
00056 
00057     virtual void    getAllContactManifolds(btManifoldArray& manifoldArray)
00058     {
00060         if (m_manifoldPtr && m_ownManifold)
00061             manifoldArray.push_back(m_manifoldPtr);
00062     }
00063 
00064 
00065     void    setLowLevelOfDetail(bool useLowLevel);
00066 
00067 
00068     const btPersistentManifold* getManifold()
00069     {
00070         return m_manifoldPtr;
00071     }
00072 
00073     struct CreateFunc :public   btCollisionAlgorithmCreateFunc
00074     {
00075 
00076         btConvexPenetrationDepthSolver*     m_pdSolver;
00077         btSimplexSolverInterface*           m_simplexSolver;
00078         int m_numPerturbationIterations;
00079         int m_minimumPointsPerturbationThreshold;
00080 
00081         CreateFunc(btSimplexSolverInterface*            simplexSolver, btConvexPenetrationDepthSolver* pdSolver);
00082         
00083         virtual ~CreateFunc();
00084 
00085         virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1)
00086         {
00087             void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvex2dConvex2dAlgorithm));
00088             return new(mem) btConvex2dConvex2dAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold);
00089         }
00090     };
00091 
00092 
00093 };
00094 
00095 #endif //CONVEX_2D_CONVEX_2D_ALGORITHM_H