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

Generated on Mon Feb 15 22:17:07 2010 for Bullet Collision Detection & Physics Library by  doxygen 1.6.1