Back to index

supertuxkart  0.5+dfsg1
btPolyhedralConvexShape.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 BU_SHAPE
00017 #define BU_SHAPE
00018 
00019 #include "LinearMath/btPoint3.h"
00020 #include "LinearMath/btMatrix3x3.h"
00021 #include "btConvexInternalShape.h"
00022 
00023 
00025 class btPolyhedralConvexShape : public btConvexInternalShape
00026 {
00027 
00028 protected:
00029        btVector3     m_localAabbMin;
00030        btVector3     m_localAabbMax;
00031        bool          m_isLocalAabbValid;
00032 
00033 public:
00034 
00035        btPolyhedralConvexShape();
00036 
00037        //brute force implementations
00038        virtual btVector3    localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00039        virtual void  batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00040        
00041        virtual void  calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00042 
00043 
00044        inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
00045        {
00046 
00047               //lazy evaluation of local aabb
00048               btAssert(m_isLocalAabbValid);
00049 
00050               btAssert(m_localAabbMin.getX() <= m_localAabbMax.getX());
00051               btAssert(m_localAabbMin.getY() <= m_localAabbMax.getY());
00052               btAssert(m_localAabbMin.getZ() <= m_localAabbMax.getZ());
00053 
00054 
00055               btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin);
00056               btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin);
00057               
00058               btMatrix3x3 abs_b = trans.getBasis().absolute();  
00059 
00060               btPoint3 center = trans(localCenter);
00061 
00062               btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents),
00063                         abs_b[1].dot(localHalfExtents),
00064                        abs_b[2].dot(localHalfExtents));
00065               extent += btVector3(margin,margin,margin);
00066 
00067               aabbMin = center - extent;
00068               aabbMax = center + extent;
00069 
00070               
00071        }
00072 
00073        
00074        virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00075 
00076        void   recalcLocalAabb();
00077 
00078        virtual int   getNumVertices() const = 0 ;
00079        virtual int getNumEdges() const = 0;
00080        virtual void getEdge(int i,btPoint3& pa,btPoint3& pb) const = 0;
00081        virtual void getVertex(int i,btPoint3& vtx) const = 0;
00082        virtual int   getNumPlanes() const = 0;
00083        virtual void getPlane(btVector3& planeNormal,btPoint3& planeSupport,int i ) const = 0;
00084 //     virtual int getIndex(int i) const = 0 ; 
00085 
00086        virtual       bool isInside(const btPoint3& pt,btScalar tolerance) const = 0;
00087        
00089        class  Hull*  m_optionalHull;
00090 
00091 };
00092 
00093 #endif //BU_SHAPE