Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/bullet/BulletMultiThreaded/SpuParallelSolver.h @ 1966

Last change on this file since 1966 was 1966, checked in by rgrieder, 16 years ago

Let's go for multithreaded physics!

  • Property svn:eol-style set to native
File size: 2.8 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library - Parallel solver
3Copyright (c) 2007 Starbreeze Studios
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. This notice may not be removed or altered from any source distribution.
14
15Written 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
25class SolverTaskScheduler
26{
27protected:
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
37public:
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
52class btParallelSequentialImpulseSolver : public btConstraintSolver
53{
54protected:
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
65public:
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
Note: See TracBrowser for help on using the repository browser.