Deterministic simulation for concave and compound collision shapes: added childShapeA/B to b3Contact4 + sort on them

Use tetrahedra instead of barrel for convex demo (until performance for edge-edge is improved)
Increased #overlapping pair capacity from 12 to 16 / objec
This commit is contained in:
erwincoumans
2013-07-17 22:42:50 -07:00
parent ab125fbb6d
commit 733f9027fb
26 changed files with 358 additions and 70 deletions

View File

@@ -51,6 +51,12 @@ static const char* primitiveContactsKernelsCL= \
"\n"
" int m_bodyAPtrAndSignBit;//x:m_bodyAPtr, y:m_bodyBPtr\n"
" int m_bodyBPtrAndSignBit;\n"
"\n"
" int m_childIndexA;\n"
" int m_childIndexB;\n"
" int m_unused1;\n"
" int m_unused2;\n"
"\n"
"} Contact4;\n"
"\n"
"typedef struct \n"
@@ -485,6 +491,9 @@ static const char* primitiveContactsKernelsCL= \
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyIndexA].m_invMass==0?-bodyIndexA:bodyIndexA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;\n"
" c->m_worldPos[0] = pOnB1;\n"
" c->m_childIndexA = -1;\n"
" c->m_childIndexB = -1;\n"
"\n"
" GET_NPOINTS(*c) = 1;\n"
" } \n"
"\n"
@@ -707,6 +716,8 @@ static const char* primitiveContactsKernelsCL= \
" c->m_batchIdx = pairIndex;\n"
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyIndexA].m_invMass==0?-bodyIndexA:bodyIndexA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;\n"
" c->m_childIndexA = -1;\n"
" c->m_childIndexB = -1;\n"
"\n"
" switch (numReducedPoints)\n"
" {\n"
@@ -785,6 +796,8 @@ static const char* primitiveContactsKernelsCL= \
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyIndexA].m_invMass==0?-bodyIndexA:bodyIndexA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;\n"
" c->m_worldPos[0] = pOnB1;\n"
" c->m_childIndexA = -1;\n"
" c->m_childIndexB = -1;\n"
" GET_NPOINTS(*c) = 1;\n"
" }//if (dstIdx < numPairs)\n"
" }//if (hasCollision)\n"
@@ -957,6 +970,8 @@ static const char* primitiveContactsKernelsCL= \
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyA].m_invMass==0?-bodyA:bodyA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyB].m_invMass==0?-bodyB:bodyB;\n"
" c->m_worldPos[0] = contactPosB;\n"
" c->m_childIndexA = -1;\n"
" c->m_childIndexB = -1;\n"
" GET_NPOINTS(*c) = 1;\n"
" }//if (dstIdx < numPairs)\n"
" }//if ( len <= (radiusA+radiusB))\n"
@@ -1165,7 +1180,8 @@ static const char* primitiveContactsKernelsCL= \
" float4 spherePos2,\n"
" float radius,\n"
" float4 pos,\n"
" float4 quat\n"
" float4 quat,\n"
" int faceIndex\n"
" )\n"
"{\n"
"\n"
@@ -1178,7 +1194,7 @@ static const char* primitiveContactsKernelsCL= \
" float4 closestPnt = (float4)(0, 0, 0, 0);\n"
" float4 hitNormalWorld = (float4)(0, 0, 0, 0);\n"
" float minDist = -1000000.f;\n"
" bool bCollide = true;\n"
" bool bCollide = false;\n"
"\n"
" \n"
" //////////////////////////////////////\n"
@@ -1253,11 +1269,12 @@ static const char* primitiveContactsKernelsCL= \
" closestPnt = contactPoint;\n"
" float4 contactToCenter = sphereCenter - contactPoint;\n"
" minDist = length(contactToCenter);\n"
" if (minDist>0.f)\n"
" if (minDist>FLT_EPSILON)\n"
" {\n"
" hitNormalWorld = normalize(contactToCenter);//*(1./minDist);\n"
" bCollide = true;\n"
" }\n"
" bCollide = true;\n"
" \n"
" }\n"
"\n"
"\n"
@@ -1275,19 +1292,29 @@ static const char* primitiveContactsKernelsCL= \
" {\n"
" pOnB1.w = actualDepth;\n"
" int dstIdx;\n"
" AppendInc( nGlobalContactsOut, dstIdx );\n"
"\n"
" \n"
" if (dstIdx < maxContactCapacity)\n"
" float lenSqr = dot3F4(normalOnSurfaceB1,normalOnSurfaceB1);\n"
" if (lenSqr>FLT_EPSILON)\n"
" {\n"
" __global Contact4* c = &globalContactsOut[dstIdx];\n"
" c->m_worldNormal = normalOnSurfaceB1;\n"
" c->m_coeffs = (u32)(0.f*0xffff) | ((u32)(0.7f*0xffff)<<16);\n"
" c->m_batchIdx = pairIndex;\n"
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyIndexA].m_invMass==0?-bodyIndexA:bodyIndexA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;\n"
" c->m_worldPos[0] = pOnB1;\n"
" GET_NPOINTS(*c) = 1;\n"
" } \n"
" AppendInc( nGlobalContactsOut, dstIdx );\n"
" \n"
" if (dstIdx < maxContactCapacity)\n"
" {\n"
" __global Contact4* c = &globalContactsOut[dstIdx];\n"
" c->m_worldNormal = normalOnSurfaceB1;\n"
" c->m_coeffs = (u32)(0.f*0xffff) | ((u32)(0.7f*0xffff)<<16);\n"
" c->m_batchIdx = pairIndex;\n"
" c->m_bodyAPtrAndSignBit = rigidBodies[bodyIndexA].m_invMass==0?-bodyIndexA:bodyIndexA;\n"
" c->m_bodyBPtrAndSignBit = rigidBodies[bodyIndexB].m_invMass==0?-bodyIndexB:bodyIndexB;\n"
" c->m_worldPos[0] = pOnB1;\n"
"\n"
" c->m_childIndexA = -1;\n"
" c->m_childIndexB = faceIndex;\n"
"\n"
" GET_NPOINTS(*c) = 1;\n"
" } \n"
" }\n"
"\n"
" }\n"
" }//if (hasCollision)\n"
@@ -1348,7 +1375,7 @@ static const char* primitiveContactsKernelsCL= \
" rigidBodies,collidables,\n"
" verticesA,\n"
" globalContactsOut, nGlobalContactsOut,maxContactCapacity,\n"
" spherePos,sphereRadius,convexPos,convexOrn);\n"
" spherePos,sphereRadius,convexPos,convexOrn, f);\n"
"\n"
" return;\n"
" }\n"