Back to index

supertuxkart  0.5+dfsg1
btUprightConstraint.h
Go to the documentation of this file.
00001 /*
00002 
00003 Bullet Continuous Collision Detection and Physics Library
00004 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
00005 
00006 This software is provided 'as-is', without any express or implied warranty.
00007 In no event will the authors be held liable for any damages arising from the use of this software.
00008 Permission is granted to anyone to use this software for any purpose,
00009 including commercial applications, and to alter it and redistribute it freely,
00010 subject to the following restrictions:
00011 
00012 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.
00013 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00014 3. This notice may not be removed or altered from any source distribution.
00015 */
00016 
00017 #ifndef UPRIGHT_CONSTRAINT_H
00018 #define UPRIGHT_CONSTRAINT_H
00019 
00020 #include "LinearMath/btVector3.h"
00021 #include "btJacobianEntry.h"
00022 #include "btTypedConstraint.h"
00023 
00024 class btRigidBody;
00025 
00029 
00030 class btUprightConstraintLimit
00031 {
00032 public:
00033        btVector3   m_axis;
00034        btScalar    m_angle;
00035        btScalar    m_accumulatedImpulse;
00036        btScalar    m_currentLimitError;
00037 };
00038 
00039 class btUprightConstraint : public btTypedConstraint
00040 {
00041 protected:
00042 
00044 
00046     btTransform             m_frameInA;
00047 
00048 
00051     btJacobianEntry     m_jacAng[ 2 ];
00052 
00053 
00054 protected:
00055 
00058        btScalar    m_timeStep;
00059        btScalar    m_ERP;
00060        btScalar    m_bounce;
00061        btScalar    m_damping;
00062        btScalar    m_maxLimitForce;
00063        btScalar    m_limitSoftness;
00064        btScalar      m_hiLimit;
00065        btScalar      m_loLimit;
00066     btScalar    m_disable_time;
00067 
00068        btUprightConstraintLimit    m_limit[ 2 ];
00069 
00071 
00072     btUprightConstraint&      operator=(btUprightConstraint&      other)
00073     {
00074         btAssert(0);
00075         (void) other;
00076         return *this;
00077     }
00078 
00079     void buildAngularJacobian(btJacobianEntry & jacAngular,const btVector3 & jointAxisW);
00080 
00081        void solveAngularLimit(
00082                               btUprightConstraintLimit *limit,
00083                   btScalar timeStep, btScalar jacDiagABInv,
00084                   btRigidBody * body0 );
00085 
00086 public:
00087 
00088     btUprightConstraint(btRigidBody& rbA, const btTransform& frameInA );
00089 
00090        // -PI,+PI                  is the full range
00091        // 0,0                      is no rotation around x or z
00092        // -PI*0.2,+PI*0.2   is a nice bit of tilt
00093        void setLimit( btScalar range )
00094        {
00095               m_loLimit = -range;
00096               m_hiLimit = +range;
00097        }
00098 
00099        // Error correction scaling
00100        // 0 - 1
00101        //
00102        void setErp( btScalar erp )
00103        {
00104               m_ERP = erp;
00105        }
00106        void setBounce( btScalar bounce )
00107        {
00108               m_bounce = bounce;
00109        }
00110        void setMaxLimitForce( btScalar force )
00111        {
00112               m_maxLimitForce = force;
00113        }
00114        void setLimitSoftness( btScalar softness )
00115        {
00116               m_limitSoftness = softness;
00117        }
00118        void setDamping( btScalar damping )
00119        {
00120               m_damping = damping;
00121        }
00122     void setDisableTime( btScalar t )
00123     {
00124         m_disable_time = t;
00125     }
00126 
00127     virtual void  buildJacobian();
00128     virtual void  solveConstraint(btScalar      timeStep);
00129 };
00130 
00131  
00132 
00133 #endif //UPRIGHT_CONSTRAINT_H
00134