///return true if it requires a dma transfer back bool ManifoldResultAddContactPoint(const btVector3& normalOnBInWorld, const btVector3& pointInWorld, float depth, btPersistentManifold* manifoldPtr, btTransform& transA, btTransform& transB, btScalar combinedFriction, btScalar combinedRestitution, bool isSwapped) { // float contactTreshold = manifoldPtr->getContactBreakingThreshold(); //spu_printf("SPU: add contactpoint, depth:%f, contactTreshold %f, manifoldPtr %llx\n",depth,contactTreshold,manifoldPtr); #ifdef DEBUG_SPU_COLLISION_DETECTION spu_printf("SPU: contactTreshold %f\n",contactTreshold); #endif //DEBUG_SPU_COLLISION_DETECTION //if (depth > manifoldPtr->getContactBreakingThreshold()) // return false; if (depth > manifoldPtr->getContactProcessingThreshold()) return false; btVector3 pointA; btVector3 localA; btVector3 localB; btVector3 normal; if (isSwapped) { normal = normalOnBInWorld * -1; pointA = pointInWorld + normal * depth; localA = transA.invXform(pointA ); localB = transB.invXform(pointInWorld); } else { normal = normalOnBInWorld; pointA = pointInWorld + normal * depth; localA = transA.invXform(pointA ); localB = transB.invXform(pointInWorld); } btManifoldPoint newPt(localA,localB,normal,depth); newPt.m_positionWorldOnA = pointA; newPt.m_positionWorldOnB = pointInWorld; newPt.m_combinedFriction = combinedFriction; newPt.m_combinedRestitution = combinedRestitution; int insertIndex = manifoldPtr->getCacheEntry(newPt); if (insertIndex >= 0) { // we need to replace the current contact point, otherwise small errors will accumulate (spheres start rolling etc) manifoldPtr->replaceContactPoint(newPt,insertIndex); return true; } else { /* ///@todo: SPU callbacks, either immediate (local on the SPU), or deferred //User can override friction and/or restitution if (gContactAddedCallback && //and if either of the two bodies requires custom material ((m_body0->m_collisionFlags & btCollisionObject::customMaterialCallback) || (m_body1->m_collisionFlags & btCollisionObject::customMaterialCallback))) { //experimental feature info, for per-triangle material etc. (*gContactAddedCallback)(newPt,m_body0,m_partId0,m_index0,m_body1,m_partId1,m_index1); } */ manifoldPtr->addManifoldPoint(newPt); return true; } return false; }