diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2006-11-21 03:03:56 +0300 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2006-11-21 03:03:56 +0300 |
commit | d58670ddd2e43c9ba6e56c766827165eb3ba08cb (patch) | |
tree | 96e85d2feeb35a9939297257ceccca9edd6f05b9 /extern/bullet2/src/BulletCollision/CollisionShapes | |
parent | 731e7e3915f35de124ab65b455316e5fd3e60585 (diff) |
catch up with latest Bullet 2.x (not in use yet)
Diffstat (limited to 'extern/bullet2/src/BulletCollision/CollisionShapes')
4 files changed, 62 insertions, 19 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; } } diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h index 0fd3ce177fe..52d925fe714 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btConeShape.h @@ -19,7 +19,7 @@ subject to the following restrictions: #include "btConvexShape.h" #include "BulletCollision/BroadphaseCollision/btBroadphaseProxy.h" // for the types -/// implements cone shape interface +///btConeShape implements a Cone shape, around the Y axis class btConeShape : public btConvexShape { @@ -27,7 +27,7 @@ class btConeShape : public btConvexShape float m_sinAngle; float m_radius; float m_height; - + int m_coneIndices[3]; btVector3 coneLocalSupport(const btVector3& v) const; @@ -76,8 +76,28 @@ public: { return "Cone"; } + + ///choose upAxis index + void setConeUpIndex(int upIndex); + + int getConeUpIndex() const + { + return m_coneIndices[1]; + } }; +///btConeShape implements a Cone shape, around the X axis +class btConeShapeX : public btConeShape +{ + public: + btConeShapeX(btScalar radius,btScalar height); +}; +///btConeShapeZ implements a Cone shape, around the Z axis +class btConeShapeZ : public btConeShape +{ + public: + btConeShapeZ(btScalar radius,btScalar height); +}; #endif //CONE_MINKOWSKI_H diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp index 078ba38fdf4..54864c32f3a 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.cpp @@ -39,3 +39,4 @@ void btTriangleBuffer::processTriangle(btVector3* triangle,int partId,int trian m_triangleBuffer.push_back(tri); } + diff --git a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h index 4f421a616c8..d04341aa809 100644 --- a/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h +++ b/extern/bullet2/src/BulletCollision/CollisionShapes/btTriangleBuffer.h @@ -57,4 +57,5 @@ public: }; -#endif //BT_TRIANGLE_BUFFER_H
\ No newline at end of file +#endif //BT_TRIANGLE_BUFFER_H + |