Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h @ 5681

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

Update from Bullet 2.73 to 2.74.

  • Property svn:eol-style set to native
File size: 4.5 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
27///The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (iterative LCP) method.
28class btSequentialImpulseConstraintSolver : public btConstraintSolver
29{
30protected:
31
32        btAlignedObjectArray<btSolverBody>      m_tmpSolverBodyPool;
33        btConstraintArray                       m_tmpSolverContactConstraintPool;
34        btConstraintArray                       m_tmpSolverNonContactConstraintPool;
35        btConstraintArray                       m_tmpSolverContactFrictionConstraintPool;
36        btAlignedObjectArray<int>       m_orderTmpConstraintPool;
37        btAlignedObjectArray<int>       m_orderFrictionConstraintPool;
38
39        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);
40       
41        ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction
42        unsigned long   m_btSeed2;
43
44        void    initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
45        btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
46
47        void    convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
48
49        void    resolveSplitPenetrationImpulseCacheFriendly(
50        btSolverBody& body1,
51        btSolverBody& body2,
52        const btSolverConstraint& contactConstraint,
53        const btContactSolverInfo& solverInfo);
54
55        //internal method
56        int     getOrInitSolverBody(btCollisionObject& body);
57
58        void    resolveSingleConstraintRowGeneric(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
59
60        void    resolveSingleConstraintRowGenericSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
61       
62        void    resolveSingleConstraintRowLowerLimit(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
63       
64        void    resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& body1,btSolverBody& body2,const btSolverConstraint& contactConstraint);
65               
66public:
67
68       
69        btSequentialImpulseConstraintSolver();
70        virtual ~btSequentialImpulseConstraintSolver();
71
72        virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
73       
74        btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
75        btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
76
77        ///clear internal cached data and reset random seed
78        virtual void    reset();
79       
80        unsigned long btRand2();
81
82        int btRandInt2 (int n);
83
84        void    setRandSeed(unsigned long seed)
85        {
86                m_btSeed2 = seed;
87        }
88        unsigned long   getRandSeed() const
89        {
90                return m_btSeed2;
91        }
92
93};
94
95#ifndef BT_PREFER_SIMD
96typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
97#endif
98
99
100#endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
101
Note: See TracBrowser for help on using the repository browser.