support compound versus compound collision shape acceleration on GPU, using aabb tree versus aabb tree.

Remove constructor from b3Vector3,  to make it a POD type, so it can go into a union (and more compatible with OpenCL float4)
Use b3MakeVector3 instead of constructor
Share some code between C++ and GPU in a shared file: see b3TransformAabb2 in src/Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h
Improve PairBench a bit, show timings and #overlapping pairs.
Increase shadowmap default size to 8192x8192 (hope the GPU supports it)
This commit is contained in:
erwincoumans
2013-08-20 03:19:59 -07:00
parent 41ba48b10d
commit 677722bba3
62 changed files with 1827 additions and 564 deletions

View File

@@ -6,16 +6,90 @@ static const char* satKernelsCL= \
"#define SHAPE_CONCAVE_TRIMESH 5\n"
"#define TRIANGLE_NUM_CONVEX_FACES 5\n"
"#define SHAPE_COMPOUND_OF_CONVEX_HULLS 6\n"
"#define B3_MAX_STACK_DEPTH 256\n"
"typedef unsigned int u32;\n"
"///keep this in sync with btCollidable.h\n"
"typedef struct\n"
"{\n"
" int m_numChildShapes;\n"
" int blaat2;\n"
" union {\n"
" int m_numChildShapes;\n"
" int m_bvhIndex;\n"
" };\n"
" union\n"
" {\n"
" float m_radius;\n"
" int m_compoundBvhIndex;\n"
" };\n"
" \n"
" int m_shapeType;\n"
" int m_shapeIndex;\n"
" \n"
"} btCollidableGpu;\n"
"#define MAX_NUM_PARTS_IN_BITS 10\n"
"///b3QuantizedBvhNode is a compressed aabb node, 16 bytes.\n"
"///Node can be used for leafnode or internal node. Leafnodes can point to 32-bit triangle index (non-negative range).\n"
"typedef struct\n"
"{\n"
" //12 bytes\n"
" unsigned short int m_quantizedAabbMin[3];\n"
" unsigned short int m_quantizedAabbMax[3];\n"
" //4 bytes\n"
" int m_escapeIndexOrTriangleIndex;\n"
"} b3QuantizedBvhNode;\n"
"typedef struct\n"
"{\n"
" float4 m_aabbMin;\n"
" float4 m_aabbMax;\n"
" float4 m_quantization;\n"
" int m_numNodes;\n"
" int m_numSubTrees;\n"
" int m_nodeOffset;\n"
" int m_subTreeOffset;\n"
"} b3BvhInfo;\n"
"int getTriangleIndex(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" unsigned int x=0;\n"
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
" // Get only the lower bits where the triangle index is stored\n"
" return (rootNode->m_escapeIndexOrTriangleIndex&~(y));\n"
"}\n"
"int getTriangleIndexGlobal(__global const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" unsigned int x=0;\n"
" unsigned int y = (~(x&0))<<(31-MAX_NUM_PARTS_IN_BITS);\n"
" // Get only the lower bits where the triangle index is stored\n"
" return (rootNode->m_escapeIndexOrTriangleIndex&~(y));\n"
"}\n"
"int isLeafNode(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" //skipindex is negative (internal node), triangleindex >=0 (leafnode)\n"
" return (rootNode->m_escapeIndexOrTriangleIndex >= 0)? 1 : 0;\n"
"}\n"
"int isLeafNodeGlobal(__global const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" //skipindex is negative (internal node), triangleindex >=0 (leafnode)\n"
" return (rootNode->m_escapeIndexOrTriangleIndex >= 0)? 1 : 0;\n"
"}\n"
" \n"
"int getEscapeIndex(const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" return -rootNode->m_escapeIndexOrTriangleIndex;\n"
"}\n"
"int getEscapeIndexGlobal(__global const b3QuantizedBvhNode* rootNode)\n"
"{\n"
" return -rootNode->m_escapeIndexOrTriangleIndex;\n"
"}\n"
"typedef struct\n"
"{\n"
" //12 bytes\n"
" unsigned short int m_quantizedAabbMin[3];\n"
" unsigned short int m_quantizedAabbMax[3];\n"
" //4 bytes, points to the root of the subtree\n"
" int m_rootNodeIndex;\n"
" //4 bytes\n"
" int m_subtreeSize;\n"
" int m_padding[3];\n"
"} b3BvhSubtreeInfo;\n"
"typedef struct\n"
"{\n"
" float4 m_childPosition;\n"
@@ -67,6 +141,210 @@ static const char* satKernelsCL= \
" int m_maxIndices[4];\n"
" };\n"
"} btAabbCL;\n"
"#ifndef B3_AABB_H\n"
"#define B3_AABB_H\n"
"#ifndef B3_FLOAT4_H\n"
"#define B3_FLOAT4_H\n"
"#ifndef B3_PLATFORM_DEFINITIONS_H\n"
"#define B3_PLATFORM_DEFINITIONS_H\n"
"struct MyTest\n"
"{\n"
" int bla;\n"
"};\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3AtomicInc atomic_inc\n"
"#endif\n"
"#endif\n"
"#ifdef __cplusplus\n"
"#else\n"
" typedef float4 b3Float4;\n"
" #define b3Float4ConstArg const b3Float4\n"
" #define b3MakeFloat4 (float4)\n"
" float b3Dot3F4(b3Float4ConstArg v0,b3Float4ConstArg v1)\n"
" {\n"
" float4 a1 = b3MakeFloat4(v0.xyz,0.f);\n"
" float4 b1 = b3MakeFloat4(v1.xyz,0.f);\n"
" return dot(a1, b1);\n"
" }\n"
" b3Float4 b3Cross3(b3Float4ConstArg v0,b3Float4ConstArg v1)\n"
" {\n"
" float4 a1 = b3MakeFloat4(v0.xyz,0.f);\n"
" float4 b1 = b3MakeFloat4(v1.xyz,0.f);\n"
" return cross(a1, b1);\n"
" }\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"
"#ifndef B3_MAT3x3_H\n"
"#define B3_MAT3x3_H\n"
"#ifndef B3_QUAT_H\n"
"#define B3_QUAT_H\n"
"#ifndef B3_PLATFORM_DEFINITIONS_H\n"
"#ifdef __cplusplus\n"
"#else\n"
"#endif\n"
"#endif\n"
"#ifndef B3_FLOAT4_H\n"
"#ifdef __cplusplus\n"
"#else\n"
"#endif \n"
"#endif //B3_FLOAT4_H\n"
"#ifdef __cplusplus\n"
"#else\n"
" typedef float4 b3Quat;\n"
" #define b3QuatConstArg const b3Quat\n"
" \n"
" \n"
"inline float4 b3FastNormalize4(float4 v)\n"
"{\n"
" v = (float4)(v.xyz,0.f);\n"
" return fast_normalize(v);\n"
"}\n"
" \n"
"inline b3Quat b3QuatMul(b3Quat a, b3Quat b);\n"
"inline b3Quat b3QuatNormalize(b3QuatConstArg in);\n"
"inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);\n"
"inline b3Quat b3QuatInvert(b3QuatConstArg q);\n"
"inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)\n"
"{\n"
" b3Quat ans;\n"
" ans = b3Cross3( a, b );\n"
" ans += a.w*b+b.w*a;\n"
"// ans.w = a.w*b.w - (a.x*b.x+a.y*b.y+a.z*b.z);\n"
" ans.w = a.w*b.w - b3Dot3F4(a, b);\n"
" return ans;\n"
"}\n"
"inline b3Quat b3QuatNormalize(b3QuatConstArg in)\n"
"{\n"
" return b3FastNormalize4(in);\n"
"}\n"
"inline float4 b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec)\n"
"{\n"
" b3Quat qInv = b3QuatInvert( q );\n"
" float4 vcpy = vec;\n"
" vcpy.w = 0.f;\n"
" float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);\n"
" return out;\n"
"}\n"
"inline b3Quat b3QuatInvert(b3QuatConstArg q)\n"
"{\n"
" return (b3Quat)(-q.xyz, q.w);\n"
"}\n"
"inline float4 b3QuatInvRotate(b3QuatConstArg q, b3QuatConstArg vec)\n"
"{\n"
" return b3QuatRotate( b3QuatInvert( q ), vec );\n"
"}\n"
"inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation)\n"
"{\n"
" return b3QuatRotate( orientation, point ) + (translation);\n"
"}\n"
" \n"
"#endif \n"
"#endif //B3_QUAT_H\n"
"#ifdef __cplusplus\n"
"#else\n"
"typedef struct\n"
"{\n"
" float4 m_row[3];\n"
"}b3Mat3x3;\n"
"#define b3Mat3x3ConstArg const b3Mat3x3\n"
"#define b3GetRow(m,row) (m.m_row[row])\n"
"inline b3Mat3x3 b3QuatGetRotationMatrix(b3Quat quat)\n"
"{\n"
" float4 quat2 = (float4)(quat.x*quat.x, quat.y*quat.y, quat.z*quat.z, 0.f);\n"
" b3Mat3x3 out;\n"
" out.m_row[0].x=1-2*quat2.y-2*quat2.z;\n"
" out.m_row[0].y=2*quat.x*quat.y-2*quat.w*quat.z;\n"
" out.m_row[0].z=2*quat.x*quat.z+2*quat.w*quat.y;\n"
" out.m_row[0].w = 0.f;\n"
" out.m_row[1].x=2*quat.x*quat.y+2*quat.w*quat.z;\n"
" out.m_row[1].y=1-2*quat2.x-2*quat2.z;\n"
" out.m_row[1].z=2*quat.y*quat.z-2*quat.w*quat.x;\n"
" out.m_row[1].w = 0.f;\n"
" out.m_row[2].x=2*quat.x*quat.z-2*quat.w*quat.y;\n"
" out.m_row[2].y=2*quat.y*quat.z+2*quat.w*quat.x;\n"
" out.m_row[2].z=1-2*quat2.x-2*quat2.y;\n"
" out.m_row[2].w = 0.f;\n"
" return out;\n"
"}\n"
"inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg matIn)\n"
"{\n"
" b3Mat3x3 out;\n"
" out.m_row[0] = fabs(matIn.m_row[0]);\n"
" out.m_row[1] = fabs(matIn.m_row[1]);\n"
" out.m_row[2] = fabs(matIn.m_row[2]);\n"
" return out;\n"
"}\n"
"#endif\n"
"#endif //B3_MAT3x3_H\n"
"typedef struct b3Aabb b3Aabb_t;\n"
"struct b3Aabb\n"
"{\n"
" union\n"
" {\n"
" float m_min[4];\n"
" b3Float4 m_minVec;\n"
" int m_minIndices[4];\n"
" };\n"
" union\n"
" {\n"
" float m_max[4];\n"
" b3Float4 m_maxVec;\n"
" int m_signedMaxIndices[4];\n"
" };\n"
"};\n"
"inline void b3TransformAabb2(b3Float4ConstArg localAabbMin,b3Float4ConstArg localAabbMax, float margin,\n"
" b3Float4ConstArg pos,\n"
" b3QuatConstArg orn,\n"
" b3Float4* aabbMinOut,b3Float4* aabbMaxOut)\n"
"{\n"
" b3Float4 localHalfExtents = 0.5f*(localAabbMax-localAabbMin);\n"
" localHalfExtents+=b3MakeFloat4(margin,margin,margin,0.f);\n"
" b3Float4 localCenter = 0.5f*(localAabbMax+localAabbMin);\n"
" b3Mat3x3 m;\n"
" m = b3QuatGetRotationMatrix(orn);\n"
" b3Mat3x3 abs_b = b3AbsoluteMat3x3(m);\n"
" b3Float4 center = b3TransformPoint(localCenter,pos,orn);\n"
" \n"
" b3Float4 extent = b3MakeFloat4(b3Dot3F4(localHalfExtents,b3GetRow(abs_b,0)),\n"
" b3Dot3F4(localHalfExtents,b3GetRow(abs_b,1)),\n"
" b3Dot3F4(localHalfExtents,b3GetRow(abs_b,2)),\n"
" 0.f);\n"
" *aabbMinOut = center-extent;\n"
" *aabbMaxOut = center+extent;\n"
"}\n"
"/// conservative test for overlap between two aabbs\n"
"inline bool b3TestAabbAgainstAabb(b3Float4ConstArg aabbMin1,b3Float4ConstArg aabbMax1,\n"
" b3Float4ConstArg aabbMin2, b3Float4ConstArg aabbMax2)\n"
"{\n"
" bool overlap = true;\n"
" overlap = (aabbMin1.x > aabbMax2.x || aabbMax1.x < aabbMin2.x) ? false : overlap;\n"
" overlap = (aabbMin1.z > aabbMax2.z || aabbMax1.z < aabbMin2.z) ? false : overlap;\n"
" overlap = (aabbMin1.y > aabbMax2.y || aabbMax1.y < aabbMin2.y) ? false : overlap;\n"
" return overlap;\n"
"}\n"
"#endif //B3_AABB_H\n"
"/*\n"
"Bullet Continuous Collision Detection and Physics Library\n"
"Copyright (c) 2003-2013 Erwin Coumans http://bulletphysics.org\n"
"This software is provided 'as-is', without any express or implied warranty.\n"
"In no event will the authors be held liable for any damages arising from the use of this software.\n"
"Permission is granted to anyone to use this software for any purpose,\n"
"including commercial applications, and to alter it and redistribute it freely,\n"
"subject to the following restrictions:\n"
"1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.\n"
"2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.\n"
"3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"#ifndef B3_INT2_H\n"
"#define B3_INT2_H\n"
"#ifdef __cplusplus\n"
"#else\n"
"#define b3UnsignedInt2 uint2\n"
"#define b3Int2 int2\n"
"#define b3MakeInt2 (int2)\n"
"#endif //__cplusplus\n"
"#endif\n"
"typedef struct\n"
"{\n"
" float4 m_plane;\n"
@@ -650,6 +928,28 @@ static const char* satKernelsCL= \
" }\n"
" \n"
"}\n"
"inline b3Float4 MyUnQuantize(const unsigned short* vecIn, b3Float4 quantization, b3Float4 bvhAabbMin)\n"
"{\n"
" b3Float4 vecOut;\n"
" vecOut = b3MakeFloat4(\n"
" (float)(vecIn[0]) / (quantization.x),\n"
" (float)(vecIn[1]) / (quantization.y),\n"
" (float)(vecIn[2]) / (quantization.z),\n"
" 0.f);\n"
" vecOut += bvhAabbMin;\n"
" return vecOut;\n"
"}\n"
"inline b3Float4 MyUnQuantizeGlobal(__global const unsigned short* vecIn, b3Float4 quantization, b3Float4 bvhAabbMin)\n"
"{\n"
" b3Float4 vecOut;\n"
" vecOut = b3MakeFloat4(\n"
" (float)(vecIn[0]) / (quantization.x),\n"
" (float)(vecIn[1]) / (quantization.y),\n"
" (float)(vecIn[2]) / (quantization.z),\n"
" 0.f);\n"
" vecOut += bvhAabbMin;\n"
" return vecOut;\n"
"}\n"
"// work-in-progress\n"
"__kernel void findCompoundPairsKernel( __global const int4* pairs, \n"
" __global const BodyData* rigidBodies, \n"
@@ -659,10 +959,13 @@ static const char* satKernelsCL= \
" __global const float4* uniqueEdges,\n"
" __global const btGpuFace* faces,\n"
" __global const int* indices,\n"
" __global btAabbCL* aabbs,\n"
" __global b3Aabb_t* aabbLocalSpace,\n"
" __global const btGpuChildShape* gpuChildShapes,\n"
" __global volatile int4* gpuCompoundPairsOut,\n"
" __global volatile int* numCompoundPairsOut,\n"
" __global const b3BvhSubtreeInfo* subtrees,\n"
" __global const b3QuantizedBvhNode* quantizedNodes,\n"
" __global const b3BvhInfo* bvhInfos,\n"
" int numPairs,\n"
" int maxNumCompoundPairsCapacity\n"
" )\n"
@@ -681,6 +984,131 @@ static const char* satKernelsCL= \
" {\n"
" return;\n"
" }\n"
" if ((collidables[collidableIndexA].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS) &&(collidables[collidableIndexB].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS))\n"
" {\n"
" int bvhA = collidables[collidableIndexA].m_compoundBvhIndex;\n"
" int bvhB = collidables[collidableIndexB].m_compoundBvhIndex;\n"
" int numSubTreesA = bvhInfos[bvhA].m_numSubTrees;\n"
" int subTreesOffsetA = bvhInfos[bvhA].m_subTreeOffset;\n"
" int subTreesOffsetB = bvhInfos[bvhB].m_subTreeOffset;\n"
" int numSubTreesB = bvhInfos[bvhB].m_numSubTrees;\n"
" \n"
" float4 posA = rigidBodies[bodyIndexA].m_pos;\n"
" b3Quat ornA = rigidBodies[bodyIndexA].m_quat;\n"
" b3Quat ornB = rigidBodies[bodyIndexB].m_quat;\n"
" float4 posB = rigidBodies[bodyIndexB].m_pos;\n"
" \n"
" for (int p=0;p<numSubTreesA;p++)\n"
" {\n"
" b3BvhSubtreeInfo subtreeA = subtrees[subTreesOffsetA+p];\n"
" //bvhInfos[bvhA].m_quantization\n"
" b3Float4 treeAminLocal = MyUnQuantize(subtreeA.m_quantizedAabbMin,bvhInfos[bvhA].m_quantization,bvhInfos[bvhA].m_aabbMin);\n"
" b3Float4 treeAmaxLocal = MyUnQuantize(subtreeA.m_quantizedAabbMax,bvhInfos[bvhA].m_quantization,bvhInfos[bvhA].m_aabbMin);\n"
" b3Float4 aabbAMinOut,aabbAMaxOut;\n"
" float margin=0.f;\n"
" b3TransformAabb2(treeAminLocal,treeAmaxLocal, margin,posA,ornA,&aabbAMinOut,&aabbAMaxOut);\n"
" \n"
" for (int q=0;q<numSubTreesB;q++)\n"
" {\n"
" b3BvhSubtreeInfo subtreeB = subtrees[subTreesOffsetB+q];\n"
" b3Float4 treeBminLocal = MyUnQuantize(subtreeB.m_quantizedAabbMin,bvhInfos[bvhB].m_quantization,bvhInfos[bvhB].m_aabbMin);\n"
" b3Float4 treeBmaxLocal = MyUnQuantize(subtreeB.m_quantizedAabbMax,bvhInfos[bvhB].m_quantization,bvhInfos[bvhB].m_aabbMin);\n"
" b3Float4 aabbBMinOut,aabbBMaxOut;\n"
" float margin=0.f;\n"
" b3TransformAabb2(treeBminLocal,treeBmaxLocal, margin,posB,ornB,&aabbBMinOut,&aabbBMaxOut);\n"
" \n"
" \n"
" bool aabbOverlap = b3TestAabbAgainstAabb(aabbAMinOut,aabbAMaxOut,aabbBMinOut,aabbBMaxOut);\n"
" if (aabbOverlap)\n"
" {\n"
" \n"
" int startNodeIndexA = subtreeA.m_rootNodeIndex+bvhInfos[bvhA].m_nodeOffset;\n"
" int endNodeIndexA = startNodeIndexA+subtreeA.m_subtreeSize;\n"
" int startNodeIndexB = subtreeB.m_rootNodeIndex+bvhInfos[bvhB].m_nodeOffset;\n"
" int endNodeIndexB = startNodeIndexB+subtreeB.m_subtreeSize;\n"
" b3Int2 nodeStack[B3_MAX_STACK_DEPTH];\n"
" b3Int2 node0;\n"
" node0.x = startNodeIndexA;\n"
" node0.y = startNodeIndexB;\n"
" int maxStackDepth = B3_MAX_STACK_DEPTH;\n"
" int depth=0;\n"
" nodeStack[depth++]=node0;\n"
" do\n"
" {\n"
" b3Int2 node = nodeStack[--depth];\n"
" b3Float4 aMinLocal = MyUnQuantizeGlobal(quantizedNodes[node.x].m_quantizedAabbMin,bvhInfos[bvhA].m_quantization,bvhInfos[bvhA].m_aabbMin);\n"
" b3Float4 aMaxLocal = MyUnQuantizeGlobal(quantizedNodes[node.x].m_quantizedAabbMax,bvhInfos[bvhA].m_quantization,bvhInfos[bvhA].m_aabbMin);\n"
" b3Float4 bMinLocal = MyUnQuantizeGlobal(quantizedNodes[node.y].m_quantizedAabbMin,bvhInfos[bvhB].m_quantization,bvhInfos[bvhB].m_aabbMin);\n"
" b3Float4 bMaxLocal = MyUnQuantizeGlobal(quantizedNodes[node.y].m_quantizedAabbMax,bvhInfos[bvhB].m_quantization,bvhInfos[bvhB].m_aabbMin);\n"
" float margin=0.f;\n"
" b3Float4 aabbAMinOut,aabbAMaxOut;\n"
" b3TransformAabb2(aMinLocal,aMaxLocal, margin,posA,ornA,&aabbAMinOut,&aabbAMaxOut);\n"
" b3Float4 aabbBMinOut,aabbBMaxOut;\n"
" b3TransformAabb2(bMinLocal,bMaxLocal, margin,posB,ornB,&aabbBMinOut,&aabbBMaxOut);\n"
" \n"
" bool nodeOverlap = b3TestAabbAgainstAabb(aabbAMinOut,aabbAMaxOut,aabbBMinOut,aabbBMaxOut);\n"
" if (nodeOverlap)\n"
" {\n"
" bool isLeafA = isLeafNodeGlobal(&quantizedNodes[node.x]);\n"
" bool isLeafB = isLeafNodeGlobal(&quantizedNodes[node.y]);\n"
" bool isInternalA = !isLeafA;\n"
" bool isInternalB = !isLeafB;\n"
" //fail, even though it might hit two leaf nodes\n"
" if (depth+4>maxStackDepth && !(isLeafA && isLeafB))\n"
" {\n"
" //printf(\"Error: traversal exceeded maxStackDepth\");\n"
" continue;\n"
" }\n"
" if(isInternalA)\n"
" {\n"
" int nodeAleftChild = node.x+1;\n"
" bool isNodeALeftChildLeaf = isLeafNodeGlobal(&quantizedNodes[node.x+1]);\n"
" int nodeArightChild = isNodeALeftChildLeaf? node.x+2 : node.x+1 + getEscapeIndexGlobal(&quantizedNodes[node.x+1]);\n"
" if(isInternalB)\n"
" { \n"
" int nodeBleftChild = node.y+1;\n"
" bool isNodeBLeftChildLeaf = isLeafNodeGlobal(&quantizedNodes[node.y+1]);\n"
" int nodeBrightChild = isNodeBLeftChildLeaf? node.y+2 : node.y+1 + getEscapeIndexGlobal(&quantizedNodes[node.y+1]);\n"
" nodeStack[depth++] = b3MakeInt2(nodeAleftChild, nodeBleftChild);\n"
" nodeStack[depth++] = b3MakeInt2(nodeArightChild, nodeBleftChild);\n"
" nodeStack[depth++] = b3MakeInt2(nodeAleftChild, nodeBrightChild);\n"
" nodeStack[depth++] = b3MakeInt2(nodeArightChild, nodeBrightChild);\n"
" }\n"
" else\n"
" {\n"
" nodeStack[depth++] = b3MakeInt2(nodeAleftChild,node.y);\n"
" nodeStack[depth++] = b3MakeInt2(nodeArightChild,node.y);\n"
" }\n"
" }\n"
" else\n"
" {\n"
" if(isInternalB)\n"
" {\n"
" int nodeBleftChild = node.y+1;\n"
" bool isNodeBLeftChildLeaf = isLeafNodeGlobal(&quantizedNodes[node.y+1]);\n"
" int nodeBrightChild = isNodeBLeftChildLeaf? node.y+2 : node.y+1 + getEscapeIndexGlobal(&quantizedNodes[node.y+1]);\n"
" nodeStack[depth++] = b3MakeInt2(node.x,nodeBleftChild);\n"
" nodeStack[depth++] = b3MakeInt2(node.x,nodeBrightChild);\n"
" }\n"
" else\n"
" {\n"
" int compoundPairIdx = atomic_inc(numCompoundPairsOut);\n"
" if (compoundPairIdx<maxNumCompoundPairsCapacity)\n"
" {\n"
" int childShapeIndexA = getTriangleIndexGlobal(&quantizedNodes[node.x]);\n"
" int childShapeIndexB = getTriangleIndexGlobal(&quantizedNodes[node.y]);\n"
" gpuCompoundPairsOut[compoundPairIdx] = (int4)(bodyIndexA,bodyIndexB,childShapeIndexA,childShapeIndexB);\n"
" }\n"
" }\n"
" }\n"
" }\n"
" } while (depth);\n"
" }\n"
" }\n"
" }\n"
" \n"
" return;\n"
" }\n"
" if ((collidables[collidableIndexA].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS) ||(collidables[collidableIndexB].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS))\n"
" {\n"
" if (collidables[collidableIndexA].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS) \n"
@@ -697,6 +1125,18 @@ static const char* satKernelsCL= \
" float4 newPosA = qtRotate(ornA,childPosA)+posA;\n"
" float4 newOrnA = qtMul(ornA,childOrnA);\n"
" int shapeIndexA = collidables[childColIndexA].m_shapeIndex;\n"
" b3Aabb_t aabbAlocal = aabbLocalSpace[shapeIndexA];\n"
" float margin = 0.f;\n"
" \n"
" b3Float4 aabbAMinWS;\n"
" b3Float4 aabbAMaxWS;\n"
" \n"
" b3TransformAabb2(aabbAlocal.m_minVec,aabbAlocal.m_maxVec,margin,\n"
" newPosA,\n"
" newOrnA,\n"
" &aabbAMinWS,&aabbAMaxWS);\n"
" \n"
" \n"
" if (collidables[collidableIndexB].m_shapeType==SHAPE_COMPOUND_OF_CONVEX_HULLS)\n"
" {\n"
" int numChildrenB = collidables[collidableIndexB].m_numChildShapes;\n"
@@ -711,7 +1151,20 @@ static const char* satKernelsCL= \
" float4 newPosB = transform(&childPosB,&posB,&ornB);\n"
" float4 newOrnB = qtMul(ornB,childOrnB);\n"
" int shapeIndexB = collidables[childColIndexB].m_shapeIndex;\n"
" if (1)\n"
" b3Aabb_t aabbBlocal = aabbLocalSpace[shapeIndexB];\n"
" \n"
" b3Float4 aabbBMinWS;\n"
" b3Float4 aabbBMaxWS;\n"
" \n"
" b3TransformAabb2(aabbBlocal.m_minVec,aabbBlocal.m_maxVec,margin,\n"
" newPosB,\n"
" newOrnB,\n"
" &aabbBMinWS,&aabbBMaxWS);\n"
" \n"
" \n"
" \n"
" bool aabbOverlap = b3TestAabbAgainstAabb(aabbAMinWS,aabbAMaxWS,aabbBMinWS,aabbBMaxWS);\n"
" if (aabbOverlap)\n"
" {\n"
" int numFacesA = convexShapes[shapeIndexA].m_numFaces;\n"
" float dmin = FLT_MAX;\n"