Blender V2.61 - r43446
|
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_CONVEX_ALGORITHM_H 00017 #define 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,btCollisionObject* body0,btCollisionObject* body1, btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver, int numPerturbationIterations, int minimumPointsPerturbationThreshold); 00063 00064 00065 virtual ~btConvexConvexAlgorithm(); 00066 00067 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); 00068 00069 virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); 00070 00071 virtual void getAllContactManifolds(btManifoldArray& manifoldArray) 00072 { 00074 if (m_manifoldPtr && m_ownManifold) 00075 manifoldArray.push_back(m_manifoldPtr); 00076 } 00077 00078 00079 void setLowLevelOfDetail(bool useLowLevel); 00080 00081 00082 const btPersistentManifold* getManifold() 00083 { 00084 return m_manifoldPtr; 00085 } 00086 00087 struct CreateFunc :public btCollisionAlgorithmCreateFunc 00088 { 00089 00090 btConvexPenetrationDepthSolver* m_pdSolver; 00091 btSimplexSolverInterface* m_simplexSolver; 00092 int m_numPerturbationIterations; 00093 int m_minimumPointsPerturbationThreshold; 00094 00095 CreateFunc(btSimplexSolverInterface* simplexSolver, btConvexPenetrationDepthSolver* pdSolver); 00096 00097 virtual ~CreateFunc(); 00098 00099 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) 00100 { 00101 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btConvexConvexAlgorithm)); 00102 return new(mem) btConvexConvexAlgorithm(ci.m_manifold,ci,body0,body1,m_simplexSolver,m_pdSolver,m_numPerturbationIterations,m_minimumPointsPerturbationThreshold); 00103 } 00104 }; 00105 00106 00107 }; 00108 00109 #endif //CONVEX_CONVEX_ALGORITHM_H