#ifndef B3_NEW_CONTACT_REDUCTION_H #define B3_NEW_CONTACT_REDUCTION_H #include "Bullet3Common/shared/b3Float4.h" #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h" #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h" #define GET_NPOINTS(x) (x).m_worldNormalOnB.w int b3ExtractManifoldSequentialGlobal(__global const b3Float4* p, int nPoints, b3Float4ConstArg nearNormal, b3Int4* contactIdx) { if( nPoints == 0 ) return 0; if (nPoints <=4) return nPoints; if (nPoints >64) nPoints = 64; b3Float4 center = b3MakeFloat4(0,0,0,0); { for (int i=0;i0) { __global b3Float4* pointsIn = &worldVertsB2[pairIndex*vertexFaceCapacity]; b3Float4 normal = -separatingNormals[i]; int nReducedContacts = b3ExtractManifoldSequentialGlobal(pointsIn, nPoints, normal, &contactIdx); int dstIdx; dstIdx = b3AtomicInc( nGlobalContactsOut); //#if 0 b3Assert(dstIdx < contactCapacity); if (dstIdx < contactCapacity) { __global struct b3Contact4Data* c = &globalContactsOut[dstIdx]; c->m_worldNormalOnB = -normal; c->m_restituitionCoeffCmp = (0.f*0xffff);c->m_frictionCoeffCmp = (0.7f*0xffff); c->m_batchIdx = pairIndex; int bodyA = pairs[pairIndex].x; int bodyB = pairs[pairIndex].y; pairs[pairIndex].w = dstIdx; c->m_bodyAPtrAndSignBit = rigidBodies[bodyA].m_invMass==0?-bodyA:bodyA; c->m_bodyBPtrAndSignBit = rigidBodies[bodyB].m_invMass==0?-bodyB:bodyB; c->m_childIndexA =-1; c->m_childIndexB =-1; switch (nReducedContacts) { case 4: c->m_worldPosB[3] = pointsIn[contactIdx.w]; case 3: c->m_worldPosB[2] = pointsIn[contactIdx.z]; case 2: c->m_worldPosB[1] = pointsIn[contactIdx.y]; case 1: c->m_worldPosB[0] = pointsIn[contactIdx.x]; default: { } }; GET_NPOINTS(*c) = nReducedContacts; } //#endif }// if (numContactsOut>0) }// if (hasSeparatingAxis[i]) }// if (i