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