Back to index

supertuxkart  0.5+dfsg1
btTypedConstraint.h
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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 
00016 #ifndef TYPED_CONSTRAINT_H
00017 #define TYPED_CONSTRAINT_H
00018 
00019 class btRigidBody;
00020 #include "LinearMath/btScalar.h"
00021 
00022 enum btTypedConstraintType
00023 {
00024        POINT2POINT_CONSTRAINT_TYPE,
00025        HINGE_CONSTRAINT_TYPE,
00026        CONETWIST_CONSTRAINT_TYPE,
00027        D6_CONSTRAINT_TYPE,
00028        VEHICLE_CONSTRAINT_TYPE,
00029        SLIDER_CONSTRAINT_TYPE,
00030 };
00031 
00033 class btTypedConstraint
00034 {
00035        int    m_userConstraintType;
00036        int    m_userConstraintId;
00037 
00038        btTypedConstraintType m_constraintType;
00039 
00040        btTypedConstraint&   operator=(btTypedConstraint&       other)
00041        {
00042               btAssert(0);
00043               (void) other;
00044               return *this;
00045        }
00046 
00047 protected:
00048        btRigidBody&  m_rbA;
00049        btRigidBody&  m_rbB;
00050        btScalar      m_appliedImpulse;
00051 
00052 
00053 public:
00054 
00055        btTypedConstraint(btTypedConstraintType type);
00056        virtual ~btTypedConstraint() {};
00057        btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA);
00058 
00059        btTypedConstraint(btTypedConstraintType type, btRigidBody& rbA,btRigidBody& rbB);
00060 
00061        virtual void  buildJacobian() = 0;
00062 
00063        virtual       void   solveConstraint(btScalar    timeStep) = 0;
00064 
00065        const btRigidBody& getRigidBodyA() const
00066        {
00067               return m_rbA;
00068        }
00069        const btRigidBody& getRigidBodyB() const
00070        {
00071               return m_rbB;
00072        }
00073 
00074        btRigidBody& getRigidBodyA() 
00075        {
00076               return m_rbA;
00077        }
00078        btRigidBody& getRigidBodyB()
00079        {
00080               return m_rbB;
00081        }
00082 
00083        int getUserConstraintType() const
00084        {
00085               return m_userConstraintType ;
00086        }
00087 
00088        void   setUserConstraintType(int userConstraintType)
00089        {
00090               m_userConstraintType = userConstraintType;
00091        };
00092 
00093        void   setUserConstraintId(int uid)
00094        {
00095               m_userConstraintId = uid;
00096        }
00097        
00098        int getUserConstraintId() const
00099        {
00100               return m_userConstraintId;
00101        }
00102 
00103        int getUid() const
00104        {
00105               return m_userConstraintId;   
00106        } 
00107 
00108        btScalar      getAppliedImpulse() const
00109        {
00110               return m_appliedImpulse;
00111        }
00112 
00113        btTypedConstraintType getConstraintType () const
00114        {
00115               return m_constraintType;
00116        }
00117 
00118 };
00119 
00120 #endif //TYPED_CONSTRAINT_H