00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef COLLISION_SHAPE_H
00017 #define COLLISION_SHAPE_H
00018
00019 #include "LinearMath/btTransform.h"
00020 #include "LinearMath/btVector3.h"
00021 #include "LinearMath/btMatrix3x3.h"
00022 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h"
00023 class btSerializer;
00024
00025
00027 class btCollisionShape
00028 {
00029 protected:
00030 int m_shapeType;
00031 void* m_userPointer;
00032
00033 public:
00034
00035 btCollisionShape() : m_shapeType (INVALID_SHAPE_PROXYTYPE), m_userPointer(0)
00036 {
00037 }
00038
00039 virtual ~btCollisionShape()
00040 {
00041 }
00042
00044 virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const =0;
00045
00046 virtual void getBoundingSphere(btVector3& center,btScalar& radius) const;
00047
00049 virtual btScalar getAngularMotionDisc() const;
00050
00051 virtual btScalar getContactBreakingThreshold(btScalar defaultContactThresholdFactor) const;
00052
00053
00056 void calculateTemporalAabb(const btTransform& curTrans,const btVector3& linvel,const btVector3& angvel,btScalar timeStep, btVector3& temporalAabbMin,btVector3& temporalAabbMax) const;
00057
00058
00059
00060 SIMD_FORCE_INLINE bool isPolyhedral() const
00061 {
00062 return btBroadphaseProxy::isPolyhedral(getShapeType());
00063 }
00064
00065 SIMD_FORCE_INLINE bool isConvex2d() const
00066 {
00067 return btBroadphaseProxy::isConvex2d(getShapeType());
00068 }
00069
00070 SIMD_FORCE_INLINE bool isConvex() const
00071 {
00072 return btBroadphaseProxy::isConvex(getShapeType());
00073 }
00074 SIMD_FORCE_INLINE bool isConcave() const
00075 {
00076 return btBroadphaseProxy::isConcave(getShapeType());
00077 }
00078 SIMD_FORCE_INLINE bool isCompound() const
00079 {
00080 return btBroadphaseProxy::isCompound(getShapeType());
00081 }
00082
00083 SIMD_FORCE_INLINE bool isSoftBody() const
00084 {
00085 return btBroadphaseProxy::isSoftBody(getShapeType());
00086 }
00087
00089 SIMD_FORCE_INLINE bool isInfinite() const
00090 {
00091 return btBroadphaseProxy::isInfinite(getShapeType());
00092 }
00093
00094 #ifndef __SPU__
00095 virtual void setLocalScaling(const btVector3& scaling) =0;
00096 virtual const btVector3& getLocalScaling() const =0;
00097 virtual void calculateLocalInertia(btScalar mass,btVector3& inertia) const = 0;
00098
00099
00100
00101 virtual const char* getName()const =0 ;
00102 #endif //__SPU__
00103
00104
00105 int getShapeType() const { return m_shapeType; }
00106 virtual void setMargin(btScalar margin) = 0;
00107 virtual btScalar getMargin() const = 0;
00108
00109
00111 void setUserPointer(void* userPtr)
00112 {
00113 m_userPointer = userPtr;
00114 }
00115
00116 void* getUserPointer() const
00117 {
00118 return m_userPointer;
00119 }
00120
00121 virtual int calculateSerializeBufferSize() const;
00122
00124 virtual const char* serialize(void* dataBuffer, btSerializer* serializer) const;
00125
00126 virtual void serializeSingleShape(btSerializer* serializer) const;
00127
00128 };
00129
00131 struct btCollisionShapeData
00132 {
00133 char *m_name;
00134 int m_shapeType;
00135 char m_padding[4];
00136 };
00137
00138 SIMD_FORCE_INLINE int btCollisionShape::calculateSerializeBufferSize() const
00139 {
00140 return sizeof(btCollisionShapeData);
00141 }
00142
00143
00144
00145 #endif //COLLISION_SHAPE_H
00146