1 | /* |
---|
2 | Bullet Continuous Collision Detection and Physics Library - Parallel solver |
---|
3 | Copyright (c) 2007 Starbreeze Studios |
---|
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 | Written by: Marten Svanfeldt |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef SPU_PARALLELSOLVER_H |
---|
19 | #define SPU_PARALLELSOLVER_H |
---|
20 | |
---|
21 | #include "BulletDynamics/ConstraintSolver/btConstraintSolver.h" |
---|
22 | #include "btThreadSupportInterface.h" |
---|
23 | #include "LinearMath/btAlignedObjectArray.h" |
---|
24 | |
---|
25 | class SolverTaskScheduler |
---|
26 | { |
---|
27 | protected: |
---|
28 | class btThreadSupportInterface* m_threadInterface; |
---|
29 | int m_maxNumOutstandingTasks; |
---|
30 | |
---|
31 | unsigned int m_currentTask; |
---|
32 | unsigned int m_numBusyTasks; |
---|
33 | |
---|
34 | btAlignedObjectArray<struct SpuSolverTaskDesc> m_taskDescriptors; |
---|
35 | btAlignedObjectArray<bool> m_taskBusy; |
---|
36 | |
---|
37 | public: |
---|
38 | SolverTaskScheduler (btThreadSupportInterface* threadIf, int maxOutstandingTasks); |
---|
39 | ~SolverTaskScheduler (); |
---|
40 | |
---|
41 | struct SpuSolverTaskDesc* getTask (); |
---|
42 | |
---|
43 | void issueTask(); |
---|
44 | void flushTasks(); |
---|
45 | |
---|
46 | int getMaxOutstandingTasks() |
---|
47 | { |
---|
48 | return m_maxNumOutstandingTasks; |
---|
49 | } |
---|
50 | }; |
---|
51 | |
---|
52 | class btParallelSequentialImpulseSolver : public btConstraintSolver |
---|
53 | { |
---|
54 | protected: |
---|
55 | |
---|
56 | struct SpuSolverHash* m_solverHash; |
---|
57 | btAlignedObjectArray<struct ManifoldCellHolder> m_sortedManifolds; |
---|
58 | btAlignedObjectArray<struct ConstraintCellHolder> m_sortedConstraints; |
---|
59 | btAlignedObjectArray<class btRigidBody*> m_allObjects; |
---|
60 | |
---|
61 | int m_numberOfContacts; |
---|
62 | |
---|
63 | SolverTaskScheduler m_taskScheduler; |
---|
64 | |
---|
65 | public: |
---|
66 | btParallelSequentialImpulseSolver (btThreadSupportInterface* threadIf, int maxOutstandingTasks); |
---|
67 | virtual ~btParallelSequentialImpulseSolver(); |
---|
68 | |
---|
69 | virtual void prepareSolve (int numBodies, int numManifolds); |
---|
70 | virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints, const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher); |
---|
71 | virtual void allSolved (const btContactSolverInfo& info,class btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc); |
---|
72 | virtual void reset (); |
---|
73 | }; |
---|
74 | |
---|
75 | #endif |
---|