Back to index

supertuxkart  0.5+dfsg1
btOdeQuickstepConstraintSolver.h
Go to the documentation of this file.
00001 /*
00002  * Quickstep constraint solver re-distributed under the ZLib license with permission from Russell L. Smith
00003  * Original version is from Open Dynamics Engine, Copyright (C) 2001,2002 Russell L. Smith.
00004  * All rights reserved.  Email: russ@q12.org   Web: www.q12.org
00005  Bullet Continuous Collision Detection and Physics Library
00006  Bullet is Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00007 
00008 This software is provided 'as-is', without any express or implied warranty.
00009 In no event will the authors be held liable for any damages arising from the use of this software.
00010 Permission is granted to anyone to use this software for any purpose, 
00011 including commercial applications, and to alter it and redistribute it freely, 
00012 subject to the following restrictions:
00013 
00014 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.
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00016 3. This notice may not be removed or altered from any source distribution.
00017 */
00018 
00019 #ifndef ODE_CONSTRAINT_SOLVER_H
00020 #define ODE_CONSTRAINT_SOLVER_H
00021 
00022 #include "BulletDynamics/ConstraintSolver/btConstraintSolver.h"
00023 
00024 #include "LinearMath/btAlignedObjectArray.h"
00025 #include "btOdeContactJoint.h"
00026 #include "btOdeTypedJoint.h"
00027 #include "btOdeSolverBody.h"
00028 #include "btSorLcp.h"
00029 
00030 class btRigidBody;
00031 struct btOdeSolverBody;
00032 class btOdeJoint;
00033 
00036 class btOdeQuickstepConstraintSolver : public btConstraintSolver
00037 {
00038 private:
00039        int           m_CurBody;
00040        int           m_CurJoint;
00041        int           m_CurTypedJoint;
00042 
00043        float  m_cfm;
00044        float  m_erp;
00045 
00046        btSorLcpSolver       m_SorLcpSolver;
00047 
00048        btAlignedObjectArray<btOdeSolverBody*> m_odeBodies;
00049        btAlignedObjectArray<btOdeJoint*>          m_joints;
00050 
00051        btAlignedObjectArray<btOdeSolverBody>  m_SolverBodyArray;
00052        btAlignedObjectArray<btOdeContactJoint>   m_JointArray;
00053        btAlignedObjectArray<btOdeTypedJoint>  m_TypedJointArray;
00054 
00055 
00056 private:
00057        int  ConvertBody(btRigidBody* body,btAlignedObjectArray< btOdeSolverBody*> &bodies,int& numBodies);
00058        void ConvertConstraint(btPersistentManifold* manifold,
00059                                                  btAlignedObjectArray<btOdeJoint*> &joints,int& numJoints,
00060                                                  const btAlignedObjectArray< btOdeSolverBody*> &bodies,
00061                                                  int _bodyId0,int _bodyId1,btIDebugDraw* debugDrawer);
00062 
00063        void ConvertTypedConstraint(
00064                                                  btTypedConstraint * constraint,
00065                                                  btAlignedObjectArray<btOdeJoint*> &joints,int& numJoints,
00066                                                  const btAlignedObjectArray< btOdeSolverBody*> &bodies,int _bodyId0,int _bodyId1,btIDebugDraw* debugDrawer);
00067 
00068 
00069 public:
00070 
00071        btOdeQuickstepConstraintSolver();
00072 
00073        virtual ~btOdeQuickstepConstraintSolver() {}
00074 
00075        virtual btScalar solveGroup(btCollisionObject** bodies,int numBodies,btPersistentManifold** manifold,int numManifolds,btTypedConstraint** constraints,int numConstraints,const btContactSolverInfo& info,btIDebugDraw* debugDrawer,btStackAlloc* stackAlloc,btDispatcher* dispatcher);
00076 
00079        void   setConstraintForceMixing(float cfm) {
00080               m_cfm  = cfm;
00081        }
00082 
00085        void   setErrorReductionParamter(float erp)
00086        {
00087               m_erp = erp;
00088        }
00089 
00091        void reset()
00092        {
00093               m_SorLcpSolver.dRand2_seed = 0;
00094        }
00095 
00096        void   setRandSeed(unsigned long seed)
00097        {
00098               m_SorLcpSolver.dRand2_seed = seed;
00099        }
00100        unsigned long getRandSeed() const
00101        {
00102               return m_SorLcpSolver.dRand2_seed;
00103        }
00104 };
00105 
00106 
00107 
00108 
00109 #endif //ODE_CONSTRAINT_SOLVER_H