b3GpuNarrowPhase.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #ifndef B3_GPU_NARROWPHASE_H
  2. #define B3_GPU_NARROWPHASE_H
  3. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
  4. #include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
  5. #include "Bullet3Common/b3AlignedObjectArray.h"
  6. #include "Bullet3Common/b3Vector3.h"
  7. class b3GpuNarrowPhase
  8. {
  9. protected:
  10. struct b3GpuNarrowPhaseInternalData* m_data;
  11. int m_acceleratedCompanionShapeIndex;
  12. int m_planeBodyIndex;
  13. int m_static0Index;
  14. cl_context m_context;
  15. cl_device_id m_device;
  16. cl_command_queue m_queue;
  17. int registerConvexHullShapeInternal(class b3ConvexUtility* convexPtr, b3Collidable& col);
  18. int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
  19. public:
  20. b3GpuNarrowPhase(cl_context vtx, cl_device_id dev, cl_command_queue q, const struct b3Config& config);
  21. virtual ~b3GpuNarrowPhase(void);
  22. int registerSphereShape(float radius);
  23. int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
  24. int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
  25. int registerFace(const b3Vector3& faceNormal, float faceConstant);
  26. int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
  27. //do they need to be merged?
  28. int registerConvexHullShape(b3ConvexUtility* utilPtr);
  29. int registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
  30. int registerRigidBody(int collidableIndex, float mass, const float* position, const float* orientation, const float* aabbMin, const float* aabbMax, bool writeToGpu);
  31. void setObjectTransform(const float* position, const float* orientation, int bodyIndex);
  32. void writeAllBodiesToGpu();
  33. void reset();
  34. void readbackAllBodiesToCpu();
  35. bool getObjectTransformFromCpu(float* position, float* orientation, int bodyIndex) const;
  36. void setObjectTransformCpu(float* position, float* orientation, int bodyIndex);
  37. void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
  38. virtual void computeContacts(cl_mem broadphasePairs, int numBroadphasePairs, cl_mem aabbsWorldSpace, int numObjects);
  39. cl_mem getBodiesGpu();
  40. const struct b3RigidBodyData* getBodiesCpu() const;
  41. //struct b3RigidBodyData* getBodiesCpu();
  42. int getNumBodiesGpu() const;
  43. cl_mem getBodyInertiasGpu();
  44. int getNumBodyInertiasGpu() const;
  45. cl_mem getCollidablesGpu();
  46. const struct b3Collidable* getCollidablesCpu() const;
  47. int getNumCollidablesGpu() const;
  48. const struct b3SapAabb* getLocalSpaceAabbsCpu() const;
  49. const struct b3Contact4* getContactsCPU() const;
  50. cl_mem getContactsGpu();
  51. int getNumContactsGpu() const;
  52. cl_mem getAabbLocalSpaceBufferGpu();
  53. int getNumRigidBodies() const;
  54. int allocateCollidable();
  55. int getStatic0Index() const
  56. {
  57. return m_static0Index;
  58. }
  59. b3Collidable& getCollidableCpu(int collidableIndex);
  60. const b3Collidable& getCollidableCpu(int collidableIndex) const;
  61. const b3GpuNarrowPhaseInternalData* getInternalData() const
  62. {
  63. return m_data;
  64. }
  65. b3GpuNarrowPhaseInternalData* getInternalData()
  66. {
  67. return m_data;
  68. }
  69. const struct b3SapAabb& getLocalSpaceAabb(int collidableIndex) const;
  70. };
  71. #endif //B3_GPU_NARROWPHASE_H