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