27 : m_simplexSolver(simplexSolver),
28 m_penetrationDepthSolver(penetrationDepthSolver),
37 m_penetrationDepthSolver(0),
46 #define MAX_ITERATIONS 64
52 m_simplexSolver->reset();
53 btGjkPairDetector gjk(m_convexA, m_convexB1, m_convexA->getShapeType(), m_convexB1->getShapeType(), m_convexA->getMargin(), m_convexB1->getMargin(), m_simplexSolver, m_penetrationDepthSolver);
55 input.m_transformA = transA;
56 input.m_transformB = transB;
65 const btVector3& planeNormal = planeShape->getPlaneNormal();
66 const btScalar& planeConstant = planeShape->getPlaneConstant();
70 convexInPlaneTrans = transB.inverse() * convexWorldTransform;
72 planeInConvex = convexWorldTransform.inverse() * transB;
74 btVector3 vtx = convexShape->localGetSupportingVertex(planeInConvex.getBasis() * -planeNormal);
76 btVector3 vtxInPlane = convexInPlaneTrans(vtx);
80 btVector3 vtxInPlaneWorld = transB * vtxInPlaneProjected;
81 btVector3 normalOnSurfaceB = transB.getBasis() * planeNormal;
98 btVector3 linVelA, angVelA, linVelB, angVelB;
102 btScalar boundingRadiusA = m_convexA->getAngularMotionDisc();
103 btScalar boundingRadiusB = m_convexB1 ? m_convexB1->getAngularMotionDisc() : 0.f;
105 btScalar maxAngularProjectedVelocity = angVelA.length() * boundingRadiusA + angVelB.length() * boundingRadiusB;
106 btVector3 relLinVel = (linVelB - linVelA);
110 if ((relLinVelocLength + maxAngularProjectedVelocity) == 0.f)
117 bool hasResult =
false;
132 computeClosestPoints(fromA, fromB, pointCollector1);
143 btScalar projectedLinearVelocity = relLinVel.dot(n);
144 if ((projectedLinearVelocity + maxAngularProjectedVelocity) <=
SIMD_EPSILON)
148 while (dist > radius)
156 projectedLinearVelocity = relLinVel.dot(n);
159 if ((projectedLinearVelocity + maxAngularProjectedVelocity) <=
SIMD_EPSILON)
162 dLambda = dist / (projectedLinearVelocity + maxAngularProjectedVelocity);
170 if (lambda <= lastLambda)
179 btTransform interpolatedTransA, interpolatedTransB, relativeTrans;
183 relativeTrans = interpolatedTransB.inverseTimes(interpolatedTransA);
187 result.m_debugDrawer->drawSphere(interpolatedTransA.getOrigin(), 0.2f,
btVector3(1, 0, 0));
193 computeClosestPoints(interpolatedTransA, interpolatedTransB, pointCollector);
203 result.reportFailure(-1, numIter);
210 result.reportFailure(-2, numIter);
215 result.m_fraction = lambda;
btConvexShape()
not supported on IBM SDK, until we fix the alignment of btVector3
float btScalar
The btScalar type abstracts floating point numbers, to easily switch between double and single floati...
#define btSimplexSolverInterface
btStaticPlaneShape(const btVector3 &planeNormal, btScalar planeConstant)
btVector3
btVector3 can be used to represent 3D points and vectors. It has an un-used w component to suit 16-by...
btContinuousConvexCollision(const btConvexShape *shapeA, const btConvexShape *shapeB, btSimplexSolverInterface *simplexSolver, btConvexPenetrationDepthSolver *penetrationDepthSolver)
virtual bool calcTimeOfImpact(const btTransform &fromA, const btTransform &toA, const btTransform &fromB, const btTransform &toB, CastResult &result)
cast a convex against another convex object
ConvexPenetrationDepthSolver provides an interface for penetration depth calculation.
btGjkPairDetector uses GJK to implement the btDiscreteCollisionDetectorInterface
virtual void getClosestPoints(const ClosestPointInput &input, Result &output, class btIDebugDraw *debugDraw, bool swapResults=false)
ccl_global KernelShaderEvalInput * input
T length(const vec_base< T, Size > &a)
T distance(const T &a, const T &b)
btVector3 m_normalOnBInWorld
virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth)