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 #include "btTypedConstraint.h"
00025 #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
00026 
00028 class btSequentialImpulseConstraintSolver : public btConstraintSolver
00029 {
00030 protected:
00031 
00032         btConstraintArray                       m_tmpSolverContactConstraintPool;
00033         btConstraintArray                       m_tmpSolverNonContactConstraintPool;
00034         btConstraintArray                       m_tmpSolverContactFrictionConstraintPool;
00035         btAlignedObjectArray<int>       m_orderTmpConstraintPool;
00036         btAlignedObjectArray<int>       m_orderFrictionConstraintPool;
00037         btAlignedObjectArray<btTypedConstraint::btConstraintInfo1> m_tmpConstraintSizesPool;
00038 
00039         btSolverConstraint&     addFrictionConstraint(const btVector3& normalAxis,btRigidBody* solverBodyA,btRigidBody* solverBodyB,int frictionIndex,btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation, btScalar desiredVelocity=0., btScalar cfmSlip=0.);
00040         
00042         unsigned long   m_btSeed2;
00043 
00044 //      void    initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
00045         btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
00046 
00047         void    convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
00048 
00049 
00050         void    resolveSplitPenetrationSIMD(
00051         btRigidBody& body1,
00052         btRigidBody& body2,
00053         const btSolverConstraint& contactConstraint);
00054 
00055         void    resolveSplitPenetrationImpulseCacheFriendly(
00056         btRigidBody& body1,
00057         btRigidBody& body2,
00058         const btSolverConstraint& contactConstraint);
00059 
00060         //internal method
00061         int     getOrInitSolverBody(btCollisionObject& body);
00062 
00063         void    resolveSingleConstraintRowGeneric(btRigidBody& body1,btRigidBody& body2,const btSolverConstraint& contactConstraint);
00064 
00065         void    resolveSingleConstraintRowGenericSIMD(btRigidBody& body1,btRigidBody& body2,const btSolverConstraint& contactConstraint);
00066         
00067         void    resolveSingleConstraintRowLowerLimit(btRigidBody& body1,btRigidBody& body2,const btSolverConstraint& contactConstraint);
00068         
00069         void    resolveSingleConstraintRowLowerLimitSIMD(btRigidBody& body1,btRigidBody& body2,const btSolverConstraint& contactConstraint);
00070                 
00071 protected:
00072         static btRigidBody& getFixedBody()
00073         {
00074                 static btRigidBody s_fixed(0, 0,0);
00075                 s_fixed.setMassProps(btScalar(0.),btVector3(btScalar(0.),btScalar(0.),btScalar(0.)));
00076                 return s_fixed;
00077         }       
00078 
00079 public:
00080 
00081         
00082         btSequentialImpulseConstraintSolver();
00083         virtual ~btSequentialImpulseConstraintSolver();
00084 
00085         virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
00086         
00087         btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00088         btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00089 
00091         virtual void    reset();
00092         
00093         unsigned long btRand2();
00094 
00095         int btRandInt2 (int n);
00096 
00097         void    setRandSeed(unsigned long seed)
00098         {
00099                 m_btSeed2 = seed;
00100         }
00101         unsigned long   getRandSeed() const
00102         {
00103                 return m_btSeed2;
00104         }
00105 
00106 };
00107 
00108 #ifndef BT_PREFER_SIMD
00109 typedef btSequentialImpulseConstraintSolver btSequentialImpulseConstraintSolverPrefered;
00110 #endif
00111 
00112 
00113 #endif //SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00114 

Generated on Mon Feb 15 22:17:06 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1