btSphereShape.cpp

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 #include "btSphereShape.h"
00017 #include "BulletCollision/CollisionShapes/btCollisionMargin.h"
00018 
00019 #include "LinearMath/btQuaternion.h"
00020 
00021 btVector3       btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
00022 {
00023         (void)vec;
00024         return btVector3(btScalar(0.),btScalar(0.),btScalar(0.));
00025 }
00026 
00027 void    btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
00028 {
00029         (void)vectors;
00030 
00031         for (int i=0;i<numVectors;i++)
00032         {
00033                 supportVerticesOut[i].setValue(btScalar(0.),btScalar(0.),btScalar(0.));
00034         }
00035 }
00036 
00037 
00038 btVector3       btSphereShape::localGetSupportingVertex(const btVector3& vec)const
00039 {
00040         btVector3 supVertex;
00041         supVertex = localGetSupportingVertexWithoutMargin(vec);
00042 
00043         btVector3 vecnorm = vec;
00044         if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
00045         {
00046                 vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
00047         } 
00048         vecnorm.normalize();
00049         supVertex+= getMargin() * vecnorm;
00050         return supVertex;
00051 }
00052 
00053 
00054 //broken due to scaling
00055 void btSphereShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
00056 {
00057         const btVector3& center = t.getOrigin();
00058         btVector3 extent(getMargin(),getMargin(),getMargin());
00059         aabbMin = center - extent;
00060         aabbMax = center + extent;
00061 }
00062 
00063 
00064 
00065 void    btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
00066 {
00067         btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin();
00068         inertia.setValue(elem,elem,elem);
00069 
00070 }
00071