diff options
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h')
-rw-r--r-- | extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h index a404504ba86..c35f7512663 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.h @@ -16,15 +16,20 @@ subject to the following restrictions: #ifndef BU_SHAPE #define BU_SHAPE -#include <LinearMath/btPoint3.h> -#include <LinearMath/btMatrix3x3.h> -#include <BulletCollision/CollisionShapes/btConvexShape.h> +#include "../../LinearMath/btPoint3.h" +#include "../../LinearMath/btMatrix3x3.h" +#include "btConvexShape.h" ///PolyhedralConvexShape is an interface class for feature based (vertex/edge/face) convex shapes. class btPolyhedralConvexShape : public btConvexShape { +protected: + btVector3 m_localAabbMin; + btVector3 m_localAabbMax; + bool m_isLocalAabbValid; + public: btPolyhedralConvexShape(); @@ -36,6 +41,39 @@ public: virtual void calculateLocalInertia(btScalar mass,btVector3& inertia); + inline void getNonvirtualAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax, btScalar margin) const + { + + //lazy evaluation of local aabb + btAssert(m_isLocalAabbValid); + + btAssert(m_localAabbMin.getX() <= m_localAabbMax.getX()); + btAssert(m_localAabbMin.getY() <= m_localAabbMax.getY()); + btAssert(m_localAabbMin.getZ() <= m_localAabbMax.getZ()); + + + btVector3 localHalfExtents = btScalar(0.5)*(m_localAabbMax-m_localAabbMin); + btVector3 localCenter = btScalar(0.5)*(m_localAabbMax+m_localAabbMin); + + btMatrix3x3 abs_b = trans.getBasis().absolute(); + + btPoint3 center = trans(localCenter); + + btVector3 extent = btVector3(abs_b[0].dot(localHalfExtents), + abs_b[1].dot(localHalfExtents), + abs_b[2].dot(localHalfExtents)); + extent += btVector3(margin,margin,margin); + + aabbMin = center - extent; + aabbMax = center + extent; + + + } + + + virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const; + + void recalcLocalAabb(); virtual int getNumVertices() const = 0 ; virtual int getNumEdges() const = 0; |