Bullet Collision Detection & Physics Library
btSequentialImpulseConstraintSolver.h
Go to the documentation of this file.
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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 
16 #ifndef BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
17 #define BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
18 
19 class btIDebugDraw;
21 class btDispatcher;
22 class btCollisionObject;
29 
32 {
33 protected:
39 
46  void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
47  btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
48  btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
49  btScalar desiredVelocity=0., btScalar cfmSlip=0.);
50 
51  void setupRollingFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
52  btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
53  btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
54  btScalar desiredVelocity=0., btScalar cfmSlip=0.);
55 
56  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, btScalar desiredVelocity=0., btScalar cfmSlip=0.);
57  btSolverConstraint& addRollingFrictionConstraint(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, btScalar desiredVelocity=0, btScalar cfmSlip=0.f);
58 
59 
60  void setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp,
61  const btContactSolverInfo& infoGlobal,btScalar& relaxation, const btVector3& rel_pos1, const btVector3& rel_pos2);
62 
63  static void applyAnisotropicFriction(btCollisionObject* colObj,btVector3& frictionDirection, int frictionMode);
64 
65  void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB,
66  btManifoldPoint& cp, const btContactSolverInfo& infoGlobal);
67 
69  unsigned long m_btSeed2;
70 
71 
72  btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
73 
74  virtual void convertContacts(btPersistentManifold** manifoldPtr, int numManifolds, const btContactSolverInfo& infoGlobal);
75 
76  void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
77 
78 
79  void resolveSplitPenetrationSIMD(
80  btSolverBody& bodyA,btSolverBody& bodyB,
81  const btSolverConstraint& contactConstraint);
82 
83  void resolveSplitPenetrationImpulseCacheFriendly(
84  btSolverBody& bodyA,btSolverBody& bodyB,
85  const btSolverConstraint& contactConstraint);
86 
87  //internal method
88  int getOrInitSolverBody(btCollisionObject& body,btScalar timeStep);
89  void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject, btScalar timeStep);
90 
91  void resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
92 
93  void resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
94 
95  void resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
96 
97  void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
98 
99 protected:
100 
101 
102  virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
103  virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal);
104  virtual btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
105 
106  virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
107  virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer);
108 
109 
110 public:
111 
113 
116 
117  virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer,btDispatcher* dispatcher);
118 
119 
120 
122  virtual void reset();
123 
124  unsigned long btRand2();
125 
126  int btRandInt2 (int n);
127 
128  void setRandSeed(unsigned long seed)
129  {
130  m_btSeed2 = seed;
131  }
132  unsigned long getRandSeed() const
133  {
134  return m_btSeed2;
135  }
136 
137 
139  {
141  }
142 };
143 
144 
145 
146 
147 #endif //BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
148 
btPersistentManifold is a contact point cache, it stays persistent as long as objects are overlapping...
btConstraintSolverType
btConstraintSolver provides solver interface
1D constraint along a normal axis between bodyA and bodyB. It can be combined to solve contact and fr...
ManifoldContactPoint collects and maintains persistent contactpoints.
btAlignedObjectArray< btSolverBody > m_tmpSolverBodyPool
btCollisionObject can be used to manage collision detection objects.
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
Definition: btIDebugDraw.h:28
The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (...
btVector3 can be used to represent 3D points and vectors.
Definition: btVector3.h:83
#define ATTRIBUTE_ALIGNED16(a)
Definition: btScalar.h:59
virtual btConstraintSolverType getSolverType() const
The btSolverBody is an internal datastructure for the constraint solver. Only necessary data is packe...
Definition: btSolverBody.h:108
btAlignedObjectArray< btTypedConstraint::btConstraintInfo1 > m_tmpConstraintSizesPool
TypedConstraint is the baseclass for Bullet constraints and vehicles.
#define BT_DECLARE_ALIGNED_ALLOCATOR()
Definition: btScalar.h:357
void resolveSingleConstraintRowGeneric(PfxSolverBody &body1, PfxSolverBody &body2, const btSolverConstraint &c)
unsigned long m_btSeed2
m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction ...
The btDispatcher interface class can be used in combination with broadphase to dispatch calculations ...
Definition: btDispatcher.h:69
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
Definition: btScalar.h:266