Back to index

supertuxkart  0.5+dfsg1
btSequentialImpulseConstraintSolver.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 */
00015 
00016 #ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00017 #define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00018 
00019 #include "btConstraintSolver.h"
00020 class btIDebugDraw;
00021 #include "btContactConstraint.h"
00022 #include "btSolverBody.h"
00023 #include "btSolverConstraint.h"
00024 
00025 
00030 class btSequentialImpulseConstraintSolver : public btConstraintSolver
00031 {
00032 
00033        btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool;
00034        btAlignedObjectArray<btSolverConstraint>  m_tmpSolverConstraintPool;
00035        btAlignedObjectArray<btSolverConstraint>  m_tmpSolverFrictionConstraintPool;
00036        btAlignedObjectArray<int>   m_orderTmpConstraintPool;
00037        btAlignedObjectArray<int>   m_orderFrictionConstraintPool;
00038 
00039 
00040 protected:
00041        btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
00042        btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
00043        void  prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer);
00044        void   addFrictionConstraint(const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation);
00045 
00046        ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
00047        ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
00048 
00049        //choose between several modes, different friction model etc.
00050        int    m_solverMode;
00052        unsigned long m_btSeed2;
00053 
00054 public:
00055 
00056        enum   eSolverMode
00057        {
00058               SOLVER_RANDMIZE_ORDER = 1,
00059               SOLVER_FRICTION_SEPARATE = 2,
00060               SOLVER_USE_WARMSTARTING = 4,
00061               SOLVER_CACHE_FRIENDLY = 8
00062        };
00063 
00064        btSequentialImpulseConstraintSolver();
00065 
00068        void   setContactSolverFunc(ContactSolverFunc func,int type0,int type1)
00069        {
00070               m_contactDispatch[type0][type1] = func;
00071        }
00072        
00075        void   SetFrictionSolverFunc(ContactSolverFunc func,int type0,int type1)
00076        {
00077               m_frictionDispatch[type0][type1] = func;
00078        }
00079 
00080        virtual ~btSequentialImpulseConstraintSolver();
00081        
00082        virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
00083 
00084        virtual btScalar solveGroupCacheFriendly(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00085        btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00086        btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00087 
00088 
00090        virtual       void   reset();
00091 
00092        btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
00093 
00094 
00095        void   setSolverMode(int mode)
00096        {
00097               m_solverMode = mode;
00098        }
00099 
00100        int    getSolverMode() const
00101        {
00102               return m_solverMode;
00103        }
00104 
00105        unsigned long btRand2();
00106 
00107        int btRandInt2 (int n);
00108 
00109        void   setRandSeed(unsigned long seed)
00110        {
00111               m_btSeed2 = seed;
00112        }
00113        unsigned long getRandSeed() const
00114        {
00115               return m_btSeed2;
00116        }
00117 
00118 };
00119 
00120 #ifndef BT_PREFER_SIMD
00121 typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
00122 #endif
00123 
00124 
00125 #endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00126