b3ConvexHullContact.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #ifndef _CONVEX_HULL_CONTACT_H
  2. #define _CONVEX_HULL_CONTACT_H
  3. #include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
  4. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
  5. #include "Bullet3Common/b3AlignedObjectArray.h"
  6. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3ConvexPolyhedronData.h"
  7. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
  8. #include "Bullet3Collision/NarrowPhaseCollision/b3Contact4.h"
  9. #include "Bullet3Common/shared/b3Int2.h"
  10. #include "Bullet3Common/shared/b3Int4.h"
  11. #include "b3OptimizedBvh.h"
  12. #include "b3BvhInfo.h"
  13. #include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
  14. //#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
  15. struct GpuSatCollision
  16. {
  17. cl_context m_context;
  18. cl_device_id m_device;
  19. cl_command_queue m_queue;
  20. cl_kernel m_findSeparatingAxisKernel;
  21. cl_kernel m_mprPenetrationKernel;
  22. cl_kernel m_findSeparatingAxisUnitSphereKernel;
  23. cl_kernel m_findSeparatingAxisVertexFaceKernel;
  24. cl_kernel m_findSeparatingAxisEdgeEdgeKernel;
  25. cl_kernel m_findConcaveSeparatingAxisKernel;
  26. cl_kernel m_findConcaveSeparatingAxisVertexFaceKernel;
  27. cl_kernel m_findConcaveSeparatingAxisEdgeEdgeKernel;
  28. cl_kernel m_findCompoundPairsKernel;
  29. cl_kernel m_processCompoundPairsKernel;
  30. cl_kernel m_clipHullHullKernel;
  31. cl_kernel m_clipCompoundsHullHullKernel;
  32. cl_kernel m_clipFacesAndFindContacts;
  33. cl_kernel m_findClippingFacesKernel;
  34. cl_kernel m_clipHullHullConcaveConvexKernel;
  35. // cl_kernel m_extractManifoldAndAddContactKernel;
  36. cl_kernel m_newContactReductionKernel;
  37. cl_kernel m_bvhTraversalKernel;
  38. cl_kernel m_primitiveContactsKernel;
  39. cl_kernel m_findConcaveSphereContactsKernel;
  40. cl_kernel m_processCompoundPairsPrimitivesKernel;
  41. b3OpenCLArray<b3Vector3> m_unitSphereDirections;
  42. b3OpenCLArray<int> m_totalContactsOut;
  43. b3OpenCLArray<b3Vector3> m_sepNormals;
  44. b3OpenCLArray<float> m_dmins;
  45. b3OpenCLArray<int> m_hasSeparatingNormals;
  46. b3OpenCLArray<b3Vector3> m_concaveSepNormals;
  47. b3OpenCLArray<int> m_concaveHasSeparatingNormals;
  48. b3OpenCLArray<int> m_numConcavePairsOut;
  49. b3OpenCLArray<b3CompoundOverlappingPair> m_gpuCompoundPairs;
  50. b3OpenCLArray<b3Vector3> m_gpuCompoundSepNormals;
  51. b3OpenCLArray<int> m_gpuHasCompoundSepNormals;
  52. b3OpenCLArray<int> m_numCompoundPairsOut;
  53. GpuSatCollision(cl_context ctx, cl_device_id device, cl_command_queue q);
  54. virtual ~GpuSatCollision();
  55. void computeConvexConvexContactsGPUSAT(b3OpenCLArray<b3Int4>* pairs, int nPairs,
  56. const b3OpenCLArray<b3RigidBodyData>* bodyBuf,
  57. b3OpenCLArray<b3Contact4>* contactOut, int& nContacts,
  58. const b3OpenCLArray<b3Contact4>* oldContacts,
  59. int maxContactCapacity,
  60. int compoundPairCapacity,
  61. const b3OpenCLArray<b3ConvexPolyhedronData>& hostConvexData,
  62. const b3OpenCLArray<b3Vector3>& vertices,
  63. const b3OpenCLArray<b3Vector3>& uniqueEdges,
  64. const b3OpenCLArray<b3GpuFace>& faces,
  65. const b3OpenCLArray<int>& indices,
  66. const b3OpenCLArray<b3Collidable>& gpuCollidables,
  67. const b3OpenCLArray<b3GpuChildShape>& gpuChildShapes,
  68. const b3OpenCLArray<b3Aabb>& clAabbsWorldSpace,
  69. const b3OpenCLArray<b3Aabb>& clAabbsLocalSpace,
  70. b3OpenCLArray<b3Vector3>& worldVertsB1GPU,
  71. b3OpenCLArray<b3Int4>& clippingFacesOutGPU,
  72. b3OpenCLArray<b3Vector3>& worldNormalsAGPU,
  73. b3OpenCLArray<b3Vector3>& worldVertsA1GPU,
  74. b3OpenCLArray<b3Vector3>& worldVertsB2GPU,
  75. b3AlignedObjectArray<class b3OptimizedBvh*>& bvhData,
  76. b3OpenCLArray<b3QuantizedBvhNode>* treeNodesGPU,
  77. b3OpenCLArray<b3BvhSubtreeInfo>* subTreesGPU,
  78. b3OpenCLArray<b3BvhInfo>* bvhInfo,
  79. int numObjects,
  80. int maxTriConvexPairCapacity,
  81. b3OpenCLArray<b3Int4>& triangleConvexPairs,
  82. int& numTriConvexPairsOut);
  83. };
  84. #endif //_CONVEX_HULL_CONTACT_H