b3CpuNarrowPhase.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #ifndef B3_CPU_NARROWPHASE_H
  2. #define B3_CPU_NARROWPHASE_H
  3. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Collidable.h"
  4. #include "Bullet3Common/b3AlignedObjectArray.h"
  5. #include "Bullet3Common/b3Vector3.h"
  6. #include "Bullet3Collision/BroadPhaseCollision/shared/b3Aabb.h"
  7. #include "Bullet3Common/shared/b3Int4.h"
  8. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
  9. #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h"
  10. class b3CpuNarrowPhase
  11. {
  12. protected:
  13. struct b3CpuNarrowPhaseInternalData* m_data;
  14. int m_acceleratedCompanionShapeIndex;
  15. int m_planeBodyIndex;
  16. int m_static0Index;
  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. b3CpuNarrowPhase(const struct b3Config& config);
  21. virtual ~b3CpuNarrowPhase(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. virtual void computeContacts(b3AlignedObjectArray<b3Int4>& pairs, b3AlignedObjectArray<b3Aabb>& aabbsWorldSpace, b3AlignedObjectArray<b3RigidBodyData>& bodies);
  40. const struct b3RigidBodyData* getBodiesCpu() const;
  41. //struct b3RigidBodyData* getBodiesCpu();
  42. int getNumBodiesGpu() const;
  43. int getNumBodyInertiasGpu() const;
  44. const struct b3Collidable* getCollidablesCpu() const;
  45. int getNumCollidablesGpu() const;
  46. /*const struct b3Contact4* getContactsCPU() const;
  47. int getNumContactsGpu() const;
  48. */
  49. const b3AlignedObjectArray<b3Contact4Data>& getContacts() const;
  50. int getNumRigidBodies() const;
  51. int allocateCollidable();
  52. int getStatic0Index() const
  53. {
  54. return m_static0Index;
  55. }
  56. b3Collidable& getCollidableCpu(int collidableIndex);
  57. const b3Collidable& getCollidableCpu(int collidableIndex) const;
  58. const b3CpuNarrowPhaseInternalData* getInternalData() const
  59. {
  60. return m_data;
  61. }
  62. const struct b3Aabb& getLocalSpaceAabb(int collidableIndex) const;
  63. };
  64. #endif //B3_CPU_NARROWPHASE_H