[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / NarrowphaseCollision / b3ConvexHullContact.h
1
2 #ifndef _CONVEX_HULL_CONTACT_H
3 #define _CONVEX_HULL_CONTACT_H
4
5 #include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
6 #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
7 #include "Bullet3Common/b3AlignedObjectArray.h"
8
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"
17
18 //#include "../../dynamics/basic_demo/Stubs/ChNarrowPhase.h"
19
20 struct GpuSatCollision
21 {
22         cl_context m_context;
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;
28
29         cl_kernel m_findSeparatingAxisVertexFaceKernel;
30         cl_kernel m_findSeparatingAxisEdgeEdgeKernel;
31
32         cl_kernel m_findConcaveSeparatingAxisKernel;
33         cl_kernel m_findConcaveSeparatingAxisVertexFaceKernel;
34         cl_kernel m_findConcaveSeparatingAxisEdgeEdgeKernel;
35
36         cl_kernel m_findCompoundPairsKernel;
37         cl_kernel m_processCompoundPairsKernel;
38
39         cl_kernel m_clipHullHullKernel;
40         cl_kernel m_clipCompoundsHullHullKernel;
41
42         cl_kernel m_clipFacesAndFindContacts;
43         cl_kernel m_findClippingFacesKernel;
44
45         cl_kernel m_clipHullHullConcaveConvexKernel;
46         //      cl_kernel                               m_extractManifoldAndAddContactKernel;
47         cl_kernel m_newContactReductionKernel;
48
49         cl_kernel m_bvhTraversalKernel;
50         cl_kernel m_primitiveContactsKernel;
51         cl_kernel m_findConcaveSphereContactsKernel;
52
53         cl_kernel m_processCompoundPairsPrimitivesKernel;
54
55         b3OpenCLArray<b3Vector3> m_unitSphereDirections;
56
57         b3OpenCLArray<int> m_totalContactsOut;
58
59         b3OpenCLArray<b3Vector3> m_sepNormals;
60         b3OpenCLArray<float> m_dmins;
61
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;
70
71         GpuSatCollision(cl_context ctx, cl_device_id device, cl_command_queue q);
72         virtual ~GpuSatCollision();
73
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,
87
88                                                                                    const b3OpenCLArray<b3Aabb>& clAabbsWorldSpace,
89                                                                                    const b3OpenCLArray<b3Aabb>& clAabbsLocalSpace,
90
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,
100                                                                                    int numObjects,
101                                                                                    int maxTriConvexPairCapacity,
102                                                                                    b3OpenCLArray<b3Int4>& triangleConvexPairs,
103                                                                                    int& numTriConvexPairsOut);
104 };
105
106 #endif  //_CONVEX_HULL_CONTACT_H