00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef BU_SHAPE
00017 #define BU_SHAPE
00018
00019 #include "LinearMath/btMatrix3x3.h"
00020 #include "btConvexInternalShape.h"
00021
00022
00024 class btPolyhedralConvexShape : public btConvexInternalShape
00025 {
00026
00027 protected:
00028
00029 public:
00030
00031 btPolyhedralConvexShape();
00032
00033
00034
00035 virtual btVector3 localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00036 virtual void batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00037
00038 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00039
00040
00041 virtual int getNumVertices() const = 0 ;
00042 virtual int getNumEdges() const = 0;
00043 virtual void getEdge(int i,btVector3& pa,btVector3& pb) const = 0;
00044 virtual void getVertex(int i,btVector3& vtx) const = 0;
00045 virtual int getNumPlanes() const = 0;
00046 virtual void getPlane(btVector3& planeNormal,btVector3& planeSupport,int i ) const = 0;
00047
00048
00049 virtual bool isInside(const btVector3& pt,btScalar tolerance) const = 0;
00050
00051 };
00052
00053
00055 class btPolyhedralConvexAabbCachingShape : public btPolyhedralConvexShape
00056 {
00057
00058 btVector3 m_localAabbMin;
00059 btVector3 m_localAabbMax;
00060 bool m_isLocalAabbValid;
00061
00062 protected:
00063
00064 void setCachedLocalAabb (const btVector3& aabbMin, const btVector3& aabbMax)
00065 {
00066 m_isLocalAabbValid = true;
00067 m_localAabbMin = aabbMin;
00068 m_localAabbMax = aabbMax;
00069 }
00070
00071 inline void getCachedLocalAabb (btVector3& aabbMin, btVector3& aabbMax) const
00072 {
00073 btAssert(m_isLocalAabbValid);
00074 aabbMin = m_localAabbMin;
00075 aabbMax = m_localAabbMax;
00076 }
00077
00078 public:
00079
00080 btPolyhedralConvexAabbCachingShape();
00081
00082 inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const
00083 {
00084
00085
00086 btAssert(m_isLocalAabbValid);
00087 btTransformAabb(m_localAabbMin,m_localAabbMax,margin,trans,aabbMin,aabbMax);
00088 }
00089
00090 virtual void setLocalScaling(const btVector3& scaling);
00091
00092 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00093
00094 void recalcLocalAabb();
00095
00096 };
00097
00098 #endif //BU_SHAPE