updateAabbsKernel.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. //this file is autogenerated using stringify.bat (premake --stringify) in the build folder of this project
  2. static const char* updateAabbsKernelCL =
  3. "#ifndef B3_UPDATE_AABBS_H\n"
  4. "#define B3_UPDATE_AABBS_H\n"
  5. "#ifndef B3_AABB_H\n"
  6. "#define B3_AABB_H\n"
  7. "#ifndef B3_FLOAT4_H\n"
  8. "#define B3_FLOAT4_H\n"
  9. "#ifndef B3_PLATFORM_DEFINITIONS_H\n"
  10. "#define B3_PLATFORM_DEFINITIONS_H\n"
  11. "struct MyTest\n"
  12. "{\n"
  13. " int bla;\n"
  14. "};\n"
  15. "#ifdef __cplusplus\n"
  16. "#else\n"
  17. "//keep B3_LARGE_FLOAT*B3_LARGE_FLOAT < FLT_MAX\n"
  18. "#define B3_LARGE_FLOAT 1e18f\n"
  19. "#define B3_INFINITY 1e18f\n"
  20. "#define b3Assert(a)\n"
  21. "#define b3ConstArray(a) __global const a*\n"
  22. "#define b3AtomicInc atomic_inc\n"
  23. "#define b3AtomicAdd atomic_add\n"
  24. "#define b3Fabs fabs\n"
  25. "#define b3Sqrt native_sqrt\n"
  26. "#define b3Sin native_sin\n"
  27. "#define b3Cos native_cos\n"
  28. "#define B3_STATIC\n"
  29. "#endif\n"
  30. "#endif\n"
  31. "#ifdef __cplusplus\n"
  32. "#else\n"
  33. " typedef float4 b3Float4;\n"
  34. " #define b3Float4ConstArg const b3Float4\n"
  35. " #define b3MakeFloat4 (float4)\n"
  36. " float b3Dot3F4(b3Float4ConstArg v0,b3Float4ConstArg v1)\n"
  37. " {\n"
  38. " float4 a1 = b3MakeFloat4(v0.xyz,0.f);\n"
  39. " float4 b1 = b3MakeFloat4(v1.xyz,0.f);\n"
  40. " return dot(a1, b1);\n"
  41. " }\n"
  42. " b3Float4 b3Cross3(b3Float4ConstArg v0,b3Float4ConstArg v1)\n"
  43. " {\n"
  44. " float4 a1 = b3MakeFloat4(v0.xyz,0.f);\n"
  45. " float4 b1 = b3MakeFloat4(v1.xyz,0.f);\n"
  46. " return cross(a1, b1);\n"
  47. " }\n"
  48. " #define b3MinFloat4 min\n"
  49. " #define b3MaxFloat4 max\n"
  50. " #define b3Normalized(a) normalize(a)\n"
  51. "#endif \n"
  52. " \n"
  53. "inline bool b3IsAlmostZero(b3Float4ConstArg v)\n"
  54. "{\n"
  55. " if(b3Fabs(v.x)>1e-6 || b3Fabs(v.y)>1e-6 || b3Fabs(v.z)>1e-6) \n"
  56. " return false;\n"
  57. " return true;\n"
  58. "}\n"
  59. "inline int b3MaxDot( b3Float4ConstArg vec, __global const b3Float4* vecArray, int vecLen, float* dotOut )\n"
  60. "{\n"
  61. " float maxDot = -B3_INFINITY;\n"
  62. " int i = 0;\n"
  63. " int ptIndex = -1;\n"
  64. " for( i = 0; i < vecLen; i++ )\n"
  65. " {\n"
  66. " float dot = b3Dot3F4(vecArray[i],vec);\n"
  67. " \n"
  68. " if( dot > maxDot )\n"
  69. " {\n"
  70. " maxDot = dot;\n"
  71. " ptIndex = i;\n"
  72. " }\n"
  73. " }\n"
  74. " b3Assert(ptIndex>=0);\n"
  75. " if (ptIndex<0)\n"
  76. " {\n"
  77. " ptIndex = 0;\n"
  78. " }\n"
  79. " *dotOut = maxDot;\n"
  80. " return ptIndex;\n"
  81. "}\n"
  82. "#endif //B3_FLOAT4_H\n"
  83. "#ifndef B3_MAT3x3_H\n"
  84. "#define B3_MAT3x3_H\n"
  85. "#ifndef B3_QUAT_H\n"
  86. "#define B3_QUAT_H\n"
  87. "#ifndef B3_PLATFORM_DEFINITIONS_H\n"
  88. "#ifdef __cplusplus\n"
  89. "#else\n"
  90. "#endif\n"
  91. "#endif\n"
  92. "#ifndef B3_FLOAT4_H\n"
  93. "#ifdef __cplusplus\n"
  94. "#else\n"
  95. "#endif \n"
  96. "#endif //B3_FLOAT4_H\n"
  97. "#ifdef __cplusplus\n"
  98. "#else\n"
  99. " typedef float4 b3Quat;\n"
  100. " #define b3QuatConstArg const b3Quat\n"
  101. " \n"
  102. " \n"
  103. "inline float4 b3FastNormalize4(float4 v)\n"
  104. "{\n"
  105. " v = (float4)(v.xyz,0.f);\n"
  106. " return fast_normalize(v);\n"
  107. "}\n"
  108. " \n"
  109. "inline b3Quat b3QuatMul(b3Quat a, b3Quat b);\n"
  110. "inline b3Quat b3QuatNormalized(b3QuatConstArg in);\n"
  111. "inline b3Quat b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec);\n"
  112. "inline b3Quat b3QuatInvert(b3QuatConstArg q);\n"
  113. "inline b3Quat b3QuatInverse(b3QuatConstArg q);\n"
  114. "inline b3Quat b3QuatMul(b3QuatConstArg a, b3QuatConstArg b)\n"
  115. "{\n"
  116. " b3Quat ans;\n"
  117. " ans = b3Cross3( a, b );\n"
  118. " ans += a.w*b+b.w*a;\n"
  119. "// ans.w = a.w*b.w - (a.x*b.x+a.y*b.y+a.z*b.z);\n"
  120. " ans.w = a.w*b.w - b3Dot3F4(a, b);\n"
  121. " return ans;\n"
  122. "}\n"
  123. "inline b3Quat b3QuatNormalized(b3QuatConstArg in)\n"
  124. "{\n"
  125. " b3Quat q;\n"
  126. " q=in;\n"
  127. " //return b3FastNormalize4(in);\n"
  128. " float len = native_sqrt(dot(q, q));\n"
  129. " if(len > 0.f)\n"
  130. " {\n"
  131. " q *= 1.f / len;\n"
  132. " }\n"
  133. " else\n"
  134. " {\n"
  135. " q.x = q.y = q.z = 0.f;\n"
  136. " q.w = 1.f;\n"
  137. " }\n"
  138. " return q;\n"
  139. "}\n"
  140. "inline float4 b3QuatRotate(b3QuatConstArg q, b3QuatConstArg vec)\n"
  141. "{\n"
  142. " b3Quat qInv = b3QuatInvert( q );\n"
  143. " float4 vcpy = vec;\n"
  144. " vcpy.w = 0.f;\n"
  145. " float4 out = b3QuatMul(b3QuatMul(q,vcpy),qInv);\n"
  146. " return out;\n"
  147. "}\n"
  148. "inline b3Quat b3QuatInverse(b3QuatConstArg q)\n"
  149. "{\n"
  150. " return (b3Quat)(-q.xyz, q.w);\n"
  151. "}\n"
  152. "inline b3Quat b3QuatInvert(b3QuatConstArg q)\n"
  153. "{\n"
  154. " return (b3Quat)(-q.xyz, q.w);\n"
  155. "}\n"
  156. "inline float4 b3QuatInvRotate(b3QuatConstArg q, b3QuatConstArg vec)\n"
  157. "{\n"
  158. " return b3QuatRotate( b3QuatInvert( q ), vec );\n"
  159. "}\n"
  160. "inline b3Float4 b3TransformPoint(b3Float4ConstArg point, b3Float4ConstArg translation, b3QuatConstArg orientation)\n"
  161. "{\n"
  162. " return b3QuatRotate( orientation, point ) + (translation);\n"
  163. "}\n"
  164. " \n"
  165. "#endif \n"
  166. "#endif //B3_QUAT_H\n"
  167. "#ifdef __cplusplus\n"
  168. "#else\n"
  169. "typedef struct\n"
  170. "{\n"
  171. " b3Float4 m_row[3];\n"
  172. "}b3Mat3x3;\n"
  173. "#define b3Mat3x3ConstArg const b3Mat3x3\n"
  174. "#define b3GetRow(m,row) (m.m_row[row])\n"
  175. "inline b3Mat3x3 b3QuatGetRotationMatrix(b3Quat quat)\n"
  176. "{\n"
  177. " b3Float4 quat2 = (b3Float4)(quat.x*quat.x, quat.y*quat.y, quat.z*quat.z, 0.f);\n"
  178. " b3Mat3x3 out;\n"
  179. " out.m_row[0].x=1-2*quat2.y-2*quat2.z;\n"
  180. " out.m_row[0].y=2*quat.x*quat.y-2*quat.w*quat.z;\n"
  181. " out.m_row[0].z=2*quat.x*quat.z+2*quat.w*quat.y;\n"
  182. " out.m_row[0].w = 0.f;\n"
  183. " out.m_row[1].x=2*quat.x*quat.y+2*quat.w*quat.z;\n"
  184. " out.m_row[1].y=1-2*quat2.x-2*quat2.z;\n"
  185. " out.m_row[1].z=2*quat.y*quat.z-2*quat.w*quat.x;\n"
  186. " out.m_row[1].w = 0.f;\n"
  187. " out.m_row[2].x=2*quat.x*quat.z-2*quat.w*quat.y;\n"
  188. " out.m_row[2].y=2*quat.y*quat.z+2*quat.w*quat.x;\n"
  189. " out.m_row[2].z=1-2*quat2.x-2*quat2.y;\n"
  190. " out.m_row[2].w = 0.f;\n"
  191. " return out;\n"
  192. "}\n"
  193. "inline b3Mat3x3 b3AbsoluteMat3x3(b3Mat3x3ConstArg matIn)\n"
  194. "{\n"
  195. " b3Mat3x3 out;\n"
  196. " out.m_row[0] = fabs(matIn.m_row[0]);\n"
  197. " out.m_row[1] = fabs(matIn.m_row[1]);\n"
  198. " out.m_row[2] = fabs(matIn.m_row[2]);\n"
  199. " return out;\n"
  200. "}\n"
  201. "__inline\n"
  202. "b3Mat3x3 mtZero();\n"
  203. "__inline\n"
  204. "b3Mat3x3 mtIdentity();\n"
  205. "__inline\n"
  206. "b3Mat3x3 mtTranspose(b3Mat3x3 m);\n"
  207. "__inline\n"
  208. "b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b);\n"
  209. "__inline\n"
  210. "b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b);\n"
  211. "__inline\n"
  212. "b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b);\n"
  213. "__inline\n"
  214. "b3Mat3x3 mtZero()\n"
  215. "{\n"
  216. " b3Mat3x3 m;\n"
  217. " m.m_row[0] = (b3Float4)(0.f);\n"
  218. " m.m_row[1] = (b3Float4)(0.f);\n"
  219. " m.m_row[2] = (b3Float4)(0.f);\n"
  220. " return m;\n"
  221. "}\n"
  222. "__inline\n"
  223. "b3Mat3x3 mtIdentity()\n"
  224. "{\n"
  225. " b3Mat3x3 m;\n"
  226. " m.m_row[0] = (b3Float4)(1,0,0,0);\n"
  227. " m.m_row[1] = (b3Float4)(0,1,0,0);\n"
  228. " m.m_row[2] = (b3Float4)(0,0,1,0);\n"
  229. " return m;\n"
  230. "}\n"
  231. "__inline\n"
  232. "b3Mat3x3 mtTranspose(b3Mat3x3 m)\n"
  233. "{\n"
  234. " b3Mat3x3 out;\n"
  235. " out.m_row[0] = (b3Float4)(m.m_row[0].x, m.m_row[1].x, m.m_row[2].x, 0.f);\n"
  236. " out.m_row[1] = (b3Float4)(m.m_row[0].y, m.m_row[1].y, m.m_row[2].y, 0.f);\n"
  237. " out.m_row[2] = (b3Float4)(m.m_row[0].z, m.m_row[1].z, m.m_row[2].z, 0.f);\n"
  238. " return out;\n"
  239. "}\n"
  240. "__inline\n"
  241. "b3Mat3x3 mtMul(b3Mat3x3 a, b3Mat3x3 b)\n"
  242. "{\n"
  243. " b3Mat3x3 transB;\n"
  244. " transB = mtTranspose( b );\n"
  245. " b3Mat3x3 ans;\n"
  246. " // why this doesn't run when 0ing in the for{}\n"
  247. " a.m_row[0].w = 0.f;\n"
  248. " a.m_row[1].w = 0.f;\n"
  249. " a.m_row[2].w = 0.f;\n"
  250. " for(int i=0; i<3; i++)\n"
  251. " {\n"
  252. "// a.m_row[i].w = 0.f;\n"
  253. " ans.m_row[i].x = b3Dot3F4(a.m_row[i],transB.m_row[0]);\n"
  254. " ans.m_row[i].y = b3Dot3F4(a.m_row[i],transB.m_row[1]);\n"
  255. " ans.m_row[i].z = b3Dot3F4(a.m_row[i],transB.m_row[2]);\n"
  256. " ans.m_row[i].w = 0.f;\n"
  257. " }\n"
  258. " return ans;\n"
  259. "}\n"
  260. "__inline\n"
  261. "b3Float4 mtMul1(b3Mat3x3 a, b3Float4 b)\n"
  262. "{\n"
  263. " b3Float4 ans;\n"
  264. " ans.x = b3Dot3F4( a.m_row[0], b );\n"
  265. " ans.y = b3Dot3F4( a.m_row[1], b );\n"
  266. " ans.z = b3Dot3F4( a.m_row[2], b );\n"
  267. " ans.w = 0.f;\n"
  268. " return ans;\n"
  269. "}\n"
  270. "__inline\n"
  271. "b3Float4 mtMul3(b3Float4 a, b3Mat3x3 b)\n"
  272. "{\n"
  273. " b3Float4 colx = b3MakeFloat4(b.m_row[0].x, b.m_row[1].x, b.m_row[2].x, 0);\n"
  274. " b3Float4 coly = b3MakeFloat4(b.m_row[0].y, b.m_row[1].y, b.m_row[2].y, 0);\n"
  275. " b3Float4 colz = b3MakeFloat4(b.m_row[0].z, b.m_row[1].z, b.m_row[2].z, 0);\n"
  276. " b3Float4 ans;\n"
  277. " ans.x = b3Dot3F4( a, colx );\n"
  278. " ans.y = b3Dot3F4( a, coly );\n"
  279. " ans.z = b3Dot3F4( a, colz );\n"
  280. " return ans;\n"
  281. "}\n"
  282. "#endif\n"
  283. "#endif //B3_MAT3x3_H\n"
  284. "typedef struct b3Aabb b3Aabb_t;\n"
  285. "struct b3Aabb\n"
  286. "{\n"
  287. " union\n"
  288. " {\n"
  289. " float m_min[4];\n"
  290. " b3Float4 m_minVec;\n"
  291. " int m_minIndices[4];\n"
  292. " };\n"
  293. " union\n"
  294. " {\n"
  295. " float m_max[4];\n"
  296. " b3Float4 m_maxVec;\n"
  297. " int m_signedMaxIndices[4];\n"
  298. " };\n"
  299. "};\n"
  300. "inline void b3TransformAabb2(b3Float4ConstArg localAabbMin,b3Float4ConstArg localAabbMax, float margin,\n"
  301. " b3Float4ConstArg pos,\n"
  302. " b3QuatConstArg orn,\n"
  303. " b3Float4* aabbMinOut,b3Float4* aabbMaxOut)\n"
  304. "{\n"
  305. " b3Float4 localHalfExtents = 0.5f*(localAabbMax-localAabbMin);\n"
  306. " localHalfExtents+=b3MakeFloat4(margin,margin,margin,0.f);\n"
  307. " b3Float4 localCenter = 0.5f*(localAabbMax+localAabbMin);\n"
  308. " b3Mat3x3 m;\n"
  309. " m = b3QuatGetRotationMatrix(orn);\n"
  310. " b3Mat3x3 abs_b = b3AbsoluteMat3x3(m);\n"
  311. " b3Float4 center = b3TransformPoint(localCenter,pos,orn);\n"
  312. " \n"
  313. " b3Float4 extent = b3MakeFloat4(b3Dot3F4(localHalfExtents,b3GetRow(abs_b,0)),\n"
  314. " b3Dot3F4(localHalfExtents,b3GetRow(abs_b,1)),\n"
  315. " b3Dot3F4(localHalfExtents,b3GetRow(abs_b,2)),\n"
  316. " 0.f);\n"
  317. " *aabbMinOut = center-extent;\n"
  318. " *aabbMaxOut = center+extent;\n"
  319. "}\n"
  320. "/// conservative test for overlap between two aabbs\n"
  321. "inline bool b3TestAabbAgainstAabb(b3Float4ConstArg aabbMin1,b3Float4ConstArg aabbMax1,\n"
  322. " b3Float4ConstArg aabbMin2, b3Float4ConstArg aabbMax2)\n"
  323. "{\n"
  324. " bool overlap = true;\n"
  325. " overlap = (aabbMin1.x > aabbMax2.x || aabbMax1.x < aabbMin2.x) ? false : overlap;\n"
  326. " overlap = (aabbMin1.z > aabbMax2.z || aabbMax1.z < aabbMin2.z) ? false : overlap;\n"
  327. " overlap = (aabbMin1.y > aabbMax2.y || aabbMax1.y < aabbMin2.y) ? false : overlap;\n"
  328. " return overlap;\n"
  329. "}\n"
  330. "#endif //B3_AABB_H\n"
  331. "#ifndef B3_COLLIDABLE_H\n"
  332. "#define B3_COLLIDABLE_H\n"
  333. "#ifndef B3_FLOAT4_H\n"
  334. "#ifdef __cplusplus\n"
  335. "#else\n"
  336. "#endif \n"
  337. "#endif //B3_FLOAT4_H\n"
  338. "#ifndef B3_QUAT_H\n"
  339. "#ifdef __cplusplus\n"
  340. "#else\n"
  341. "#endif \n"
  342. "#endif //B3_QUAT_H\n"
  343. "enum b3ShapeTypes\n"
  344. "{\n"
  345. " SHAPE_HEIGHT_FIELD=1,\n"
  346. " SHAPE_CONVEX_HULL=3,\n"
  347. " SHAPE_PLANE=4,\n"
  348. " SHAPE_CONCAVE_TRIMESH=5,\n"
  349. " SHAPE_COMPOUND_OF_CONVEX_HULLS=6,\n"
  350. " SHAPE_SPHERE=7,\n"
  351. " MAX_NUM_SHAPE_TYPES,\n"
  352. "};\n"
  353. "typedef struct b3Collidable b3Collidable_t;\n"
  354. "struct b3Collidable\n"
  355. "{\n"
  356. " union {\n"
  357. " int m_numChildShapes;\n"
  358. " int m_bvhIndex;\n"
  359. " };\n"
  360. " union\n"
  361. " {\n"
  362. " float m_radius;\n"
  363. " int m_compoundBvhIndex;\n"
  364. " };\n"
  365. " int m_shapeType;\n"
  366. " union\n"
  367. " {\n"
  368. " int m_shapeIndex;\n"
  369. " float m_height;\n"
  370. " };\n"
  371. "};\n"
  372. "typedef struct b3GpuChildShape b3GpuChildShape_t;\n"
  373. "struct b3GpuChildShape\n"
  374. "{\n"
  375. " b3Float4 m_childPosition;\n"
  376. " b3Quat m_childOrientation;\n"
  377. " union\n"
  378. " {\n"
  379. " int m_shapeIndex;//used for SHAPE_COMPOUND_OF_CONVEX_HULLS\n"
  380. " int m_capsuleAxis;\n"
  381. " };\n"
  382. " union \n"
  383. " {\n"
  384. " float m_radius;//used for childshape of SHAPE_COMPOUND_OF_SPHERES or SHAPE_COMPOUND_OF_CAPSULES\n"
  385. " int m_numChildShapes;//used for compound shape\n"
  386. " };\n"
  387. " union \n"
  388. " {\n"
  389. " float m_height;//used for childshape of SHAPE_COMPOUND_OF_CAPSULES\n"
  390. " int m_collidableShapeIndex;\n"
  391. " };\n"
  392. " int m_shapeType;\n"
  393. "};\n"
  394. "struct b3CompoundOverlappingPair\n"
  395. "{\n"
  396. " int m_bodyIndexA;\n"
  397. " int m_bodyIndexB;\n"
  398. "// int m_pairType;\n"
  399. " int m_childShapeIndexA;\n"
  400. " int m_childShapeIndexB;\n"
  401. "};\n"
  402. "#endif //B3_COLLIDABLE_H\n"
  403. "#ifndef B3_RIGIDBODY_DATA_H\n"
  404. "#define B3_RIGIDBODY_DATA_H\n"
  405. "#ifndef B3_FLOAT4_H\n"
  406. "#ifdef __cplusplus\n"
  407. "#else\n"
  408. "#endif \n"
  409. "#endif //B3_FLOAT4_H\n"
  410. "#ifndef B3_QUAT_H\n"
  411. "#ifdef __cplusplus\n"
  412. "#else\n"
  413. "#endif \n"
  414. "#endif //B3_QUAT_H\n"
  415. "#ifndef B3_MAT3x3_H\n"
  416. "#ifdef __cplusplus\n"
  417. "#else\n"
  418. "#endif\n"
  419. "#endif //B3_MAT3x3_H\n"
  420. "typedef struct b3RigidBodyData b3RigidBodyData_t;\n"
  421. "struct b3RigidBodyData\n"
  422. "{\n"
  423. " b3Float4 m_pos;\n"
  424. " b3Quat m_quat;\n"
  425. " b3Float4 m_linVel;\n"
  426. " b3Float4 m_angVel;\n"
  427. " int m_collidableIdx;\n"
  428. " float m_invMass;\n"
  429. " float m_restituitionCoeff;\n"
  430. " float m_frictionCoeff;\n"
  431. "};\n"
  432. "typedef struct b3InertiaData b3InertiaData_t;\n"
  433. "struct b3InertiaData\n"
  434. "{\n"
  435. " b3Mat3x3 m_invInertiaWorld;\n"
  436. " b3Mat3x3 m_initInvInertia;\n"
  437. "};\n"
  438. "#endif //B3_RIGIDBODY_DATA_H\n"
  439. " \n"
  440. "void b3ComputeWorldAabb( int bodyId, __global const b3RigidBodyData_t* bodies, __global const b3Collidable_t* collidables, __global const b3Aabb_t* localShapeAABB, __global b3Aabb_t* worldAabbs)\n"
  441. "{\n"
  442. " __global const b3RigidBodyData_t* body = &bodies[bodyId];\n"
  443. " b3Float4 position = body->m_pos;\n"
  444. " b3Quat orientation = body->m_quat;\n"
  445. " \n"
  446. " int collidableIndex = body->m_collidableIdx;\n"
  447. " int shapeIndex = collidables[collidableIndex].m_shapeIndex;\n"
  448. " \n"
  449. " if (shapeIndex>=0)\n"
  450. " {\n"
  451. " \n"
  452. " b3Aabb_t localAabb = localShapeAABB[collidableIndex];\n"
  453. " b3Aabb_t worldAabb;\n"
  454. " \n"
  455. " b3Float4 aabbAMinOut,aabbAMaxOut; \n"
  456. " float margin = 0.f;\n"
  457. " b3TransformAabb2(localAabb.m_minVec,localAabb.m_maxVec,margin,position,orientation,&aabbAMinOut,&aabbAMaxOut);\n"
  458. " \n"
  459. " worldAabb.m_minVec =aabbAMinOut;\n"
  460. " worldAabb.m_minIndices[3] = bodyId;\n"
  461. " worldAabb.m_maxVec = aabbAMaxOut;\n"
  462. " worldAabb.m_signedMaxIndices[3] = body[bodyId].m_invMass==0.f? 0 : 1;\n"
  463. " worldAabbs[bodyId] = worldAabb;\n"
  464. " }\n"
  465. "}\n"
  466. "#endif //B3_UPDATE_AABBS_H\n"
  467. "__kernel void initializeGpuAabbsFull( const int numNodes, __global b3RigidBodyData_t* gBodies,__global b3Collidable_t* collidables, __global b3Aabb_t* plocalShapeAABB, __global b3Aabb_t* pAABB)\n"
  468. "{\n"
  469. " int nodeID = get_global_id(0);\n"
  470. " if( nodeID < numNodes )\n"
  471. " {\n"
  472. " b3ComputeWorldAabb(nodeID, gBodies, collidables, plocalShapeAABB,pAABB);\n"
  473. " }\n"
  474. "}\n"
  475. "__kernel void clearOverlappingPairsKernel( __global int4* pairs, int numPairs)\n"
  476. "{\n"
  477. " int pairId = get_global_id(0);\n"
  478. " if( pairId< numPairs )\n"
  479. " {\n"
  480. " pairs[pairId].z = 0xffffffff;\n"
  481. " }\n"
  482. "}\n";