00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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
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
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