23 #if defined(DEBUG) || defined (_DEBUG) 27 #include <spu_printf.h> 28 #define printf spu_printf 33 #ifdef BT_USE_DOUBLE_PRECISION 34 #define REL_ERROR2 btScalar(1.0e-12) 36 #define REL_ERROR2 btScalar(1.0e-6) 46 m_penetrationDepthSolver(penetrationDepthSolver),
47 m_simplexSolver(simplexSolver),
48 m_minkowskiA(objectA),
49 m_minkowskiB(objectB),
50 m_shapeTypeA(objectA->getShapeType()),
51 m_shapeTypeB(objectB->getShapeType()),
52 m_marginA(objectA->getMargin()),
53 m_marginB(objectB->getMargin()),
54 m_ignoreMargin(false),
56 m_catchDegeneracies(1),
57 m_fixContactNormalDirection(1)
99 localTransA.
getOrigin() -= positionOffset;
100 localTransB.
getOrigin() -= positionOffset;
117 int gGjkMaxIter = 1000;
120 bool isValid =
false;
121 bool checkSimplex =
false;
122 bool checkPenetration =
true;
131 btScalar margin = marginA + marginB;
178 btScalar f0 = squaredDistance - delta;
214 btScalar previousSquaredDistance = squaredDistance;
215 squaredDistance = newCachedSeparatingAxis.
length2();
217 if (squaredDistance>previousSquaredDistance)
221 squaredDistance = previousSquaredDistance;
222 checkSimplex =
false;
231 if (previousSquaredDistance - squaredDistance <=
SIMD_EPSILON * previousSquaredDistance)
245 #if defined(DEBUG) || defined (_DEBUG) 247 printf(
"btGjkPairDetector maxIter exceeded:%i\n",
m_curIter);
248 printf(
"sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n",
296 distance = ((
btScalar(1.)/rlen) - margin);
306 bool catchDegeneratePenetrationCase =
310 if (checkPenetration && (!isValid || catchDegeneratePenetrationCase ))
326 localTransA,localTransB,
334 btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
342 if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
344 tmpNormalInB /=
btSqrt(lenSqr);
348 if (!isValid || (distance2 < distance))
350 distance = distance2;
351 pointOnA = tmpPointOnA;
352 pointOnB = tmpPointOnB;
353 normalInB = tmpNormalInB;
371 d1 = (-normalInB).
dot(w);
385 d0 = normalInB.
dot(w);
418 if (!isValid || (distance2 < distance))
420 distance = distance2;
421 pointOnA = tmpPointOnA;
422 pointOnB = tmpPointOnB;
452 pointOnB+positionOffset,
btConvexPenetrationDepthSolver * m_penetrationDepthSolver
btVector3 m_cachedSeparatingAxis
btSimplexSolverInterface * m_simplexSolver
btGjkPairDetector(const btConvexShape *objectA, const btConvexShape *objectB, btSimplexSolverInterface *simplexSolver, btConvexPenetrationDepthSolver *penetrationDepthSolver)
btScalar length(const btQuaternion &q)
Return the length of a quaternion.
void setValue(const btScalar &_x, const btScalar &_y, const btScalar &_z)
btScalar m_cachedSeparatingDistance
btScalar gGjkEpaPenetrationTolerance
ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
btScalar length2() const
Return the length of the vector squared.
btScalar btSqrt(btScalar y)
const btScalar & getY() const
Return the y value.
btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
The btConvexShape is an abstract shape interface, implemented by all convex shapes such as btBoxShape...
int gNumDeepPenetrationChecks
const btScalar & getZ() const
Return the z value.
virtual bool calcPenDepth(btSimplexSolverInterface &simplexSolver, const btConvexShape *convexA, const btConvexShape *convexB, const btTransform &transA, const btTransform &transB, btVector3 &v, btVector3 &pa, btVector3 &pb, class btIDebugDraw *debugDraw)=0
#define btSimplexSolverInterface
btScalar dot(const btVector3 &v) const
Return the dot product.
int m_fixContactNormalDirection
The btIDebugDraw interface class allows hooking up a debug renderer to visually debug simulations...
const btConvexShape * m_minkowskiB
btVector3 can be used to represent 3D points and vectors.
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)=0
btScalar dot(const btQuaternion &q1, const btQuaternion &q2)
Calculate the dot product between two quaternions.
btVector3 localGetSupportVertexWithoutMarginNonVirtual(const btVector3 &vec) const
const btConvexShape * m_minkowskiA
const btScalar & getX() const
Return the x value.
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
void getClosestPointsNonVirtual(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw)