btUniformScalingShape.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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 }