btStaticPlaneShape.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 BT_STATIC_PLANE_SHAPE_H
00017 #define BT_STATIC_PLANE_SHAPE_H
00018 
00019 #include "btConcaveShape.h"
00020 
00021 
00023 ATTRIBUTE_ALIGNED16(class) btStaticPlaneShape : public btConcaveShape
00024 {
00025 protected:
00026         btVector3       m_localAabbMin;
00027         btVector3       m_localAabbMax;
00028         
00029         btVector3       m_planeNormal;
00030         btScalar      m_planeConstant;
00031         btVector3       m_localScaling;
00032 
00033 public:
00034         BT_DECLARE_ALIGNED_ALLOCATOR();
00035 
00036         btStaticPlaneShape(const btVector3& planeNormal,btScalar planeConstant);
00037 
00038         virtual ~btStaticPlaneShape();
00039 
00040 
00041         virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00042 
00043         virtual void    processAllTriangles(btTriangleCallback* callback,const btVector3& aabbMin,const btVector3& aabbMax) const;
00044 
00045         virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00046 
00047         virtual void    setLocalScaling(const btVector3& scaling);
00048         virtual const btVector3& getLocalScaling() const;
00049         
00050         const btVector3&        getPlaneNormal() const
00051         {
00052                 return  m_planeNormal;
00053         }
00054 
00055         const btScalar& getPlaneConstant() const
00056         {
00057                 return  m_planeConstant;
00058         }
00059 
00060         //debugging
00061         virtual const char*     getName()const {return "STATICPLANE";}
00062 
00063         virtual int     calculateSerializeBufferSize() const;
00064 
00066         virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
00067 
00068 
00069 };
00070 
00072 struct  btStaticPlaneShapeData
00073 {
00074         btCollisionShapeData    m_collisionShapeData;
00075 
00076         btVector3FloatData      m_localScaling;
00077         btVector3FloatData      m_planeNormal;
00078         float                   m_planeConstant;
00079         char    m_pad[4];
00080 };
00081 
00082 
00083 SIMD_FORCE_INLINE       int     btStaticPlaneShape::calculateSerializeBufferSize() const
00084 {
00085         return sizeof(btStaticPlaneShapeData);
00086 }
00087 
00089 SIMD_FORCE_INLINE       const char*     btStaticPlaneShape::serialize(void* dataBuffer, btSerializer* serializer) const
00090 {
00091         btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) dataBuffer;
00092         btCollisionShape::serialize(&planeData->m_collisionShapeData,serializer);
00093 
00094         m_localScaling.serializeFloat(planeData->m_localScaling);
00095         m_planeNormal.serializeFloat(planeData->m_planeNormal);
00096         planeData->m_planeConstant = float(m_planeConstant);
00097                 
00098         return "btStaticPlaneShapeData";
00099 }
00100 
00101 
00102 #endif //BT_STATIC_PLANE_SHAPE_H
00103 
00104 
00105