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 COMPOUND_COLLISION_ALGORITHM_H 00017 #define COMPOUND_COLLISION_ALGORITHM_H 00018 00019 #include "btActivatingCollisionAlgorithm.h" 00020 #include "BulletCollision/BroadphaseCollision/btDispatcher.h" 00021 #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" 00022 00023 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" 00024 class btDispatcher; 00025 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" 00026 #include "btCollisionCreateFunc.h" 00027 #include "LinearMath/btAlignedObjectArray.h" 00028 class btDispatcher; 00029 class btCollisionObject; 00030 00032 class btCompoundCollisionAlgorithm : public btActivatingCollisionAlgorithm 00033 { 00034 btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms; 00035 bool m_isSwapped; 00036 00037 class btPersistentManifold* m_sharedManifold; 00038 bool m_ownsManifold; 00039 00040 int m_compoundShapeRevision;//to keep track of changes, so that childAlgorithm array can be updated 00041 00042 void removeChildAlgorithms(); 00043 00044 void preallocateChildAlgorithms(btCollisionObject* body0,btCollisionObject* body1); 00045 00046 public: 00047 00048 btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); 00049 00050 virtual ~btCompoundCollisionAlgorithm(); 00051 00052 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); 00053 00054 btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); 00055 00056 virtual void getAllContactManifolds(btManifoldArray& manifoldArray) 00057 { 00058 int i; 00059 for (i=0;i<m_childCollisionAlgorithms.size();i++) 00060 { 00061 if (m_childCollisionAlgorithms[i]) 00062 m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray); 00063 } 00064 } 00065 00066 struct CreateFunc :public btCollisionAlgorithmCreateFunc 00067 { 00068 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) 00069 { 00070 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); 00071 return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,false); 00072 } 00073 }; 00074 00075 struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc 00076 { 00077 virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) 00078 { 00079 void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); 00080 return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,true); 00081 } 00082 }; 00083 00084 }; 00085 00086 #endif //COMPOUND_COLLISION_ALGORITHM_H