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