btMultiSphereShape.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_MULTI_SPHERE_MINKOWSKI_H
00017 #define BT_MULTI_SPHERE_MINKOWSKI_H
00018 
00019 #include "btConvexInternalShape.h"
00020 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
00021 #include "LinearMath/btAlignedObjectArray.h"
00022 #include "LinearMath/btAabbUtil2.h"
00023 
00024 
00025 
00028 ATTRIBUTE_ALIGNED16(class) btMultiSphereShape : public btConvexInternalAabbCachingShape
00029 {
00030         
00031         btAlignedObjectArray<btVector3> m_localPositionArray;
00032         btAlignedObjectArray<btScalar>  m_radiArray;
00033         
00034 public:
00035         BT_DECLARE_ALIGNED_ALLOCATOR();
00036         
00037         btMultiSphereShape (const btVector3* positions,const btScalar* radi,int numSpheres);
00038 
00040         virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00041 
00043         virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00044 
00045         virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00046         
00047         int     getSphereCount() const
00048         {
00049                 return m_localPositionArray.size();
00050         }
00051 
00052         const btVector3&        getSpherePosition(int index) const
00053         {
00054                 return m_localPositionArray[index];
00055         }
00056 
00057         btScalar        getSphereRadius(int index) const
00058         {
00059                 return m_radiArray[index];
00060         }
00061 
00062 
00063         virtual const char*     getName()const 
00064         {
00065                 return "MultiSphere";
00066         }
00067 
00068         virtual int     calculateSerializeBufferSize() const;
00069 
00071         virtual const char*     serialize(void* dataBuffer, btSerializer* serializer) const;
00072 
00073 
00074 };
00075 
00076 
00077 struct  btPositionAndRadius
00078 {
00079         btVector3FloatData      m_pos;
00080         float           m_radius;
00081 };
00082 
00083 struct  btMultiSphereShapeData
00084 {
00085         btConvexInternalShapeData       m_convexInternalShapeData;
00086 
00087         btPositionAndRadius     *m_localPositionArrayPtr;
00088         int                             m_localPositionArraySize;
00089         char    m_padding[4];
00090 };
00091 
00092 
00093 
00094 SIMD_FORCE_INLINE       int     btMultiSphereShape::calculateSerializeBufferSize() const
00095 {
00096         return sizeof(btMultiSphereShapeData);
00097 }
00098 
00099 
00100 
00101 #endif //BT_MULTI_SPHERE_MINKOWSKI_H