Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h @ 2548

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

Merged physics_merge back to presentation branch.

  • Property svn:eol-style set to native
File size: 5.3 KB
Line 
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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*/
15
16#ifndef SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
17#define SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
18
19#include "btConstraintSolver.h"
20class btIDebugDraw;
21#include "btContactConstraint.h"
22#include "btSolverBody.h"
23#include "btSolverConstraint.h"
24
25
26///The btSequentialImpulseConstraintSolver uses a Propagation Method and Sequentially applies impulses
27///The approach is the 3D version of Erin Catto's GDC 2006 tutorial. See http://www.gphysics.com
28///Although Sequential Impulse is more intuitive, it is mathematically equivalent to Projected Successive Overrelaxation (iterative LCP)
29///Applies impulses for combined restitution and penetration recovery and to simulate friction
30class btSequentialImpulseConstraintSolver : public btConstraintSolver
31{
32
33        btAlignedObjectArray<btSolverBody>      m_tmpSolverBodyPool;
34        btAlignedObjectArray<btSolverConstraint>        m_tmpSolverConstraintPool;
35        btAlignedObjectArray<btSolverConstraint>        m_tmpSolverFrictionConstraintPool;
36        btAlignedObjectArray<int>       m_orderTmpConstraintPool;
37        btAlignedObjectArray<int>       m_orderFrictionConstraintPool;
38
39
40protected:
41        btScalar solve(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
42        btScalar solveFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
43        void  prepareConstraints(btPersistentManifold* manifoldPtr, const btContactSolverInfo& info,btIDebugDraw* debugDrawer);
44        btSolverConstraint&     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);
45
46        ContactSolverFunc m_contactDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
47        ContactSolverFunc m_frictionDispatch[MAX_CONTACT_SOLVER_TYPES][MAX_CONTACT_SOLVER_TYPES];
48
49       
50        ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction
51        unsigned long   m_btSeed2;
52
53public:
54
55       
56        btSequentialImpulseConstraintSolver();
57
58        ///Advanced: Override the default contact solving function for contacts, for certain types of rigidbody
59        ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType
60        void    setContactSolverFunc(ContactSolverFunc func,int type0,int type1)
61        {
62                m_contactDispatch[type0][type1] = func;
63        }
64       
65        ///Advanced: Override the default friction solving function for contacts, for certain types of rigidbody
66        ///See btRigidBody::m_contactSolverType and btRigidBody::m_frictionSolverType
67        void    SetFrictionSolverFunc(ContactSolverFunc func,int type0,int type1)
68        {
69                m_frictionDispatch[type0][type1] = func;
70        }
71
72        virtual ~btSequentialImpulseConstraintSolver();
73       
74        virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
75
76        virtual btScalar solveGroupCacheFriendly(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
77        btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
78        btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
79
80
81        ///clear internal cached data and reset random seed
82        virtual void    reset();
83
84        btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);
85
86
87       
88        unsigned long btRand2();
89
90        int btRandInt2 (int n);
91
92        void    setRandSeed(unsigned long seed)
93        {
94                m_btSeed2 = seed;
95        }
96        unsigned long   getRandSeed() const
97        {
98                return m_btSeed2;
99        }
100
101};
102
103#ifndef BT_PREFER_SIMD
104typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
105#endif
106
107
108#endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
109
Note: See TracBrowser for help on using the repository browser.