[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / Bullet3OpenCL / RigidBody / b3GpuNarrowPhase.h
1 #ifndef B3_GPU_NARROWPHASE_H
2 #define B3_GPU_NARROWPHASE_H
3
4 #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
5 #include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
6 #include "Bullet3Common/b3AlignedObjectArray.h"
7 #include "Bullet3Common/b3Vector3.h"
8
9 class b3GpuNarrowPhase
10 {
11 protected:
12         struct b3GpuNarrowPhaseInternalData* m_data;
13         int m_acceleratedCompanionShapeIndex;
14         int m_planeBodyIndex;
15         int m_static0Index;
16
17         cl_context m_context;
18         cl_device_id m_device;
19         cl_command_queue m_queue;
20
21         int registerConvexHullShapeInternal(class b3ConvexUtility* convexPtr, b3Collidable& col);
22         int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
23
24 public:
25         b3GpuNarrowPhase(cl_context vtx, cl_device_id dev, cl_command_queue q, const struct b3Config& config);
26
27         virtual ~b3GpuNarrowPhase(void);
28
29         int registerSphereShape(float radius);
30         int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
31
32         int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
33         int registerFace(const b3Vector3& faceNormal, float faceConstant);
34
35         int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
36
37         //do they need to be merged?
38
39         int registerConvexHullShape(b3ConvexUtility* utilPtr);
40         int registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
41
42         int registerRigidBody(int collidableIndex, float mass, const float* position, const float* orientation, const float* aabbMin, const float* aabbMax, bool writeToGpu);
43         void setObjectTransform(const float* position, const float* orientation, int bodyIndex);
44
45         void writeAllBodiesToGpu();
46         void reset();
47         void readbackAllBodiesToCpu();
48         bool getObjectTransformFromCpu(float* position, float* orientation, int bodyIndex) const;
49
50         void setObjectTransformCpu(float* position, float* orientation, int bodyIndex);
51         void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
52
53         virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects);
54
55         cl_mem getBodiesGpu();
56         const struct b3RigidBodyData* getBodiesCpu() const;
57         //struct b3RigidBodyData* getBodiesCpu();
58
59         int getNumBodiesGpu() const;
60
61         cl_mem getBodyInertiasGpu();
62         int getNumBodyInertiasGpu() const;
63
64         cl_mem getCollidablesGpu();
65         const struct b3Collidable* getCollidablesCpu() const;
66         int getNumCollidablesGpu() const;
67
68         const struct b3SapAabb* getLocalSpaceAabbsCpu() const;
69
70         const struct b3Contact4* getContactsCPU() const;
71
72         cl_mem getContactsGpu();
73         int getNumContactsGpu() const;
74
75         cl_mem getAabbLocalSpaceBufferGpu();
76
77         int getNumRigidBodies() const;
78
79         int allocateCollidable();
80
81         int getStatic0Index() const
82         {
83                 return m_static0Index;
84         }
85         b3Collidable& getCollidableCpu(int collidableIndex);
86         const b3Collidable& getCollidableCpu(int collidableIndex) const;
87
88         const b3GpuNarrowPhaseInternalData* getInternalData() const
89         {
90                 return m_data;
91         }
92
93         b3GpuNarrowPhaseInternalData* getInternalData()
94         {
95                 return m_data;
96         }
97
98         const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
99 };
100
101 #endif  //B3_GPU_NARROWPHASE_H