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/btCapsuleShape.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp97
1 files changed, 37 insertions, 60 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
index 864df26e931..7c337742841 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btCapsuleShape.cpp
@@ -13,24 +13,21 @@ subject to the following restrictions:
3. This notice may not be removed or altered from any source distribution.
*/
-
#include "btCapsuleShape.h"
-#include "BulletCollision/CollisionShapes/btCollisionMargin.h"
#include "LinearMath/btQuaternion.h"
-btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape ()
+btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInternalShape()
{
+ m_collisionMargin = radius;
m_shapeType = CAPSULE_SHAPE_PROXYTYPE;
m_upAxis = 1;
- m_implicitShapeDimensions.setValue(radius,0.5f*height,radius);
+ m_implicitShapeDimensions.setValue(radius, 0.5f * height, radius);
}
-
- btVector3 btCapsuleShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0)const
+btVector3 btCapsuleShape::localGetSupportingVertexWithoutMargin(const btVector3& vec0) const
{
-
- btVector3 supVec(0,0,0);
+ btVector3 supVec(0, 0, 0);
btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
@@ -38,24 +35,22 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
btScalar lenSqr = vec.length2();
if (lenSqr < btScalar(0.0001))
{
- vec.setValue(1,0,0);
- } else
+ vec.setValue(1, 0, 0);
+ }
+ else
{
- btScalar rlen = btScalar(1.) / btSqrt(lenSqr );
+ btScalar rlen = btScalar(1.) / btSqrt(lenSqr);
vec *= rlen;
}
btVector3 vtx;
btScalar newDot;
-
- btScalar radius = getRadius();
-
{
- btVector3 pos(0,0,0);
+ btVector3 pos(0, 0, 0);
pos[getUpAxis()] = getHalfHeight();
- vtx = pos +vec*(radius) - vec * getMargin();
+ vtx = pos;
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
@@ -64,10 +59,10 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
}
}
{
- btVector3 pos(0,0,0);
+ btVector3 pos(0, 0, 0);
pos[getUpAxis()] = -getHalfHeight();
- vtx = pos +vec*(radius) - vec * getMargin();
+ vtx = pos;
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
@@ -77,16 +72,11 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
}
return supVec;
-
}
- void btCapsuleShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors,btVector3* supportVerticesOut,int numVectors) const
+void btCapsuleShape::batchedUnitVectorGetSupportingVertexWithoutMargin(const btVector3* vectors, btVector3* supportVerticesOut, int numVectors) const
{
-
-
- btScalar radius = getRadius();
-
- for (int j=0;j<numVectors;j++)
+ for (int j = 0; j < numVectors; j++)
{
btScalar maxDot(btScalar(-BT_LARGE_FLOAT));
const btVector3& vec = vectors[j];
@@ -94,9 +84,9 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
btVector3 vtx;
btScalar newDot;
{
- btVector3 pos(0,0,0);
+ btVector3 pos(0, 0, 0);
pos[getUpAxis()] = getHalfHeight();
- vtx = pos +vec*(radius) - vec * getMargin();
+ vtx = pos;
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
@@ -105,9 +95,9 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
}
}
{
- btVector3 pos(0,0,0);
+ btVector3 pos(0, 0, 0);
pos[getUpAxis()] = -getHalfHeight();
- vtx = pos +vec*(radius) - vec * getMargin();
+ vtx = pos;
newDot = vec.dot(vtx);
if (newDot > maxDot)
{
@@ -115,57 +105,44 @@ btCapsuleShape::btCapsuleShape(btScalar radius, btScalar height) : btConvexInter
supportVerticesOut[j] = vtx;
}
}
-
}
}
-
-void btCapsuleShape::calculateLocalInertia(btScalar mass,btVector3& inertia) const
+void btCapsuleShape::calculateLocalInertia(btScalar mass, btVector3& inertia) const
{
//as an approximation, take the inertia of the box that bounds the spheres
btTransform ident;
ident.setIdentity();
-
btScalar radius = getRadius();
- btVector3 halfExtents(radius,radius,radius);
- halfExtents[getUpAxis()]+=getHalfHeight();
-
- btScalar margin = CONVEX_DISTANCE_MARGIN;
+ btVector3 halfExtents(radius, radius, radius);
+ halfExtents[getUpAxis()] += getHalfHeight();
- btScalar lx=btScalar(2.)*(halfExtents[0]+margin);
- btScalar ly=btScalar(2.)*(halfExtents[1]+margin);
- btScalar lz=btScalar(2.)*(halfExtents[2]+margin);
- const btScalar x2 = lx*lx;
- const btScalar y2 = ly*ly;
- const btScalar z2 = lz*lz;
+ btScalar lx = btScalar(2.) * (halfExtents[0]);
+ btScalar ly = btScalar(2.) * (halfExtents[1]);
+ btScalar lz = btScalar(2.) * (halfExtents[2]);
+ const btScalar x2 = lx * lx;
+ const btScalar y2 = ly * ly;
+ const btScalar z2 = lz * lz;
const btScalar scaledmass = mass * btScalar(.08333333);
- inertia[0] = scaledmass * (y2+z2);
- inertia[1] = scaledmass * (x2+z2);
- inertia[2] = scaledmass * (x2+y2);
-
+ inertia[0] = scaledmass * (y2 + z2);
+ inertia[1] = scaledmass * (x2 + z2);
+ inertia[2] = scaledmass * (x2 + y2);
}
-btCapsuleShapeX::btCapsuleShapeX(btScalar radius,btScalar height)
+btCapsuleShapeX::btCapsuleShapeX(btScalar radius, btScalar height)
{
+ m_collisionMargin = radius;
m_upAxis = 0;
- m_implicitShapeDimensions.setValue(0.5f*height, radius,radius);
+ m_implicitShapeDimensions.setValue(0.5f * height, radius, radius);
}
-
-
-
-
-
-btCapsuleShapeZ::btCapsuleShapeZ(btScalar radius,btScalar height)
+btCapsuleShapeZ::btCapsuleShapeZ(btScalar radius, btScalar height)
{
+ m_collisionMargin = radius;
m_upAxis = 2;
- m_implicitShapeDimensions.setValue(radius,radius,0.5f*height);
+ m_implicitShapeDimensions.setValue(radius, radius, 0.5f * height);
}
-
-
-
-