113 lines
3.0 KiB
C
113 lines
3.0 KiB
C
//this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
|
|
static const char* bvhTraversalKernelCL= \
|
|
"//keep this enum in sync with the CPU version (in btCollidable.h)\n"
|
|
"//written by Erwin Coumans\n"
|
|
"\n"
|
|
"#define SHAPE_CONVEX_HULL 3\n"
|
|
"#define SHAPE_CONCAVE_TRIMESH 5\n"
|
|
"#define TRIANGLE_NUM_CONVEX_FACES 5\n"
|
|
"#define SHAPE_COMPOUND_OF_CONVEX_HULLS 6\n"
|
|
"\n"
|
|
"typedef unsigned int u32;\n"
|
|
"\n"
|
|
"///keep this in sync with btCollidable.h\n"
|
|
"typedef struct\n"
|
|
"{\n"
|
|
" int m_numChildShapes;\n"
|
|
" int blaat2;\n"
|
|
" int m_shapeType;\n"
|
|
" int m_shapeIndex;\n"
|
|
" \n"
|
|
"} btCollidableGpu;\n"
|
|
"\n"
|
|
"typedef struct\n"
|
|
"{\n"
|
|
" float4 m_childPosition;\n"
|
|
" float4 m_childOrientation;\n"
|
|
" int m_shapeIndex;\n"
|
|
" int m_unused0;\n"
|
|
" int m_unused1;\n"
|
|
" int m_unused2;\n"
|
|
"} btGpuChildShape;\n"
|
|
"\n"
|
|
"\n"
|
|
"typedef struct\n"
|
|
"{\n"
|
|
" float4 m_pos;\n"
|
|
" float4 m_quat;\n"
|
|
" float4 m_linVel;\n"
|
|
" float4 m_angVel;\n"
|
|
"\n"
|
|
" u32 m_collidableIdx;\n"
|
|
" float m_invMass;\n"
|
|
" float m_restituitionCoeff;\n"
|
|
" float m_frictionCoeff;\n"
|
|
"} BodyData;\n"
|
|
"\n"
|
|
"typedef struct \n"
|
|
"{\n"
|
|
" union\n"
|
|
" {\n"
|
|
" float4 m_min;\n"
|
|
" float m_minElems[4];\n"
|
|
" int m_minIndices[4];\n"
|
|
" };\n"
|
|
" union\n"
|
|
" {\n"
|
|
" float4 m_max;\n"
|
|
" float m_maxElems[4];\n"
|
|
" int m_maxIndices[4];\n"
|
|
" };\n"
|
|
"} btAabbCL;\n"
|
|
"\n"
|
|
"// work-in-progress\n"
|
|
"__kernel void bvhTraversalKernel( __global const int2* pairs, \n"
|
|
" __global const BodyData* rigidBodies, \n"
|
|
" __global const btCollidableGpu* collidables,\n"
|
|
" __global btAabbCL* aabbs,\n"
|
|
" __global int4* concavePairsOut,\n"
|
|
" __global volatile int* numConcavePairsOut,\n"
|
|
" int numPairs,\n"
|
|
" int maxNumConcavePairsCapacity\n"
|
|
" )\n"
|
|
"{\n"
|
|
"\n"
|
|
" int i = get_global_id(0);\n"
|
|
" \n"
|
|
" if (i<numPairs)\n"
|
|
" {\n"
|
|
"\n"
|
|
" \n"
|
|
" int bodyIndexA = pairs[i].x;\n"
|
|
" int bodyIndexB = pairs[i].y;\n"
|
|
"\n"
|
|
" int collidableIndexA = rigidBodies[bodyIndexA].m_collidableIdx;\n"
|
|
" int collidableIndexB = rigidBodies[bodyIndexB].m_collidableIdx;\n"
|
|
" \n"
|
|
" int shapeIndexA = collidables[collidableIndexA].m_shapeIndex;\n"
|
|
" int shapeIndexB = collidables[collidableIndexB].m_shapeIndex;\n"
|
|
" \n"
|
|
" \n"
|
|
" //once the broadphase avoids static-static pairs, we can remove this test\n"
|
|
" if ((rigidBodies[bodyIndexA].m_invMass==0) &&(rigidBodies[bodyIndexB].m_invMass==0))\n"
|
|
" {\n"
|
|
" return;\n"
|
|
" }\n"
|
|
" \n"
|
|
" if ((collidables[collidableIndexA].m_shapeType==SHAPE_CONCAVE_TRIMESH))// && (collidables[collidableIndexB].m_shapeType==SHAPE_CONVEX_HULL))\n"
|
|
" {\n"
|
|
" int pairIdx = atomic_inc(numConcavePairsOut);\n"
|
|
" if (pairIdx<maxNumConcavePairsCapacity)\n"
|
|
" {\n"
|
|
" //int4 newPair;\n"
|
|
" concavePairsOut[pairIdx].x = bodyIndexA;\n"
|
|
" concavePairsOut[pairIdx].y = bodyIndexB;\n"
|
|
" concavePairsOut[pairIdx].z = 5;\n"
|
|
" concavePairsOut[pairIdx].w = 3;\n"
|
|
" }\n"
|
|
" }//SHAPE_CONCAVE_TRIMESH\n"
|
|
" \n"
|
|
" }//i<numpairs\n"
|
|
"}\n"
|
|
;
|