1 #ifndef B3_GPU_NARROWPHASE_H
2 #define B3_GPU_NARROWPHASE_H
4 #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
5 #include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
6 #include "Bullet3Common/b3AlignedObjectArray.h"
7 #include "Bullet3Common/b3Vector3.h"
12 struct b3GpuNarrowPhaseInternalData* m_data;
13 int m_acceleratedCompanionShapeIndex;
18 cl_device_id m_device;
19 cl_command_queue m_queue;
21 int registerConvexHullShapeInternal(class b3ConvexUtility* convexPtr, b3Collidable& col);
22 int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
25 b3GpuNarrowPhase(cl_context vtx, cl_device_id dev, cl_command_queue q, const struct b3Config& config);
27 virtual ~b3GpuNarrowPhase(void);
29 int registerSphereShape(float radius);
30 int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
32 int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
33 int registerFace(const b3Vector3& faceNormal, float faceConstant);
35 int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
37 //do they need to be merged?
39 int registerConvexHullShape(b3ConvexUtility* utilPtr);
40 int registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
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);
45 void writeAllBodiesToGpu();
47 void readbackAllBodiesToCpu();
48 bool getObjectTransformFromCpu(float* position, float* orientation, int bodyIndex) const;
50 void setObjectTransformCpu(float* position, float* orientation, int bodyIndex);
51 void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
53 virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects);
55 cl_mem getBodiesGpu();
56 const struct b3RigidBodyData* getBodiesCpu() const;
57 //struct b3RigidBodyData* getBodiesCpu();
59 int getNumBodiesGpu() const;
61 cl_mem getBodyInertiasGpu();
62 int getNumBodyInertiasGpu() const;
64 cl_mem getCollidablesGpu();
65 const struct b3Collidable* getCollidablesCpu() const;
66 int getNumCollidablesGpu() const;
68 const struct b3SapAabb* getLocalSpaceAabbsCpu() const;
70 const struct b3Contact4* getContactsCPU() const;
72 cl_mem getContactsGpu();
73 int getNumContactsGpu() const;
75 cl_mem getAabbLocalSpaceBufferGpu();
77 int getNumRigidBodies() const;
79 int allocateCollidable();
81 int getStatic0Index() const
83 return m_static0Index;
85 b3Collidable& getCollidableCpu(int collidableIndex);
86 const b3Collidable& getCollidableCpu(int collidableIndex) const;
88 const b3GpuNarrowPhaseInternalData* getInternalData() const
93 b3GpuNarrowPhaseInternalData* getInternalData()
98 const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
101 #endif //B3_GPU_NARROWPHASE_H