Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionDispatcher.h @ 6505

Last change on this file since 6505 was 5781, checked in by rgrieder, 15 years ago

Reverted trunk again. We might want to find a way to delete these revisions again (x3n's changes are still available as diff in the commit mails).

  • Property svn:eol-style set to native
File size: 4.6 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14*/
15
16#ifndef COLLISION__DISPATCHER_H
17#define COLLISION__DISPATCHER_H
18
19#include "BulletCollision/BroadphaseCollision/btDispatcher.h"
20#include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h"
21
22#include "BulletCollision/CollisionDispatch/btManifoldResult.h"
23
24#include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
25#include "LinearMath/btAlignedObjectArray.h"
26
27class btIDebugDraw;
28class btOverlappingPairCache;
29class btPoolAllocator;
30class btCollisionConfiguration;
31
32#include "btCollisionCreateFunc.h"
33
34#define USE_DISPATCH_REGISTRY_ARRAY 1
35
36class btCollisionDispatcher;
37///user can override this nearcallback for collision filtering and more finegrained control over collision detection
38typedef void (*btNearCallback)(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
39
40
41///btCollisionDispatcher supports algorithms that handle ConvexConvex and ConvexConcave collision pairs.
42///Time of Impact, Closest Points and Penetration Depth.
43class btCollisionDispatcher : public btDispatcher
44{
45        int m_count;
46       
47        btAlignedObjectArray<btPersistentManifold*>     m_manifoldsPtr;
48
49        bool m_useIslands;
50
51        bool    m_staticWarningReported;
52       
53        btManifoldResult        m_defaultManifoldResult;
54
55        btNearCallback          m_nearCallback;
56       
57        btPoolAllocator*        m_collisionAlgorithmPoolAllocator;
58
59        btPoolAllocator*        m_persistentManifoldPoolAllocator;
60
61        btCollisionAlgorithmCreateFunc* m_doubleDispatch[MAX_BROADPHASE_COLLISION_TYPES][MAX_BROADPHASE_COLLISION_TYPES];
62       
63
64        btCollisionConfiguration*       m_collisionConfiguration;
65
66
67public:
68
69        ///registerCollisionCreateFunc allows registration of custom/alternative collision create functions
70        void    registerCollisionCreateFunc(int proxyType0,int proxyType1, btCollisionAlgorithmCreateFunc* createFunc);
71
72        int     getNumManifolds() const
73        { 
74                return int( m_manifoldsPtr.size());
75        }
76
77        btPersistentManifold**  getInternalManifoldPointer()
78        {
79                return &m_manifoldsPtr[0];
80        }
81
82         btPersistentManifold* getManifoldByIndexInternal(int index)
83        {
84                return m_manifoldsPtr[index];
85        }
86
87         const btPersistentManifold* getManifoldByIndexInternal(int index) const
88        {
89                return m_manifoldsPtr[index];
90        }
91
92        btCollisionDispatcher (btCollisionConfiguration* collisionConfiguration);
93
94        virtual ~btCollisionDispatcher();
95
96        virtual btPersistentManifold*   getNewManifold(void* b0,void* b1);
97       
98        virtual void releaseManifold(btPersistentManifold* manifold);
99
100
101        virtual void clearManifold(btPersistentManifold* manifold);
102
103                       
104        btCollisionAlgorithm* findAlgorithm(btCollisionObject* body0,btCollisionObject* body1,btPersistentManifold* sharedManifold = 0);
105               
106        virtual bool    needsCollision(btCollisionObject* body0,btCollisionObject* body1);
107       
108        virtual bool    needsResponse(btCollisionObject* body0,btCollisionObject* body1);
109       
110        virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
111
112        void    setNearCallback(btNearCallback  nearCallback)
113        {
114                m_nearCallback = nearCallback; 
115        }
116
117        btNearCallback  getNearCallback() const
118        {
119                return m_nearCallback;
120        }
121
122        //by default, Bullet will use this near callback
123        static void  defaultNearCallback(btBroadphasePair& collisionPair, btCollisionDispatcher& dispatcher, const btDispatcherInfo& dispatchInfo);
124
125        virtual void* allocateCollisionAlgorithm(int size);
126
127        virtual void freeCollisionAlgorithm(void* ptr);
128
129        btCollisionConfiguration*       getCollisionConfiguration()
130        {
131                return m_collisionConfiguration;
132        }
133
134        const btCollisionConfiguration* getCollisionConfiguration() const
135        {
136                return m_collisionConfiguration;
137        }
138
139        void    setCollisionConfiguration(btCollisionConfiguration* config)
140        {
141                m_collisionConfiguration = config;
142        }
143
144};
145
146#endif //COLLISION__DISPATCHER_H
147
Note: See TracBrowser for help on using the repository browser.