updated EPA,

updated user manual (work in progress)
This commit is contained in:
ejcoumans
2006-11-18 03:27:01 +00:00
parent 509ed8f634
commit 3adf09f7e3
6 changed files with 776 additions and 698 deletions

Binary file not shown.

View File

@@ -193,11 +193,15 @@ void DemoApplication::stepBack()
}
void DemoApplication::zoomIn()
{
m_cameraDistance -= 1; updateCamera();
m_cameraDistance -= 0.4; updateCamera();
if (m_cameraDistance < 0.1)
m_cameraDistance = 0.1;
}
void DemoApplication::zoomOut()
{
m_cameraDistance += 1; updateCamera();
m_cameraDistance += 0.4; updateCamera();
}

View File

@@ -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;
}
}

View File

@@ -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

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,8 @@ struct sResults
btVector3 witnesses[2];
btVector3 normal;
btScalar depth;
int epa_iterations;
int gjk_iterations;
};
static bool Collide(btConvexShape* shape0,const btTransform& wtrs0,
btConvexShape* shape1,const btTransform& wtrs1,