[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / BulletCollision / CollisionDispatch / btSimulationIslandManager.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  https://bulletphysics.org
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 BT_SIMULATION_ISLAND_MANAGER_H
17 #define BT_SIMULATION_ISLAND_MANAGER_H
18
19 #include "BulletCollision/CollisionDispatch/btUnionFind.h"
20 #include "btCollisionCreateFunc.h"
21 #include "LinearMath/btAlignedObjectArray.h"
22 #include "btCollisionObject.h"
23
24 class btCollisionObject;
25 class btCollisionWorld;
26 class btDispatcher;
27 class btPersistentManifold;
28
29 ///SimulationIslandManager creates and handles simulation islands, using btUnionFind
30 class btSimulationIslandManager
31 {
32         btUnionFind m_unionFind;
33
34         btAlignedObjectArray<btPersistentManifold*> m_islandmanifold;
35         btAlignedObjectArray<btCollisionObject*> m_islandBodies;
36
37         bool m_splitIslands;
38
39 public:
40         btSimulationIslandManager();
41         virtual ~btSimulationIslandManager();
42
43         void initUnionFind(int n);
44
45         btUnionFind& getUnionFind() { return m_unionFind; }
46
47         virtual void updateActivationState(btCollisionWorld* colWorld, btDispatcher* dispatcher);
48         virtual void storeIslandActivationState(btCollisionWorld* world);
49
50         void findUnions(btDispatcher* dispatcher, btCollisionWorld* colWorld);
51
52         struct IslandCallback
53         {
54                 virtual ~IslandCallback(){};
55
56                 virtual void processIsland(btCollisionObject** bodies, int numBodies, class btPersistentManifold** manifolds, int numManifolds, int islandId) = 0;
57         };
58
59         void buildAndProcessIslands(btDispatcher* dispatcher, btCollisionWorld* collisionWorld, IslandCallback* callback);
60     
61         void buildIslands(btDispatcher* dispatcher, btCollisionWorld* colWorld);
62
63     void processIslands(btDispatcher* dispatcher, btCollisionWorld* collisionWorld, IslandCallback* callback);
64     
65         bool getSplitIslands()
66         {
67                 return m_splitIslands;
68         }
69         void setSplitIslands(bool doSplitIslands)
70         {
71                 m_splitIslands = doSplitIslands;
72         }
73 };
74
75 #endif  //BT_SIMULATION_ISLAND_MANAGER_H