Back to index

supertuxkart  0.5+dfsg1
btConvexInternalShape.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 
00017 #include "btConvexInternalShape.h"
00018 
00019 
00020 btConvexInternalShape::btConvexInternalShape()
00021 : m_localScaling(btScalar(1.),btScalar(1.),btScalar(1.)),
00022 m_collisionMargin(CONVEX_DISTANCE_MARGIN)
00023 {
00024 }
00025 
00026 
00027 void   btConvexInternalShape::setLocalScaling(const btVector3& scaling)
00028 {
00029        m_localScaling = scaling;
00030 }
00031 
00032 
00033 
00034 void   btConvexInternalShape::getAabbSlow(const btTransform& trans,btVector3&minAabb,btVector3&maxAabb) const
00035 {
00036 
00037        btScalar margin = getMargin();
00038        for (int i=0;i<3;i++)
00039        {
00040               btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
00041               vec[i] = btScalar(1.);
00042 
00043               btVector3 sv = localGetSupportingVertex(vec*trans.getBasis());
00044 
00045               btVector3 tmp = trans(sv);
00046               maxAabb[i] = tmp[i]+margin;
00047               vec[i] = btScalar(-1.);
00048               tmp = trans(localGetSupportingVertex(vec*trans.getBasis()));
00049               minAabb[i] = tmp[i]-margin;
00050        }
00051 };
00052 
00053 
00054 btVector3     btConvexInternalShape::localGetSupportingVertex(const btVector3& vec)const
00055 {
00056 #ifndef __SPU__
00057 
00058         btVector3    supVertex = localGetSupportingVertexWithoutMargin(vec);
00059 
00060        if ( getMargin()!=btScalar(0.) )
00061        {
00062               btVector3 vecnorm = vec;
00063               if (vecnorm .length2() < (SIMD_EPSILON*SIMD_EPSILON))
00064               {
00065                      vecnorm.setValue(btScalar(-1.),btScalar(-1.),btScalar(-1.));
00066               } 
00067               vecnorm.normalize();
00068               supVertex+= getMargin() * vecnorm;
00069        }
00070        return supVertex;
00071 
00072 #else
00073        return btVector3(0,0,0);
00074 #endif //__SPU__
00075 
00076  }
00077 
00078