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) 37 #define REL_ERROR2 btScalar(1.0e-6) 48 m_penetrationDepthSolver(penetrationDepthSolver),
49 m_simplexSolver(simplexSolver),
50 m_minkowskiA(objectA),
51 m_minkowskiB(objectB),
52 m_shapeTypeA(objectA->getShapeType()),
53 m_shapeTypeB(objectB->getShapeType()),
54 m_marginA(objectA->getMargin()),
55 m_marginB(objectB->getMargin()),
56 m_ignoreMargin(false),
58 m_catchDegeneracies(1),
59 m_fixContactNormalDirection(1)
101 localTransA.
getOrigin() -= positionOffset;
102 localTransB.
getOrigin() -= positionOffset;
119 int gGjkMaxIter = 1000;
122 bool isValid =
false;
123 bool checkSimplex =
false;
124 bool checkPenetration =
true;
133 btScalar margin = marginA + marginB;
180 btScalar f0 = squaredDistance - delta;
216 btScalar previousSquaredDistance = squaredDistance;
217 squaredDistance = newCachedSeparatingAxis.
length2();
219 if (squaredDistance>previousSquaredDistance)
223 squaredDistance = previousSquaredDistance;
224 checkSimplex =
false;
233 if (previousSquaredDistance - squaredDistance <=
SIMD_EPSILON * previousSquaredDistance)
247 #if defined(DEBUG) || defined (_DEBUG) 249 printf(
"btGjkPairDetector maxIter exceeded:%i\n",
m_curIter);
250 printf(
"sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n",
298 distance = ((
btScalar(1.)/rlen) - margin);
308 bool catchDegeneratePenetrationCase =
312 if (checkPenetration && (!isValid || catchDegeneratePenetrationCase ))
328 localTransA,localTransB,
336 btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA;
344 if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON))
346 tmpNormalInB /=
btSqrt(lenSqr);
350 if (!isValid || (distance2 < distance))
352 distance = distance2;
353 pointOnA = tmpPointOnA;
354 pointOnB = tmpPointOnB;
355 normalInB = tmpNormalInB;
381 if (!isValid || (distance2 < distance))
383 distance = distance2;
384 pointOnA = tmpPointOnA;
385 pointOnB = tmpPointOnB;
431 d1 = (-normalInB).
dot(w);
445 d0 = normalInB.
dot(w);
456 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)