btCollisionShape.h

Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2009 Erwin Coumans  http://bulletphysics.org
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 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" //for the shape types
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 //debugging support
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 };      
00127 
00129 struct  btCollisionShapeData
00130 {
00131         char    *m_name;
00132         int             m_shapeType;
00133         char    m_padding[4];
00134 };
00135 
00136 SIMD_FORCE_INLINE       int     btCollisionShape::calculateSerializeBufferSize() const
00137 {
00138         return sizeof(btCollisionShapeData);
00139 }
00140 
00141 
00142 
00143 #endif //COLLISION_SHAPE_H
00144 

Generated on Mon Feb 15 22:17:02 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1