Tizen 2.1 base
[platform/upstream/libbullet.git] / Extras / PhysicsEffects / include / BulletPhysicsEffects / btLowLevelCollisionDispatcher.h
1 /*\r
2 Bullet Continuous Collision Detection and Physics Library\r
3 Copyright (c) 2003-2007 Erwin Coumans  http://bulletphysics.com\r
4 \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
10 \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
14 */\r
15 #ifndef BT_LOW_LEVEL_COLLISION__DISPATCHER_H\r
16 #define BT_LOW_LEVEL_COLLISION__DISPATCHER_H\r
17 \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
32 \r
33 class btLowLevelCollisionAlgorithm : public btCollisionAlgorithm\r
34 {\r
35         btPersistentManifold* m_manifold;\r
36 \r
37 public:\r
38 \r
39         btLowLevelCollisionAlgorithm()\r
40                 :m_manifold(0)\r
41         {\r
42         }\r
43 \r
44         btLowLevelCollisionAlgorithm(btPersistentManifold* manifold, btCollisionDispatcher* dispatcher)\r
45                 :m_manifold(manifold)\r
46         {\r
47                 m_dispatcher = dispatcher;\r
48         }\r
49         virtual ~btLowLevelCollisionAlgorithm()\r
50         {\r
51                 if (m_manifold)\r
52                         m_dispatcher->releaseManifold(m_manifold);\r
53         }\r
54         virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)\r
55         {\r
56                 btAssert(0);\r
57         }\r
58 \r
59         virtual btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut)\r
60         {\r
61                 btAssert(0);\r
62                 return 0.f;\r
63         }\r
64 \r
65         virtual void    getAllContactManifolds(btManifoldArray& manifoldArray)\r
66         {\r
67                 manifoldArray.push_back(m_manifold);\r
68         }\r
69         \r
70 };\r
71 \r
72 \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
76 {\r
77 \r
78         btLowLevelData* m_lowLevelData;\r
79 \r
80         btAlignedObjectArray<btPersistentManifold>      m_manifoldArray;\r
81         btAlignedObjectArray<btLowLevelCollisionAlgorithm> m_algorithms;\r
82 \r
83 protected:\r
84 \r
85         void    collision();\r
86 \r
87 public:\r
88 \r
89         \r
90         btLowLevelCollisionDispatcher (btLowLevelData* lowLevelData, btCollisionConfiguration* collisionConfiguration, int maxNumManifolds);\r
91         \r
92         virtual ~btLowLevelCollisionDispatcher();\r
93 \r
94         bool    supportsDispatchPairOnSpu(int proxyType0,int proxyType1);\r
95 \r
96         virtual void    dispatchAllCollisionPairs(btOverlappingPairCache* pairCache,const btDispatcherInfo& dispatchInfo,btDispatcher* dispatcher) ;\r
97 \r
98         \r
99 \r
100         virtual btPersistentManifold*   getNewManifold(void* b0,void* b1)\r
101         {\r
102                 btAssert(0);\r
103                 return 0;\r
104         }\r
105         virtual void releaseManifold(btPersistentManifold* manifold);\r
106 \r
107         \r
108         virtual void* allocateCollisionAlgorithm(int size)\r
109         {\r
110                 btAssert(0);\r
111                 return 0;\r
112         }\r
113 \r
114         virtual void freeCollisionAlgorithm(void* ptr)\r
115         {\r
116 \r
117         }\r
118 \r
119 \r
120 \r
121 };\r
122 \r
123 \r
124 \r
125 #endif //BT_LOW_LEVEL_COLLISION__DISPATCHER_H\r
126 \r
127 \r