Changeset 2907 for code/branches/questsystem5/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
- Timestamp:
- Apr 8, 2009, 12:36:08 AM (16 years ago)
- Location:
- code/branches/questsystem5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/questsystem5
- Property svn:mergeinfo changed
-
code/branches/questsystem5/src/bullet/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h
r2662 r2907 24 24 25 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 26 27 ///The btSequentialImpulseConstraintSolver is a fast SIMD implementation of the Projected Gauss Seidel (iterative LCP) method. 30 28 class btSequentialImpulseConstraintSolver : public btConstraintSolver 31 29 { 30 protected: 32 31 33 32 btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool; 34 btAlignedObjectArray<btSolverConstraint> m_tmpSolverConstraintPool; 35 btAlignedObjectArray<btSolverConstraint> m_tmpSolverFrictionConstraintPool; 33 btConstraintArray m_tmpSolverContactConstraintPool; 34 btConstraintArray m_tmpSolverNonContactConstraintPool; 35 btConstraintArray m_tmpSolverContactFrictionConstraintPool; 36 36 btAlignedObjectArray<int> m_orderTmpConstraintPool; 37 37 btAlignedObjectArray<int> m_orderFrictionConstraintPool; 38 38 39 40 protected: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 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); 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 40 50 41 ///m_btSeed2 is used for re-arranging the constraint rows. improves convergence/quality of friction 51 42 unsigned long m_btSeed2; 52 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 53 66 public: 54 67 55 68 56 69 btSequentialImpulseConstraintSolver(); 70 virtual ~btSequentialImpulseConstraintSolver(); 57 71 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 } 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); 64 73 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); 74 btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc); 77 75 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 76 81 77 ///clear internal cached data and reset random seed 82 78 virtual void reset(); 83 84 btScalar solveCombinedContactFriction(btRigidBody* body0,btRigidBody* body1, btManifoldPoint& cp, const btContactSolverInfo& info,int iter,btIDebugDraw* debugDrawer);85 86 87 79 88 80 unsigned long btRand2();
Note: See TracChangeset
for help on using the changeset viewer.