Back to index

supertuxkart  0.5+dfsg1
btUniformScalingShape.cpp
Go to the documentation of this file.
00001 /*
00002 Bullet Continuous Collision Detection and Physics Library
00003 Copyright (c) 2003-2007 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 "btUniformScalingShape.h"
00017 
00018 btUniformScalingShape::btUniformScalingShape(    btConvexShape* convexChildShape,btScalar uniformScalingFactor):
00019 m_childConvexShape(convexChildShape),
00020 m_uniformScalingFactor(uniformScalingFactor)
00021 {
00022 }
00023        
00024 btUniformScalingShape::~btUniformScalingShape()
00025 {
00026 }
00027        
00028 
00029 btVector3     btUniformScalingShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
00030 {
00031        btVector3 tmpVertex;
00032        tmpVertex = m_childConvexShape->localGetSupportingVertexWithoutMargin(vec);
00033        return tmpVertex*m_uniformScalingFactor;
00034 }
00035 
00036 void   btUniformScalingShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
00037 {
00038        m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors,supportVerticesOut,numVectors);
00039        int i;
00040        for (i=0;i<numVectors;i++)
00041        {
00042               supportVerticesOut[i] = supportVerticesOut[i] * m_uniformScalingFactor;
00043        }
00044 }
00045 
00046 
00047 btVector3     btUniformScalingShape::localGetSupportingVertex(const btVector3& vec)const
00048 {
00049        btVector3 tmpVertex;
00050        tmpVertex = m_childConvexShape->localGetSupportingVertex(vec);
00051        return tmpVertex*m_uniformScalingFactor;
00052 }
00053 
00054 
00055 void   btUniformScalingShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
00056 {
00057 
00059        btVector3 tmpInertia;
00060        m_childConvexShape->calculateLocalInertia(mass,tmpInertia);
00061        inertia = tmpInertia * m_uniformScalingFactor;
00062 }
00063 
00064 
00066 void btUniformScalingShape::getAabb(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
00067 {
00068        m_childConvexShape->getAabb(t,aabbMin,aabbMax);
00069        btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
00070        btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
00071 
00072        aabbMin = aabbCenter - scaledAabbHalfExtends;
00073        aabbMax = aabbCenter + scaledAabbHalfExtends;
00074 
00075 }
00076 
00077 void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
00078 {
00079        m_childConvexShape->getAabbSlow(t,aabbMin,aabbMax);
00080        btVector3 aabbCenter = (aabbMax+aabbMin)*btScalar(0.5);
00081        btVector3 scaledAabbHalfExtends = (aabbMax-aabbMin)*btScalar(0.5)*m_uniformScalingFactor;
00082 
00083        aabbMin = aabbCenter - scaledAabbHalfExtends;
00084        aabbMax = aabbCenter + scaledAabbHalfExtends;
00085 }
00086 
00087 void   btUniformScalingShape::setLocalScaling(const btVector3& scaling) 
00088 {
00089        m_childConvexShape->setLocalScaling(scaling);
00090 }
00091 
00092 const btVector3& btUniformScalingShape::getLocalScaling() const
00093 {
00094        return m_childConvexShape->getLocalScaling();
00095 }
00096 
00097 void   btUniformScalingShape::setMargin(btScalar margin)
00098 {
00099        m_childConvexShape->setMargin(margin);
00100 }
00101 btScalar      btUniformScalingShape::getMargin() const
00102 {
00103        return m_childConvexShape->getMargin() * m_uniformScalingFactor;
00104 }
00105 
00106 int           btUniformScalingShape::getNumPreferredPenetrationDirections() const
00107 {
00108        return m_childConvexShape->getNumPreferredPenetrationDirections();
00109 }
00110        
00111 void   btUniformScalingShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
00112 {
00113        m_childConvexShape->getPreferredPenetrationDirection(index,penetrationVector);
00114 }