1 | /* |
---|
2 | Bullet Continuous Collision Detection and Physics Library |
---|
3 | Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ |
---|
4 | |
---|
5 | This software is provided 'as-is', without any express or implied warranty. |
---|
6 | In no event will the authors be held liable for any damages arising from the use of this software. |
---|
7 | Permission is granted to anyone to use this software for any purpose, |
---|
8 | including commercial applications, and to alter it and redistribute it freely, |
---|
9 | subject to the following restrictions: |
---|
10 | |
---|
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. |
---|
12 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. |
---|
13 | 3. This notice may not be removed or altered from any source distribution. |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef COMPOUND_COLLISION_ALGORITHM_H |
---|
17 | #define COMPOUND_COLLISION_ALGORITHM_H |
---|
18 | |
---|
19 | #include "BulletCollision/BroadphaseCollision/btCollisionAlgorithm.h" |
---|
20 | #include "BulletCollision/BroadphaseCollision/btDispatcher.h" |
---|
21 | #include "BulletCollision/BroadphaseCollision/btBroadphaseInterface.h" |
---|
22 | |
---|
23 | #include "BulletCollision/NarrowPhaseCollision/btPersistentManifold.h" |
---|
24 | class btDispatcher; |
---|
25 | #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" |
---|
26 | #include "btCollisionCreateFunc.h" |
---|
27 | #include "LinearMath/btAlignedObjectArray.h" |
---|
28 | class btDispatcher; |
---|
29 | |
---|
30 | /// btCompoundCollisionAlgorithm supports collision between CompoundCollisionShapes and other collision shapes |
---|
31 | class btCompoundCollisionAlgorithm : public btCollisionAlgorithm |
---|
32 | { |
---|
33 | btAlignedObjectArray<btCollisionAlgorithm*> m_childCollisionAlgorithms; |
---|
34 | bool m_isSwapped; |
---|
35 | |
---|
36 | class btPersistentManifold* m_sharedManifold; |
---|
37 | bool m_ownsManifold; |
---|
38 | |
---|
39 | public: |
---|
40 | |
---|
41 | btCompoundCollisionAlgorithm( const btCollisionAlgorithmConstructionInfo& ci,btCollisionObject* body0,btCollisionObject* body1,bool isSwapped); |
---|
42 | |
---|
43 | virtual ~btCompoundCollisionAlgorithm(); |
---|
44 | |
---|
45 | virtual void processCollision (btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); |
---|
46 | |
---|
47 | btScalar calculateTimeOfImpact(btCollisionObject* body0,btCollisionObject* body1,const btDispatcherInfo& dispatchInfo,btManifoldResult* resultOut); |
---|
48 | |
---|
49 | virtual void getAllContactManifolds(btManifoldArray& manifoldArray) |
---|
50 | { |
---|
51 | int i; |
---|
52 | for (i=0;i<m_childCollisionAlgorithms.size();i++) |
---|
53 | { |
---|
54 | if (m_childCollisionAlgorithms[i]) |
---|
55 | m_childCollisionAlgorithms[i]->getAllContactManifolds(manifoldArray); |
---|
56 | } |
---|
57 | } |
---|
58 | |
---|
59 | struct CreateFunc :public btCollisionAlgorithmCreateFunc |
---|
60 | { |
---|
61 | virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) |
---|
62 | { |
---|
63 | void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); |
---|
64 | return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,false); |
---|
65 | } |
---|
66 | }; |
---|
67 | |
---|
68 | struct SwappedCreateFunc :public btCollisionAlgorithmCreateFunc |
---|
69 | { |
---|
70 | virtual btCollisionAlgorithm* CreateCollisionAlgorithm(btCollisionAlgorithmConstructionInfo& ci, btCollisionObject* body0,btCollisionObject* body1) |
---|
71 | { |
---|
72 | void* mem = ci.m_dispatcher1->allocateCollisionAlgorithm(sizeof(btCompoundCollisionAlgorithm)); |
---|
73 | return new(mem) btCompoundCollisionAlgorithm(ci,body0,body1,true); |
---|
74 | } |
---|
75 | }; |
---|
76 | |
---|
77 | }; |
---|
78 | |
---|
79 | #endif //COMPOUND_COLLISION_ALGORITHM_H |
---|