Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_COMPOUND_COLLISION_ALGORITHM_H
00017 #define BT_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;
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 //BT_COMPOUND_COLLISION_ALGORITHM_H