Back to index

supertuxkart  0.5+dfsg1
btCapsuleShape.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 BT_CAPSULE_SHAPE_H
00017 #define BT_CAPSULE_SHAPE_H
00018 
00019 #include "btConvexInternalShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
00021 
00022 
00026 class btCapsuleShape : public btConvexInternalShape
00027 {
00028 protected:
00029        int    m_upAxis;
00030 
00031 protected:
00033        btCapsuleShape() {};
00034 
00035 public:
00036        btCapsuleShape(btScalar radius,btScalar height);
00037 
00039        virtual void  calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00040 
00042        virtual btVector3    localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00043 
00044        virtual void  batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00045        
00046        virtual int   getShapeType() const { return CAPSULE_SHAPE_PROXYTYPE; }
00047 
00048        virtual void getAabb (const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
00049        {
00050                      btVector3 halfExtents(getRadius(),getRadius(),getRadius());
00051                      halfExtents[m_upAxis] = getRadius() + getHalfHeight();
00052                      btMatrix3x3 abs_b = t.getBasis().absolute();  
00053                      btPoint3 center = t.getOrigin();
00054                      btVector3 extent = btVector3(abs_b[0].dot(halfExtents),abs_b[1].dot(halfExtents),abs_b[2].dot(halfExtents));             
00055                      extent += btVector3(getMargin(),getMargin(),getMargin());
00056                      aabbMin = center - extent;
00057                      aabbMax = center + extent;
00058        }
00059 
00060        virtual const char*  getName()const 
00061        {
00062               return "CapsuleShape";
00063        }
00064 
00065        int    getUpAxis() const
00066        {
00067               return m_upAxis;
00068        }
00069 
00070        btScalar      getRadius() const
00071        {
00072               int radiusAxis = (m_upAxis+2)%3;
00073               return m_implicitShapeDimensions[radiusAxis];
00074        }
00075 
00076        btScalar      getHalfHeight() const
00077        {
00078               return m_implicitShapeDimensions[m_upAxis];
00079        }
00080 
00081 };
00082 
00085 class btCapsuleShapeX : public btCapsuleShape
00086 {
00087 public:
00088 
00089        btCapsuleShapeX(btScalar radius,btScalar height);
00090               
00091        //debugging
00092        virtual const char*  getName()const
00093        {
00094               return "CapsuleX";
00095        }
00096 
00097        
00098 
00099 };
00100 
00103 class btCapsuleShapeZ : public btCapsuleShape
00104 {
00105 public:
00106        btCapsuleShapeZ(btScalar radius,btScalar height);
00107 
00108               //debugging
00109        virtual const char*  getName()const
00110        {
00111               return "CapsuleZ";
00112        }
00113 
00114        
00115 };
00116 
00117 
00118 
00119 #endif //BT_CAPSULE_SHAPE_H