2017-08-01 12:30:58 +00:00
|
|
|
#ifndef B3_GPU_NARROWPHASE_H
|
|
|
|
#define B3_GPU_NARROWPHASE_H
|
|
|
|
|
|
|
|
#include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
|
|
|
|
#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
|
|
|
|
#include "Bullet3Common/b3AlignedObjectArray.h"
|
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
|
|
|
|
|
|
|
class b3GpuNarrowPhase
|
|
|
|
{
|
|
|
|
protected:
|
2019-01-03 13:26:51 +00:00
|
|
|
struct b3GpuNarrowPhaseInternalData* m_data;
|
2017-08-01 12:30:58 +00:00
|
|
|
int m_acceleratedCompanionShapeIndex;
|
|
|
|
int m_planeBodyIndex;
|
2019-01-03 13:26:51 +00:00
|
|
|
int m_static0Index;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
cl_context m_context;
|
|
|
|
cl_device_id m_device;
|
|
|
|
cl_command_queue m_queue;
|
|
|
|
|
|
|
|
int registerConvexHullShapeInternal(class b3ConvexUtility* convexPtr, b3Collidable& col);
|
|
|
|
int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
|
|
|
|
|
|
|
|
public:
|
|
|
|
b3GpuNarrowPhase(cl_context vtx, cl_device_id dev, cl_command_queue q, const struct b3Config& config);
|
|
|
|
|
|
|
|
virtual ~b3GpuNarrowPhase(void);
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int registerSphereShape(float radius);
|
|
|
|
int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
|
|
|
|
int registerFace(const b3Vector3& faceNormal, float faceConstant);
|
2019-01-03 13:26:51 +00:00
|
|
|
|
|
|
|
int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
|
|
|
|
|
2017-08-01 12:30:58 +00:00
|
|
|
//do they need to be merged?
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int registerConvexHullShape(b3ConvexUtility* utilPtr);
|
|
|
|
int registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
|
|
|
|
|
|
|
|
int registerRigidBody(int collidableIndex, float mass, const float* position, const float* orientation, const float* aabbMin, const float* aabbMax, bool writeToGpu);
|
|
|
|
void setObjectTransform(const float* position, const float* orientation, int bodyIndex);
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void writeAllBodiesToGpu();
|
|
|
|
void reset();
|
|
|
|
void readbackAllBodiesToCpu();
|
|
|
|
bool getObjectTransformFromCpu(float* position, float* orientation, int bodyIndex) const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
void setObjectTransformCpu(float* position, float* orientation, int bodyIndex);
|
2017-08-01 12:30:58 +00:00
|
|
|
void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
|
|
|
|
|
|
|
|
virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects);
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
cl_mem getBodiesGpu();
|
2017-08-01 12:30:58 +00:00
|
|
|
const struct b3RigidBodyData* getBodiesCpu() const;
|
|
|
|
//struct b3RigidBodyData* getBodiesCpu();
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
int getNumBodiesGpu() const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
cl_mem getBodyInertiasGpu();
|
|
|
|
int getNumBodyInertiasGpu() const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
cl_mem getCollidablesGpu();
|
2017-08-01 12:30:58 +00:00
|
|
|
const struct b3Collidable* getCollidablesCpu() const;
|
2019-01-03 13:26:51 +00:00
|
|
|
int getNumCollidablesGpu() const;
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
const struct b3SapAabb* getLocalSpaceAabbsCpu() const;
|
|
|
|
|
|
|
|
const struct b3Contact4* getContactsCPU() const;
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
cl_mem getContactsGpu();
|
|
|
|
int getNumContactsGpu() const;
|
|
|
|
|
|
|
|
cl_mem getAabbLocalSpaceBufferGpu();
|
2017-08-01 12:30:58 +00:00
|
|
|
|
|
|
|
int getNumRigidBodies() const;
|
|
|
|
|
|
|
|
int allocateCollidable();
|
|
|
|
|
|
|
|
int getStatic0Index() const
|
|
|
|
{
|
|
|
|
return m_static0Index;
|
|
|
|
}
|
|
|
|
b3Collidable& getCollidableCpu(int collidableIndex);
|
|
|
|
const b3Collidable& getCollidableCpu(int collidableIndex) const;
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
const b3GpuNarrowPhaseInternalData* getInternalData() const
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
return m_data;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
b3GpuNarrowPhaseInternalData* getInternalData()
|
2017-08-01 12:30:58 +00:00
|
|
|
{
|
2019-01-03 13:26:51 +00:00
|
|
|
return m_data;
|
2017-08-01 12:30:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
|
|
|
|
};
|
|
|
|
|
2019-01-03 13:26:51 +00:00
|
|
|
#endif //B3_GPU_NARROWPHASE_H
|