Back to index

supertuxkart  0.5+dfsg1
btSphereShape.cpp
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
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 
00022 btSphereShape ::btSphereShape (btScalar radius)
00023 {
00024        m_implicitShapeDimensions.setX(radius);
00025 }
00026 
00027 btVector3     btSphereShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
00028 {
00029        (void)vec;
00030        return btVector3(btScalar(0.),btScalar(0.),btScalar(0.));
00031 }
00032 
00033 void   btSphereShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
00034 {
00035        (void)vectors;
00036 
00037        for (int i=0;i<numVectors;i++)
00038        {
00039               supportVerticesOut[i].setValue(btScalar(0.),btScalar(0.),btScalar(0.));
00040        }
00041 }
00042 
00043 
00044 btVector3     btSphereShape::localGetSupportingVertex(const btVector3& vec)const
00045 {
00046        btVector3 supVertex;
00047        supVertex = localGetSupportingVertexWithoutMargin(vec);
00048 
00049        btVector3 vecnorm = vec;
00050        if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
00051        {
00052               vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
00053        } 
00054        vecnorm.normalize();
00055        supVertex+= getMargin() * vecnorm;
00056        return supVertex;
00057 }
00058 
00059 
00060 //broken due to scaling
00061 void btSphereShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
00062 {
00063        const btVector3& center = t.getOrigin();
00064        btVector3 extent(getMargin(),getMargin(),getMargin());
00065        aabbMin = center - extent;
00066        aabbMax = center + extent;
00067 }
00068 
00069 
00070 
00071 void   btSphereShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
00072 {
00073        btScalar elem = btScalar(0.4) * mass * getMargin()*getMargin();
00074        inertia.setValue(elem,elem,elem);
00075 
00076 }
00077