Back to index

supertuxkart  0.5+dfsg1
btConeTwistConstraint.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 btConeTwistConstraint is Copyright (c) 2007 Starbreeze Studios
00004 
00005 This software is provided 'as-is', without any express or implied warranty.
00006 In no event will the authors be held liable for any damages arising from the use of this software.
00007 Permission is granted to anyone to use this software for any purpose, 
00008 including commercial applications, and to alter it and redistribute it freely, 
00009 subject to the following restrictions:
00010 
00011 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.
00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
00013 3. This notice may not be removed or altered from any source distribution.
00014 
00015 Written by: Marcus Hennix
00016 */
00017 
00018 
00019 
00020 #ifndef CONETWISTCONSTRAINT_H
00021 #define CONETWISTCONSTRAINT_H
00022 
00023 #include "../../LinearMath/btVector3.h"
00024 #include "btJacobianEntry.h"
00025 #include "btTypedConstraint.h"
00026 
00027 class btRigidBody;
00028 
00029 
00031 class btConeTwistConstraint : public btTypedConstraint
00032 {
00033 #ifdef IN_PARALLELL_SOLVER
00034 public:
00035 #endif
00036        btJacobianEntry      m_jac[3]; //3 orthogonal linear constraints
00037 
00038        btTransform m_rbAFrame; 
00039        btTransform m_rbBFrame;
00040 
00041        btScalar      m_limitSoftness;
00042        btScalar      m_biasFactor;
00043        btScalar      m_relaxationFactor;
00044 
00045        btScalar      m_swingSpan1;
00046        btScalar      m_swingSpan2;
00047        btScalar      m_twistSpan;
00048 
00049        btVector3   m_swingAxis;
00050        btVector3     m_twistAxis;
00051 
00052        btScalar      m_kSwing;
00053        btScalar      m_kTwist;
00054 
00055        btScalar      m_twistLimitSign;
00056        btScalar      m_swingCorrection;
00057        btScalar      m_twistCorrection;
00058 
00059        btScalar      m_accSwingLimitImpulse;
00060        btScalar      m_accTwistLimitImpulse;
00061 
00062        bool          m_angularOnly;
00063        bool          m_solveTwistLimit;
00064        bool          m_solveSwingLimit;
00065 
00066        
00067 public:
00068 
00069        btConeTwistConstraint(btRigidBody& rbA,btRigidBody& rbB,const btTransform& rbAFrame, const btTransform& rbBFrame);
00070        
00071        btConeTwistConstraint(btRigidBody& rbA,const btTransform& rbAFrame);
00072 
00073        btConeTwistConstraint();
00074 
00075        virtual void  buildJacobian();
00076 
00077        virtual       void   solveConstraint(btScalar    timeStep);
00078 
00079        void   updateRHS(btScalar   timeStep);
00080 
00081        const btRigidBody& getRigidBodyA() const
00082        {
00083               return m_rbA;
00084        }
00085        const btRigidBody& getRigidBodyB() const
00086        {
00087               return m_rbB;
00088        }
00089 
00090        void   setAngularOnly(bool angularOnly)
00091        {
00092               m_angularOnly = angularOnly;
00093        }
00094 
00095        void   setLimit(btScalar _swingSpan1,btScalar _swingSpan2,btScalar _twistSpan,  btScalar _softness = 0.8f, btScalar _biasFactor = 0.3f, btScalar _relaxationFactor = 1.0f)
00096        {
00097               m_swingSpan1 = _swingSpan1;
00098               m_swingSpan2 = _swingSpan2;
00099               m_twistSpan  = _twistSpan;
00100 
00101               m_limitSoftness =  _softness;
00102               m_biasFactor = _biasFactor;
00103               m_relaxationFactor = _relaxationFactor;
00104        }
00105 
00106        const btTransform& getAFrame() { return m_rbAFrame; };  
00107        const btTransform& getBFrame() { return m_rbBFrame; };
00108 
00109        inline int getSolveTwistLimit()
00110        {
00111               return m_solveTwistLimit;
00112        }
00113 
00114        inline int getSolveSwingLimit()
00115        {
00116               return m_solveTwistLimit;
00117        }
00118 
00119        inline btScalar getTwistLimitSign()
00120        {
00121               return m_twistLimitSign;
00122        }
00123 
00124 };
00125 
00126 #endif //CONETWISTCONSTRAINT_H