summaryrefslogtreecommitdiff
path: root/thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp')
-rw-r--r--thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp118
1 files changed, 54 insertions, 64 deletions
diff --git a/thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp b/thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
index b148bbd99a..ed3cd2d259 100644
--- a/thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
+++ b/thirdparty/bullet/BulletCollision/CollisionShapes/btUniformScalingShape.cpp
@@ -15,122 +15,112 @@ subject to the following restrictions:
#include "btUniformScalingShape.h"
-btUniformScalingShape::btUniformScalingShape( btConvexShape* convexChildShape,btScalar uniformScalingFactor):
-btConvexShape (), m_childConvexShape(convexChildShape),
-m_uniformScalingFactor(uniformScalingFactor)
+btUniformScalingShape::btUniformScalingShape(btConvexShape* convexChildShape, btScalar uniformScalingFactor) : btConvexShape(), m_childConvexShape(convexChildShape), m_uniformScalingFactor(uniformScalingFactor)
{
m_shapeType = UNIFORM_SCALING_SHAPE_PROXYTYPE;
}
-
+
btUniformScalingShape::~btUniformScalingShape()
{
}
-
-btVector3 btUniformScalingShape::localGetSupportingVertexWithoutMargin(const btVector3& vec)const
+btVector3 btUniformScalingShape::localGetSupportingVertexWithoutMargin(const btVector3& vec) const
{
btVector3 tmpVertex;
tmpVertex = m_childConvexShape->localGetSupportingVertexWithoutMargin(vec);
- return tmpVertex*m_uniformScalingFactor;
+ return tmpVertex * m_uniformScalingFactor;
}
-void btUniformScalingShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+void btUniformScalingShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors, btVector3* supportVerticesOut, int numVectors) const
{
- m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors,supportVerticesOut,numVectors);
+ m_childConvexShape->batchedUnitVectorGetSupportingVertexWithoutMargin(vectors, supportVerticesOut, numVectors);
int i;
- for (i=0;i<numVectors;i++)
+ for (i = 0; i < numVectors; i++)
{
supportVerticesOut[i] = supportVerticesOut[i] * m_uniformScalingFactor;
}
}
-
-btVector3 btUniformScalingShape::localGetSupportingVertex(const btVector3& vec)const
+btVector3 btUniformScalingShape::localGetSupportingVertex(const btVector3& vec) const
{
btVector3 tmpVertex;
tmpVertex = m_childConvexShape->localGetSupportingVertex(vec);
- return tmpVertex*m_uniformScalingFactor;
+ return tmpVertex * m_uniformScalingFactor;
}
-
-void btUniformScalingShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+void btUniformScalingShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const
{
-
///this linear upscaling is not realistic, but we don't deal with large mass ratios...
btVector3 tmpInertia;
- m_childConvexShape->calculateLocalInertia(mass,tmpInertia);
+ m_childConvexShape->calculateLocalInertia(mass, tmpInertia);
inertia = tmpInertia * m_uniformScalingFactor;
}
-
- ///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
-void btUniformScalingShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+///getAabb's default implementation is brute force, expected derived classes to implement a fast dedicated version
+void btUniformScalingShape::getAabb(const btTransform& trans, btVector3& aabbMin, btVector3& aabbMax) const
{
- getAabbSlow(trans,aabbMin,aabbMax);
-
+ getAabbSlow(trans, aabbMin, aabbMax);
}
-void btUniformScalingShape::getAabbSlow(const btTransform& t,btVector3& aabbMin,btVector3& aabbMax) const
+void btUniformScalingShape::getAabbSlow(const btTransform& t, btVector3& aabbMin, btVector3& aabbMax) const
{
#if 1
btVector3 _directions[] =
- {
- btVector3( 1., 0., 0.),
- btVector3( 0., 1., 0.),
- btVector3( 0., 0., 1.),
- btVector3( -1., 0., 0.),
- btVector3( 0., -1., 0.),
- btVector3( 0., 0., -1.)
- };
-
+ {
+ btVector3(1., 0., 0.),
+ btVector3(0., 1., 0.),
+ btVector3(0., 0., 1.),
+ btVector3(-1., 0., 0.),
+ btVector3(0., -1., 0.),
+ btVector3(0., 0., -1.)};
+
btVector3 _supporting[] =
+ {
+ btVector3(0., 0., 0.),
+ btVector3(0., 0., 0.),
+ btVector3(0., 0., 0.),
+ btVector3(0., 0., 0.),
+ btVector3(0., 0., 0.),
+ btVector3(0., 0., 0.)};
+
+ for (int i = 0; i < 6; i++)
{
- btVector3( 0., 0., 0.),
- btVector3( 0., 0., 0.),
- btVector3( 0., 0., 0.),
- btVector3( 0., 0., 0.),
- btVector3( 0., 0., 0.),
- btVector3( 0., 0., 0.)
- };
-
- for (int i=0;i<6;i++)
- {
- _directions[i] = _directions[i]*t.getBasis();
+ _directions[i] = _directions[i] * t.getBasis();
}
-
+
batchedUnitVectorGetSupportingVertexWithoutMargin(_directions, _supporting, 6);
-
- btVector3 aabbMin1(0,0,0),aabbMax1(0,0,0);
- for ( int i = 0; i < 3; ++i )
+ btVector3 aabbMin1(0, 0, 0), aabbMax1(0, 0, 0);
+
+ for (int i = 0; i < 3; ++i)
{
aabbMax1[i] = t(_supporting[i])[i];
aabbMin1[i] = t(_supporting[i + 3])[i];
}
- btVector3 marginVec(getMargin(),getMargin(),getMargin());
- aabbMin = aabbMin1-marginVec;
- aabbMax = aabbMax1+marginVec;
-
+ btVector3 marginVec(getMargin(), getMargin(), getMargin());
+ aabbMin = aabbMin1 - marginVec;
+ aabbMax = aabbMax1 + marginVec;
+
#else
btScalar margin = getMargin();
- for (int i=0;i<3;i++)
+ for (int i = 0; i < 3; i++)
{
- btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+ btVector3 vec(btScalar(0.), btScalar(0.), btScalar(0.));
vec[i] = btScalar(1.);
- btVector3 sv = localGetSupportingVertex(vec*t.getBasis());
+ btVector3 sv = localGetSupportingVertex(vec * t.getBasis());
btVector3 tmp = t(sv);
- aabbMax[i] = tmp[i]+margin;
+ aabbMax[i] = tmp[i] + margin;
vec[i] = btScalar(-1.);
- sv = localGetSupportingVertex(vec*t.getBasis());
+ sv = localGetSupportingVertex(vec * t.getBasis());
tmp = t(sv);
- aabbMin[i] = tmp[i]-margin;
+ aabbMin[i] = tmp[i] - margin;
}
#endif
}
-void btUniformScalingShape::setLocalScaling(const btVector3& scaling)
+void btUniformScalingShape::setLocalScaling(const btVector3& scaling)
{
m_childConvexShape->setLocalScaling(scaling);
}
@@ -140,21 +130,21 @@ const btVector3& btUniformScalingShape::getLocalScaling() const
return m_childConvexShape->getLocalScaling();
}
-void btUniformScalingShape::setMargin(btScalar margin)
+void btUniformScalingShape::setMargin(btScalar margin)
{
m_childConvexShape->setMargin(margin);
}
-btScalar btUniformScalingShape::getMargin() const
+btScalar btUniformScalingShape::getMargin() const
{
return m_childConvexShape->getMargin() * m_uniformScalingFactor;
}
-int btUniformScalingShape::getNumPreferredPenetrationDirections() const
+int btUniformScalingShape::getNumPreferredPenetrationDirections() const
{
return m_childConvexShape->getNumPreferredPenetrationDirections();
}
-
-void btUniformScalingShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
+
+void btUniformScalingShape::getPreferredPenetrationDirection(int index, btVector3& penetrationVector) const
{
- m_childConvexShape->getPreferredPenetrationDirection(index,penetrationVector);
+ m_childConvexShape->getPreferredPenetrationDirection(index, penetrationVector);
}