btSphereShape.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 #ifndef BT_SPHERE_MINKOWSKI_H
00016 #define BT_SPHERE_MINKOWSKI_H
00017 
00018 #include "btConvexInternalShape.h"
00019 #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types
00020 
00022 ATTRIBUTE_ALIGNED16(class) btSphereShape : public btConvexInternalShape
00023 
00024 {
00025         
00026 public:
00027         BT_DECLARE_ALIGNED_ALLOCATOR();
00028 
00029         btSphereShape (btScalar radius) : btConvexInternalShape ()
00030         {
00031                 m_shapeType = SPHERE_SHAPE_PROXYTYPE;
00032                 m_implicitShapeDimensions.setX(radius);
00033                 m_collisionMargin = radius;
00034         }
00035         
00036         virtual btVector3       localGetSupportingVertex(const btVector3& vec)const;
00037         virtual btVector3       localGetSupportingVertexWithoutMargin(const btVector3& vec)const;
00038         //notice that the vectors should be unit length
00039         virtual void    batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const;
00040 
00041 
00042         virtual void    calculateLocalInertia(btScalar mass,btVector3& inertia) const;
00043 
00044         virtual void getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const;
00045 
00046 
00047         btScalar        getRadius() const { return m_implicitShapeDimensions.getX() * m_localScaling.getX();}
00048 
00049         void    setUnscaledRadius(btScalar      radius)
00050         {
00051                 m_implicitShapeDimensions.setX(radius);
00052                 btConvexInternalShape::setMargin(radius);
00053         }
00054 
00055         //debugging
00056         virtual const char*     getName()const {return "SPHERE";}
00057 
00058         virtual void    setMargin(btScalar margin)
00059         {
00060                 btConvexInternalShape::setMargin(margin);
00061         }
00062         virtual btScalar        getMargin() const
00063         {
00064                 //to improve gjk behaviour, use radius+margin as the full margin, so never get into the penetration case
00065                 //this means, non-uniform scaling is not supported anymore
00066                 return getRadius();
00067         }
00068 
00069 
00070 };
00071 
00072 
00073 #endif //BT_SPHERE_MINKOWSKI_H