Back to index

supertuxkart  0.5+dfsg1
btSorLcp.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 #define USE_SOR_SOLVER
00020 #ifdef USE_SOR_SOLVER
00021 
00022 #ifndef SOR_LCP_H
00023 #define SOR_LCP_H
00024 struct btOdeSolverBody;
00025 class btOdeJoint;
00026 #include "LinearMath/btScalar.h"
00027 #include "LinearMath/btAlignedObjectArray.h"
00028 #include "LinearMath/btStackAlloc.h"
00029 
00030 struct btContactSolverInfo;
00031 
00032 
00033 //=============================================================================
00034 class btSorLcpSolver //Remotion: 11.10.2007
00035 {
00036 public:
00037        btSorLcpSolver()
00038        {
00039               dRand2_seed = 0;
00040        }
00041 
00042        void SolveInternal1 (float global_cfm,
00043               float global_erp,
00044               const btAlignedObjectArray<btOdeSolverBody*> &body, int nb,
00045               btAlignedObjectArray<btOdeJoint*> &joint, 
00046               int nj, const btContactSolverInfo& solverInfo,
00047               btStackAlloc* stackAlloc
00048               );
00049 
00050 public: //data
00051        unsigned long dRand2_seed;
00052 
00053 protected: //typedef
00054        typedef const btScalar *dRealPtr;
00055        typedef btScalar *dRealMutablePtr;
00056 
00057 protected: //members
00058        //------------------------------------------------------------------------------
00059        SIMD_FORCE_INLINE unsigned long dRand2()
00060        {
00061               dRand2_seed = (1664525L*dRand2_seed + 1013904223L) & 0xffffffff;
00062               return dRand2_seed;
00063        }
00064        //------------------------------------------------------------------------------
00065        SIMD_FORCE_INLINE int dRandInt2 (int n)
00066        {
00067               float a = float(n) / 4294967296.0f;
00068               return (int) (float(dRand2()) * a);
00069        }
00070        //------------------------------------------------------------------------------
00071        void SOR_LCP(int m, int nb, dRealMutablePtr J, int *jb, 
00072               const btAlignedObjectArray<btOdeSolverBody*> &body,
00073               dRealPtr invI, dRealMutablePtr lambda, dRealMutablePtr invMforce, dRealMutablePtr rhs,
00074               dRealMutablePtr lo, dRealMutablePtr hi, dRealPtr cfm, int *findex,
00075               int numiter,float overRelax,
00076               btStackAlloc* stackAlloc
00077               );
00078 };
00079 
00080 
00081 //=============================================================================
00082 class AutoBlockSa //Remotion: 10.10.2007
00083 {
00084        btStackAlloc* stackAlloc;
00085        btBlock*        saBlock;
00086 public:
00087        AutoBlockSa(btStackAlloc* stackAlloc_)
00088        {
00089               stackAlloc = stackAlloc_;
00090               saBlock = stackAlloc->beginBlock();
00091        }
00092        ~AutoBlockSa()
00093        {
00094               stackAlloc->endBlock(saBlock);
00095        }
00096        //operator btBlock* () { return saBlock; }
00097 };
00098 // //Usage
00099 //void function(btStackAlloc* stackAlloc)
00100 //{
00101 //     AutoBlockSa(stackAlloc);
00102 //   ...
00103 //     if(...) return;
00104 //     return;
00105 //}
00106 //------------------------------------------------------------------------------
00107 
00108 
00109 #endif //SOR_LCP_H
00110 
00111 #endif //USE_SOR_SOLVER
00112