2 Bullet Continuous Collision Detection and Physics Library
\r
3 Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com
\r
5 This software is provided 'as-is', without any express or implied warranty.
\r
6 In no event will the authors be held liable for any damages arising from the use of this software.
\r
7 Permission is granted to anyone to use this software for any purpose,
\r
8 including commercial applications, and to alter it and redistribute it freely,
\r
9 subject to the following restrictions:
\r
11 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.
\r
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
\r
13 3. This notice may not be removed or altered from any source distribution.
\r
15 #ifndef BT_LOW_LEVEL_COLLISION__DISPATCHER_H
\r
16 #define BT_LOW_LEVEL_COLLISION__DISPATCHER_H
\r
18 #include "BulletCollision/CollisionDispatch/btCollisionDispatcher.h"
\r
19 struct btLowLevelBroadphase;//struct instead of class?
\r
20 struct btLowLevelData;
\r
21 ///Tuning value to optimized SPU utilization
\r
22 ///Too small value means Task overhead is large compared to computation (too fine granularity)
\r
23 ///Too big value might render some SPUs are idle, while a few other SPUs are doing all work.
\r
24 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 8
\r
25 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 16
\r
26 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 64
\r
27 #define SPU_BATCHSIZE_BROADPHASE_PAIRS 128
\r
28 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 256
\r
29 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 512
\r
30 //#define SPU_BATCHSIZE_BROADPHASE_PAIRS 1024
\r
31 #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h"
\r
33 class btLowLevelCollisionAlgorithm : public btCollisionAlgorithm
\r
35 btPersistentManifold* m_manifold;
\r
39 btLowLevelCollisionAlgorithm()
\r
44 btLowLevelCollisionAlgorithm(btPersistentManifold* manifold, btCollisionDispatcher* dispatcher)
\r
45 :m_manifold(manifold)
\r
47 m_dispatcher = dispatcher;
\r
49 virtual ~btLowLevelCollisionAlgorithm()
\r
52 m_dispatcher->releaseManifold(m_manifold);
\r
54 virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
\r
59 virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)
\r
65 virtual void getAllContactManifolds(btManifoldArray& manifoldArray)
\r
67 manifoldArray.push_back(m_manifold);
\r
73 ///btLowLevelCollisionDispatcher can use SPU to gather and calculate collision detection
\r
74 ///Time of Impact, Closest Points and Penetration Depth.
\r
75 class btLowLevelCollisionDispatcher : public btCollisionDispatcher
\r
78 btLowLevelData* m_lowLevelData;
\r
80 btAlignedObjectArray<btPersistentManifold> m_manifoldArray;
\r
81 btAlignedObjectArray<btLowLevelCollisionAlgorithm> m_algorithms;
\r
90 btLowLevelCollisionDispatcher (btLowLevelData* lowLevelData, btCollisionConfiguration* collisionConfiguration, int maxNumManifolds);
\r
92 virtual ~btLowLevelCollisionDispatcher();
\r
94 bool supportsDispatchPairOnSpu(int proxyType0,int proxyType1);
\r
96 virtual void dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;
\r
100 virtual btPersistentManifold* getNewManifold(void* b0,void* b1)
\r
105 virtual void releaseManifold(btPersistentManifold* manifold);
\r
108 virtual void* allocateCollisionAlgorithm(int size)
\r
114 virtual void freeCollisionAlgorithm(void* ptr)
\r
125 #endif //BT_LOW_LEVEL_COLLISION__DISPATCHER_H
\r