[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / BroadphaseCollision / b3GpuParallelLinearBvhBroadphase.h
1 /*
2 This software is provided 'as-is', without any express or implied warranty.
3 In no event will the authors be held liable for any damages arising from the use of this software.
4 Permission is granted to anyone to use this software for any purpose,
5 including commercial applications, and to alter it and redistribute it freely,
6 subject to the following restrictions:
7
8 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
9 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
10 3. This notice may not be removed or altered from any source distribution.
11 */
12 //Initial Author Jackson Lee, 2014
13
14 #ifndef B3_GPU_PARALLEL_LINEAR_BVH_BROADPHASE_H
15 #define B3_GPU_PARALLEL_LINEAR_BVH_BROADPHASE_H
16
17 #include "Bullet3OpenCL/BroadphaseCollision/b3GpuBroadphaseInterface.h"
18
19 #include "b3GpuParallelLinearBvh.h"
20
21 class b3GpuParallelLinearBvhBroadphase : public b3GpuBroadphaseInterface
22 {
23         b3GpuParallelLinearBvh m_plbvh;
24
25         b3OpenCLArray<b3Int4> m_overlappingPairsGpu;
26
27         b3OpenCLArray<b3SapAabb> m_aabbsGpu;
28         b3OpenCLArray<int> m_smallAabbsMappingGpu;
29         b3OpenCLArray<int> m_largeAabbsMappingGpu;
30
31         b3AlignedObjectArray<b3SapAabb> m_aabbsCpu;
32         b3AlignedObjectArray<int> m_smallAabbsMappingCpu;
33         b3AlignedObjectArray<int> m_largeAabbsMappingCpu;
34
35 public:
36         b3GpuParallelLinearBvhBroadphase(cl_context context, cl_device_id device, cl_command_queue queue);
37         virtual ~b3GpuParallelLinearBvhBroadphase() {}
38
39         virtual void createProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask);
40         virtual void createLargeProxy(const b3Vector3& aabbMin, const b3Vector3& aabbMax, int userPtr, int collisionFilterGroup, int collisionFilterMask);
41
42         virtual void calculateOverlappingPairs(int maxPairs);
43         virtual void calculateOverlappingPairsHost(int maxPairs);
44
45         //call writeAabbsToGpu after done making all changes (createProxy etc)
46         virtual void writeAabbsToGpu();
47
48         virtual int getNumOverlap() { return m_overlappingPairsGpu.size(); }
49         virtual cl_mem getOverlappingPairBuffer() { return m_overlappingPairsGpu.getBufferCL(); }
50
51         virtual cl_mem getAabbBufferWS() { return m_aabbsGpu.getBufferCL(); }
52         virtual b3OpenCLArray<b3SapAabb>& getAllAabbsGPU() { return m_aabbsGpu; }
53
54         virtual b3OpenCLArray<b3Int4>& getOverlappingPairsGPU() { return m_overlappingPairsGpu; }
55         virtual b3OpenCLArray<int>& getSmallAabbIndicesGPU() { return m_smallAabbsMappingGpu; }
56         virtual b3OpenCLArray<int>& getLargeAabbIndicesGPU() { return m_largeAabbsMappingGpu; }
57
58         virtual b3AlignedObjectArray<b3SapAabb>& getAllAabbsCPU() { return m_aabbsCpu; }
59
60         static b3GpuBroadphaseInterface* CreateFunc(cl_context context, cl_device_id device, cl_command_queue queue)
61         {
62                 return new b3GpuParallelLinearBvhBroadphase(context, device, queue);
63         }
64 };
65
66 #endif