Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp52
1 files changed, 41 insertions, 11 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
index 6f2272cc454..bbc4ba62af6 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btPolyhedralConvexShape.cpp
@@ -16,7 +16,10 @@ subject to the following restrictions:
#include <BulletCollision/CollisionShapes/btPolyhedralConvexShape.h>
btPolyhedralConvexShape::btPolyhedralConvexShape()
-:m_optionalHull(0)
+:m_localAabbMin(1,1,1),
+m_localAabbMax(-1,-1,-1),
+m_isLocalAabbValid(false),
+m_optionalHull(0)
{
}
@@ -28,16 +31,16 @@ btVector3 btPolyhedralConvexShape::localGetSupportingVertexWithoutMargin(const b
int i;
btVector3 supVec(0,0,0);
- btScalar maxDot(-1e30f);
+ btScalar maxDot(btScalar(-1e30));
btVector3 vec = vec0;
btScalar lenSqr = vec.length2();
- if (lenSqr < 0.0001f)
+ if (lenSqr < btScalar(0.0001))
{
vec.setValue(1,0,0);
} else
{
- float rlen = 1.f / btSqrt(lenSqr );
+ btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
vec *= rlen;
}
@@ -68,7 +71,7 @@ void btPolyhedralConvexShape::batchedUnitVectorGetSupportingVertexWithoutMargin(
for (i=0;i<numVectors;i++)
{
- supportVerticesOut[i][3] = -1e30f;
+ supportVerticesOut[i][3] = btScalar(-1e30);
}
for (int j=0;j<numVectors;j++)
@@ -96,23 +99,50 @@ void btPolyhedralConvexShape::calculateLocalInertia(btScalar mass,btVector3& ine
{
//not yet, return box inertia
- float margin = getMargin();
+ btScalar margin = getMargin();
btTransform ident;
ident.setIdentity();
btVector3 aabbMin,aabbMax;
getAabb(ident,aabbMin,aabbMax);
- btVector3 halfExtents = (aabbMax-aabbMin)*0.5f;
+ btVector3 halfExtents = (aabbMax-aabbMin)*btScalar(0.5);
- btScalar lx=2.f*(halfExtents.x()+margin);
- btScalar ly=2.f*(halfExtents.y()+margin);
- btScalar lz=2.f*(halfExtents.z()+margin);
+ btScalar lx=btScalar(2.)*(halfExtents.x()+margin);
+ btScalar ly=btScalar(2.)*(halfExtents.y()+margin);
+ btScalar lz=btScalar(2.)*(halfExtents.z()+margin);
const btScalar x2 = lx*lx;
const btScalar y2 = ly*ly;
const btScalar z2 = lz*lz;
- const btScalar scaledmass = mass * 0.08333333f;
+ const btScalar scaledmass = mass * btScalar(0.08333333);
inertia = scaledmass * (btVector3(y2+z2,x2+z2,x2+y2));
}
+
+
+void btPolyhedralConvexShape::getAabb(const btTransform& trans,btVector3& aabbMin,btVector3& aabbMax) const
+{
+ getNonvirtualAabb(trans,aabbMin,aabbMax,getMargin());
+}
+
+
+
+
+void btPolyhedralConvexShape::recalcLocalAabb()
+{
+ m_isLocalAabbValid = true;
+
+ for (int i=0;i<3;i++)
+ {
+ btVector3 vec(btScalar(0.),btScalar(0.),btScalar(0.));
+ vec[i] = btScalar(1.);
+ btVector3 tmp = localGetSupportingVertex(vec);
+ m_localAabbMax[i] = tmp[i]+m_collisionMargin;
+ vec[i] = btScalar(-1.);
+ tmp = localGetSupportingVertex(vec);
+ m_localAabbMin[i] = tmp[i]-m_collisionMargin;
+ }
+}
+
+