Back to index

supertuxkart  0.5+dfsg1
btCylinderShape.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 CYLINDER_MINKOWSKI_H
00017 #define CYLINDER_MINKOWSKI_H
00018 
00019 #include "btBoxShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
00021 #include "LinearMath/btVector3.h"
00022 
00024 class btCylinderShape : public btBoxShape
00025 
00026 {
00027 
00028 protected:
00029 
00030        int    m_upAxis;
00031 
00032 public:
00033        btCylinderShape (const btVector3& halfExtents);
00034        
00036        void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00037 
00038        virtual btVector3    localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00039 
00040        virtual void  batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00041 
00042        virtual btVector3    localGetSupportingVertex(const btVector3& vec) const
00043        {
00044 
00045               btVector3 supVertex;
00046               supVertex = localGetSupportingVertexWithoutMargin(vec);
00047               
00048               if ( getMargin()!=btScalar(0.) )
00049               {
00050                      btVector3 vecnorm = vec;
00051                      if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
00052                      {
00053                             vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
00054                      } 
00055                      vecnorm.normalize();
00056                      supVertex+= getMargin() * vecnorm;
00057               }
00058               return supVertex;
00059        }
00060 
00061 
00062        //use box inertia
00063        //     virtual void  calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00064 
00065        virtual int   getShapeType() const
00066        {
00067               return CYLINDER_SHAPE_PROXYTYPE;
00068        }
00069        
00070        int    getUpAxis() const
00071        {
00072               return m_upAxis;
00073        }
00074 
00075        virtual btScalar getRadius() const
00076        {
00077               return getHalfExtentsWithMargin().getX();
00078        }
00079 
00080        //debugging
00081        virtual const char*  getName()const
00082        {
00083               return "CylinderY";
00084        }
00085 
00086 
00087 
00088 };
00089 
00090 class btCylinderShapeX : public btCylinderShape
00091 {
00092 public:
00093        btCylinderShapeX (const btVector3& halfExtents);
00094 
00095        virtual btVector3    localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00096        virtual void  batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00097        
00098               //debugging
00099        virtual const char*  getName()const
00100        {
00101               return "CylinderX";
00102        }
00103 
00104        virtual btScalar getRadius() const
00105        {
00106               return getHalfExtentsWithMargin().getY();
00107        }
00108 
00109 };
00110 
00111 class btCylinderShapeZ : public btCylinderShape
00112 {
00113 public:
00114        btCylinderShapeZ (const btVector3& halfExtents);
00115 
00116        virtual btVector3    localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00117        virtual void  batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00118 
00119        virtual int   getUpAxis() const
00120        {
00121               return 2;
00122        }
00123               //debugging
00124        virtual const char*  getName()const
00125        {
00126               return "CylinderZ";
00127        }
00128 
00129        virtual btScalar getRadius() const
00130        {
00131               return getHalfExtentsWithMargin().getX();
00132        }
00133 
00134 };
00135 
00136 
00137 #endif //CYLINDER_MINKOWSKI_H
00138