29#if defined(DEBUG) || defined (_DEBUG)
32#include <spu_printf.h>
33#define printf spu_printf
43#define GJK_MAX_ITERATIONS 128
45#ifdef BT_USE_DOUBLE_PRECISION
46 #define GJK_ACCURACY ((btScalar)1e-12)
47 #define GJK_MIN_DISTANCE ((btScalar)1e-12)
48 #define GJK_DUPLICATED_EPS ((btScalar)1e-12)
50 #define GJK_ACCURACY ((btScalar)0.0001)
51 #define GJK_MIN_DISTANCE ((btScalar)0.0001)
52 #define GJK_DUPLICATED_EPS ((btScalar)0.0001)
56#define GJK_SIMPLEX2_EPS ((btScalar)0.0)
57#define GJK_SIMPLEX3_EPS ((btScalar)0.0)
58#define GJK_SIMPLEX4_EPS ((btScalar)0.0)
61#define EPA_MAX_VERTICES 128
62#define EPA_MAX_ITERATIONS 255
64#ifdef BT_USE_DOUBLE_PRECISION
65 #define EPA_ACCURACY ((btScalar)1e-12)
66 #define EPA_PLANE_EPS ((btScalar)1e-14)
67 #define EPA_INSIDE_EPS ((btScalar)1e-9)
69 #define EPA_ACCURACY ((btScalar)0.0001)
70 #define EPA_PLANE_EPS ((btScalar)0.00001)
71 #define EPA_INSIDE_EPS ((btScalar)0.01)
74#define EPA_FALLBACK (10*EPA_ACCURACY)
75#define EPA_MAX_FACES (EPA_MAX_VERTICES*2)
79 typedef unsigned int U;
80 typedef unsigned char U1;
248 {
found=
true;
break; }
406 return( a.
y()*b.
z()*c.
x()+a.
z()*b.
x()*c.
y()-
407 a.
x()*b.
z()*c.
y()-a.
y()*b.
x()*c.
z()+
408 a.
x()*b.
y()*c.
z()-a.
z()*b.
y()*c.
x());
419 if(
t>=1) { w[0]=0;w[1]=1;
m=2;
return(b.
length2()); }
420 else if(
t<=0) { w[0]=1;w[1]=0;
m=1;
return(a.
length2()); }
421 else { w[0]=1-(w[1]=
t);
m=3;
return((a+d*
t).length2()); }
430 static const U imd3[]={1,2,0};
449 m =
static_cast<U>(((
subm&1)?1<<i:0)+((
subm&2)?1<<
j:0));
465 w[2] = 1-(w[0]+w[1]);
477 static const U imd3[]={1,2,0};
497 m =
static_cast<U>((
subm&1?1<<i:0)+
511 w[0] =
det(c,b,d)/
vl;
512 w[1] =
det(a,c,d)/
vl;
513 w[2] =
det(b,a,d)/
vl;
514 w[3] = 1-(w[0]+w[1]+w[2]);
586 face->
l[1] =
list.root;
593 if(face->
l[1]) face->
l[1]->
l[0]=face->
l[0];
594 if(face->
l[0]) face->
l[0]->
l[1]=face->
l[1];
595 if(face==
list.root)
list.root=face->
l[1];
659 best->pass = (
U1)(++pass);
813 static const U i1m3[]={1,2,0};
814 static const U i2m3[]={2,0,1};
878 return(
sizeof(
GJK)+
sizeof(
EPA));
897 for(
U i=0;i<
gjk.m_simplex->rank;++i)
900 w0+=
shape.Support(
gjk.m_simplex->c[i]->d,0)*p;
901 w1+=
shape.Support(-
gjk.m_simplex->c[i]->d,1)*p;
941 for(
U i=0;i<
epa.m_result.rank;++i)
982 for(
U i=0;i<
gjk.m_simplex->rank;++i)
985 w0+=
shape.Support(
gjk.m_simplex->c[i]->d,0)*p;
986 w1+=
shape.Support(-
gjk.m_simplex->c[i]->d,1)*p;
993 shape1.getMarginNonVirtual();
1034#undef GJK_MAX_ITERATIONS
1036#undef GJK_MIN_DISTANCE
1037#undef GJK_DUPLICATED_EPS
1038#undef GJK_SIMPLEX2_EPS
1039#undef GJK_SIMPLEX3_EPS
1040#undef GJK_SIMPLEX4_EPS
1042#undef EPA_MAX_VERTICES
1044#undef EPA_MAX_ITERATIONS
1048#undef EPA_INSIDE_EPS
#define GJK_DUPLICATED_EPS
#define GJK_MAX_ITERATIONS
#define EPA_MAX_ITERATIONS
const T & btMax(const T &a, const T &b)
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
btScalar btSqrt(btScalar y)
btScalar btFabs(btScalar x)
static T sum(const btAlignedObjectArray< T > &items)
btScalar btDot(const btVector3 &v1, const btVector3 &v2)
Return the dot product between two vectors.
btVector3 btCross(const btVector3 &v1, const btVector3 &v2)
Return the cross product of two vectors.
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
btVector3 localGetSupportVertexNonVirtual(const btVector3 &vec) const
btVector3 localGetSupportVertexWithoutMarginNonVirtual(const btVector3 &vec) const
The btMatrix3x3 class implements a 3x3 rotation matrix, to perform linear algebra in combination with...
The btQuaternion implements quaternion to perform linear algebra rotations in combination with btMatr...
The btSphereShape implements an implicit sphere, centered around a local origin with radius.
btVector3 can be used to represent 3D points and vectors.
const btScalar & w() const
Return the w value.
const btScalar & z() const
Return the z value.
btScalar length() const
Return the length of the vector.
btScalar length2() const
Return the length of the vector squared.
const btScalar & x() const
Return the x value.
const btScalar & y() const
Return the y value.
static void Initialize(const btConvexShape *shape0, const btTransform &wtrs0, const btConvexShape *shape1, const btTransform &wtrs1, btGjkEpaSolver2::sResults &results, tShape &shape, bool withmargins)
static btScalar SignedDistance(const btVector3 &position, btScalar margin, const btConvexShape *shape, const btTransform &wtrs, sResults &results)
static bool Penetration(const btConvexShape *shape0, const btTransform &wtrs0, const btConvexShape *shape1, const btTransform &wtrs1, const btVector3 &guess, sResults &results, bool usemargins=true)
static bool Distance(const btConvexShape *shape0, const btTransform &wtrs0, const btConvexShape *shape1, const btTransform &wtrs1, const btVector3 &guess, sResults &results)
static int StackSizeRequirement()
bool expand(U pass, sSV *w, sFace *f, U e, sHorizon &horizon)
static void remove(sList &list, sFace *face)
sSV m_sv_store[EPA_MAX_VERTICES]
eStatus::_ Evaluate(GJK &gjk, const btVector3 &guess)
sFace m_fc_store[EPA_MAX_FACES]
static void append(sList &list, sFace *face)
sFace * newface(sSV *a, sSV *b, sSV *c, bool forced)
static void bind(sFace *fa, U ea, sFace *fb, U eb)
bool getedgedist(sFace *face, sSV *a, sSV *b, btScalar &dist)
void removevertice(sSimplex &simplex)
void getsupport(const btVector3 &d, sSV &sv) const
static btScalar det(const btVector3 &a, const btVector3 &b, const btVector3 &c)
void appendvertice(sSimplex &simplex, const btVector3 &v)
static btScalar projectorigin(const btVector3 &a, const btVector3 &b, const btVector3 &c, btScalar *w, U &m)
static btScalar projectorigin(const btVector3 &a, const btVector3 &b, const btVector3 &c, const btVector3 &d, btScalar *w, U &m)
static btScalar projectorigin(const btVector3 &a, const btVector3 &b, btScalar *w, U &m)
eStatus::_ Evaluate(const tShape &shapearg, const btVector3 &guess)
btVector3 Support0(const btVector3 &d) const
void EnableMargin(bool enable)
const btConvexShape * m_shapes[2]
btVector3 Support1(const btVector3 &d) const
btVector3 Support(const btVector3 &d, U index) const
btVector3(btConvexShape::* Ls)(const btVector3 &) const
btVector3 Support(const btVector3 &d) const