btCollisionDispatcher.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_COLLISION__DISPATCHER_H
00017 #define BT_COLLISION__DISPATCHER_H
00018 
00019 #include "BulletCollision/BroadphaseCollision/btDispatcher.h"
00020 #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
00021 
00022 #include "BulletCollision/CollisionDispatch/btManifoldResult.h"
00023 
00024 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00025 #include "LinearMath/btAlignedObjectArray.h"
00026 
00027 class btIDebugDraw;
00028 class btOverlappingPairCache;
00029 class btPoolAllocator;
00030 class btCollisionConfiguration;
00031 
00032 #include "btCollisionCreateFunc.h"
00033 
00034 #define USE_DISPATCH_REGISTRY_ARRAY 1
00035 
00036 class btCollisionDispatcher;
00038 typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
00039 
00040 
00043 class btCollisionDispatcher : public btDispatcher
00044 {
00045 
00046 protected:
00047 
00048         int             m_dispatcherFlags;
00049 
00050         btAlignedObjectArray<btPersistentManifold*>     m_manifoldsPtr;
00051 
00052         btManifoldResult        m_defaultManifoldResult;
00053 
00054         btNearCallback          m_nearCallback;
00055         
00056         btPoolAllocator*        m_collisionAlgorithmPoolAllocator;
00057 
00058         btPoolAllocator*        m_persistentManifoldPoolAllocator;
00059 
00060         btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
00061 
00062         btCollisionConfiguration*       m_collisionConfiguration;
00063 
00064 
00065 public:
00066 
00067         enum DispatcherFlags
00068         {
00069                 CD_STATIC_STATIC_REPORTED = 1,
00070                 CD_USE_RELATIVE_CONTACT_BREAKING_THRESHOLD = 2,
00071                 CD_DISABLE_CONTACTPOOL_DYNAMIC_ALLOCATION = 4
00072         };
00073 
00074         int     getDispatcherFlags() const
00075         {
00076                 return m_dispatcherFlags;
00077         }
00078 
00079         void    setDispatcherFlags(int flags)
00080         {
00081                 m_dispatcherFlags = flags;
00082         }
00083 
00085         void    registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
00086 
00087         int     getNumManifolds() const
00088         { 
00089                 return int( m_manifoldsPtr.size());
00090         }
00091 
00092         btPersistentManifold**  getInternalManifoldPointer()
00093         {
00094                 return &m_manifoldsPtr[0];
00095         }
00096 
00097          btPersistentManifold* getManifoldByIndexInternal(int index)
00098         {
00099                 return m_manifoldsPtr[index];
00100         }
00101 
00102          const btPersistentManifold* getManifoldByIndexInternal(int index) const
00103         {
00104                 return m_manifoldsPtr[index];
00105         }
00106 
00107         btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
00108 
00109         virtual ~btCollisionDispatcher();
00110 
00111         virtual btPersistentManifold*   getNewManifold(void* b0,void* b1);
00112         
00113         virtual void releaseManifold(btPersistentManifold* manifold);
00114 
00115 
00116         virtual void clearManifold(btPersistentManifold* manifold);
00117 
00118                         
00119         btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
00120                 
00121         virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1);
00122         
00123         virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1);
00124         
00125         virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
00126 
00127         void    setNearCallback(btNearCallback  nearCallback)
00128         {
00129                 m_nearCallback = nearCallback; 
00130         }
00131 
00132         btNearCallback  getNearCallback() const
00133         {
00134                 return m_nearCallback;
00135         }
00136 
00137         //by default, Bullet will use this near callback
00138         static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
00139 
00140         virtual void* allocateCollisionAlgorithm(int size);
00141 
00142         virtual void freeCollisionAlgorithm(void* ptr);
00143 
00144         btCollisionConfiguration*       getCollisionConfiguration()
00145         {
00146                 return m_collisionConfiguration;
00147         }
00148 
00149         const btCollisionConfiguration* getCollisionConfiguration() const
00150         {
00151                 return m_collisionConfiguration;
00152         }
00153 
00154         void    setCollisionConfiguration(btCollisionConfiguration* config)
00155         {
00156                 m_collisionConfiguration = config;
00157         }
00158 
00159         virtual btPoolAllocator*        getInternalManifoldPool()
00160         {
00161                 return m_persistentManifoldPoolAllocator;
00162         }
00163 
00164         virtual const btPoolAllocator*  getInternalManifoldPool() const
00165         {
00166                 return m_persistentManifoldPoolAllocator;
00167         }
00168 
00169 };
00170 
00171 #endif //BT_COLLISION__DISPATCHER_H
00172 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


bullet
Author(s): Erwin Coumans, ROS package maintained by Tully Foote
autogenerated on Wed Oct 31 2012 07:54:31