00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00017 #define BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00018
00019 class btIDebugDraw;
00020 class btPersistentManifold;
00021 class btStackAlloc;
00022 class btDispatcher;
00023 class btCollisionObject;
00024 #include "BulletDynamics/ConstraintSolver/btTypedConstraint.h"
00025 #include "BulletDynamics/ConstraintSolver/btContactSolverInfo.h"
00026 #include "BulletDynamics/ConstraintSolver/btSolverBody.h"
00027 #include "BulletDynamics/ConstraintSolver/btSolverConstraint.h"
00028 #include "BulletCollision/NarrowPhaseCollision/btManifoldPoint.h"
00029 #include "BulletDynamics/ConstraintSolver/btConstraintSolver.h"
00030
00032 ATTRIBUTE_ALIGNED16(class) btSequentialImpulseConstraintSolver : public btConstraintSolver
00033 {
00034 protected:
00035 btAlignedObjectArray<btSolverBody> m_tmpSolverBodyPool;
00036 btConstraintArray m_tmpSolverContactConstraintPool;
00037 btConstraintArray m_tmpSolverNonContactConstraintPool;
00038 btConstraintArray m_tmpSolverContactFrictionConstraintPool;
00039 btConstraintArray m_tmpSolverContactRollingFrictionConstraintPool;
00040
00041 btAlignedObjectArray<int> m_orderTmpConstraintPool;
00042 btAlignedObjectArray<int> m_orderNonContactConstraintPool;
00043 btAlignedObjectArray<int> m_orderFrictionConstraintPool;
00044 btAlignedObjectArray<btTypedConstraint::btConstraintInfo1> m_tmpConstraintSizesPool;
00045 int m_maxOverrideNumSolverIterations;
00046
00047 void setupFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
00048 btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
00049 btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
00050 btScalar desiredVelocity=0., btScalar cfmSlip=0.);
00051
00052 void setupRollingFrictionConstraint( btSolverConstraint& solverConstraint, const btVector3& normalAxis,int solverBodyIdA,int solverBodyIdB,
00053 btManifoldPoint& cp,const btVector3& rel_pos1,const btVector3& rel_pos2,
00054 btCollisionObject* colObj0,btCollisionObject* colObj1, btScalar relaxation,
00055 btScalar desiredVelocity=0., btScalar cfmSlip=0.);
00056
00057 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.);
00058 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);
00059
00060
00061 void setupContactConstraint(btSolverConstraint& solverConstraint, int solverBodyIdA, int solverBodyIdB, btManifoldPoint& cp,
00062 const btContactSolverInfo& infoGlobal, btVector3& vel, btScalar& rel_vel, btScalar& relaxation,
00063 btVector3& rel_pos1, btVector3& rel_pos2);
00064
00065 void setFrictionConstraintImpulse( btSolverConstraint& solverConstraint, int solverBodyIdA,int solverBodyIdB,
00066 btManifoldPoint& cp, const btContactSolverInfo& infoGlobal);
00067
00069 unsigned long m_btSeed2;
00070
00071
00072 btScalar restitutionCurve(btScalar rel_vel, btScalar restitution);
00073
00074 void convertContact(btPersistentManifold* manifold,const btContactSolverInfo& infoGlobal);
00075
00076
00077 void resolveSplitPenetrationSIMD(
00078 btSolverBody& bodyA,btSolverBody& bodyB,
00079 const btSolverConstraint& contactConstraint);
00080
00081 void resolveSplitPenetrationImpulseCacheFriendly(
00082 btSolverBody& bodyA,btSolverBody& bodyB,
00083 const btSolverConstraint& contactConstraint);
00084
00085
00086 int getOrInitSolverBody(btCollisionObject& body);
00087 void initSolverBody(btSolverBody* solverBody, btCollisionObject* collisionObject);
00088
00089 void resolveSingleConstraintRowGeneric(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
00090
00091 void resolveSingleConstraintRowGenericSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
00092
00093 void resolveSingleConstraintRowLowerLimit(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
00094
00095 void resolveSingleConstraintRowLowerLimitSIMD(btSolverBody& bodyA,btSolverBody& bodyB,const btSolverConstraint& contactConstraint);
00096
00097 protected:
00098
00099
00100 virtual void solveGroupCacheFriendlySplitImpulseIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00101 virtual btScalar solveGroupCacheFriendlyFinish(btCollisionObject** bodies,int numBodies,const btContactSolverInfo& infoGlobal);
00102 btScalar solveSingleIteration(int iteration, btCollisionObject** bodies ,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00103
00104 virtual btScalar solveGroupCacheFriendlySetup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00105 virtual btScalar solveGroupCacheFriendlyIterations(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& infoGlobal,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc);
00106
00107
00108 public:
00109
00110 BT_DECLARE_ALIGNED_ALLOCATOR();
00111
00112 btSequentialImpulseConstraintSolver();
00113 virtual ~btSequentialImpulseConstraintSolver();
00114
00115 virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info, btIDebugDraw* debugDrawer, btStackAlloc* stackAlloc,btDispatcher* dispatcher);
00116
00117
00118
00120 virtual void reset();
00121
00122 unsigned long btRand2();
00123
00124 int btRandInt2 (int n);
00125
00126 void setRandSeed(unsigned long seed)
00127 {
00128 m_btSeed2 = seed;
00129 }
00130 unsigned long getRandSeed() const
00131 {
00132 return m_btSeed2;
00133 }
00134
00135 };
00136
00137
00138
00139
00140 #endif //BT_SEQUENTIAL_IMPULSE_CONSTRAINT_SOLVER_H
00141