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:
authorErwin Coumans <blender@erwincoumans.com>2006-11-21 03:03:56 +0300
committerErwin Coumans <blender@erwincoumans.com>2006-11-21 03:03:56 +0300
commitd58670ddd2e43c9ba6e56c766827165eb3ba08cb (patch)
tree96e85d2feeb35a9939297257ceccca9edd6f05b9 /extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
parent731e7e3915f35de124ab65b455316e5fd3e60585 (diff)
catch up with latest Bullet 2.x (not in use yet)
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp')
-rw-r--r--extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp53
1 files changed, 37 insertions, 16 deletions
diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
index 13875fc5fe6..4cf11f1a977 100644
--- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
+++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.cpp
@@ -16,50 +16,71 @@ subject to the following restrictions:
#include "btConeShape.h"
#include "LinearMath/btPoint3.h"
-#ifdef WIN32
-static int coneindices[3] = {1,2,0};
-#else
-static int coneindices[3] = {2,1,0};
-#endif
+
btConeShape::btConeShape (btScalar radius,btScalar height):
m_radius (radius),
m_height(height)
{
+ setConeUpIndex(1);
btVector3 halfExtents;
m_sinAngle = (m_radius / sqrt(m_radius * m_radius + m_height * m_height));
}
+///choose upAxis index
+void btConeShape::setConeUpIndex(int upIndex)
+{
+ switch (upIndex)
+ {
+ case 0:
+ m_coneIndices[0] = 1;
+ m_coneIndices[1] = 0;
+ m_coneIndices[2] = 2;
+ break;
+ case 1:
+ m_coneIndices[0] = 0;
+ m_coneIndices[1] = 1;
+ m_coneIndices[2] = 2;
+ break;
+ case 2:
+ m_coneIndices[0] = 0;
+ m_coneIndices[1] = 2;
+ m_coneIndices[2] = 1;
+ break;
+ default:
+ assert(0);
+ };
+}
btVector3 btConeShape::coneLocalSupport(const btVector3& v) const
{
float halfHeight = m_height * 0.5f;
- if (v[coneindices[1]] > v.length() * m_sinAngle)
+ if (v[m_coneIndices[1]] > v.length() * m_sinAngle)
{
btVector3 tmp;
- tmp[coneindices[0]] = 0.f;
- tmp[coneindices[1]] = halfHeight;
- tmp[coneindices[2]] = 0.f;
+ tmp[m_coneIndices[0]] = 0.f;
+ tmp[m_coneIndices[1]] = halfHeight;
+ tmp[m_coneIndices[2]] = 0.f;
return tmp;
}
else {
- btScalar s = btSqrt(v[coneindices[0]] * v[coneindices[0]] + v[coneindices[2]] * v[coneindices[2]]);
+ btScalar s = btSqrt(v[m_coneIndices[0]] * v[m_coneIndices[0]] + v[m_coneIndices[2]] * v[m_coneIndices[2]]);
if (s > SIMD_EPSILON) {
btScalar d = m_radius / s;
btVector3 tmp;
- tmp[coneindices[0]] = v[coneindices[0]] * d;
- tmp[coneindices[1]] = -halfHeight;
- tmp[coneindices[2]] = v[coneindices[2]] * d;
+ tmp[m_coneIndices[0]] = v[m_coneIndices[0]] * d;
+ tmp[m_coneIndices[1]] = -halfHeight;
+ tmp[m_coneIndices[2]] = v[m_coneIndices[2]] * d;
return tmp;
}
else {
btVector3 tmp;
- tmp[coneindices[0]] = 0.f;
- tmp[coneindices[1]] = -halfHeight;
- tmp[coneindices[2]] = 0.f;
+ tmp[m_coneIndices[0]] = 0.f;
+ tmp[m_coneIndices[1]] = -halfHeight;
+ tmp[m_coneIndices[2]] = 0.f;
return tmp;
}
}