1 #ifndef B3_CPU_NARROWPHASE_H
2 #define B3_CPU_NARROWPHASE_H
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"
12 class b3CpuNarrowPhase
15 struct b3CpuNarrowPhaseInternalData* m_data;
16 int m_acceleratedCompanionShapeIndex;
20 int registerConvexHullShapeInternal(class b3ConvexUtility* convexPtr, b3Collidable& col);
21 int registerConcaveMeshShape(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, b3Collidable& col, const float* scaling);
24 b3CpuNarrowPhase(const struct b3Config& config);
26 virtual ~b3CpuNarrowPhase(void);
28 int registerSphereShape(float radius);
29 int registerPlaneShape(const b3Vector3& planeNormal, float planeConstant);
31 int registerCompoundShape(b3AlignedObjectArray<b3GpuChildShape>* childShapes);
32 int registerFace(const b3Vector3& faceNormal, float faceConstant);
34 int registerConcaveMesh(b3AlignedObjectArray<b3Vector3>* vertices, b3AlignedObjectArray<int>* indices, const float* scaling);
36 //do they need to be merged?
38 int registerConvexHullShape(b3ConvexUtility* utilPtr);
39 int registerConvexHullShape(const float* vertices, int strideInBytes, int numVertices, const float* scaling);
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);
44 void writeAllBodiesToGpu();
46 void readbackAllBodiesToCpu();
47 bool getObjectTransformFromCpu(float* position, float* orientation, int bodyIndex) const;
49 void setObjectTransformCpu(float* position, float* orientation, int bodyIndex);
50 void setObjectVelocityCpu(float* linVel, float* angVel, int bodyIndex);
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);
55 const struct b3RigidBodyData* getBodiesCpu() const;
56 //struct b3RigidBodyData* getBodiesCpu();
58 int getNumBodiesGpu() const;
60 int getNumBodyInertiasGpu() const;
62 const struct b3Collidable* getCollidablesCpu() const;
63 int getNumCollidablesGpu() const;
65 /*const struct b3Contact4* getContactsCPU() const;
68 int getNumContactsGpu() const;
71 const b3AlignedObjectArray<b3Contact4Data>& getContacts() const;
73 int getNumRigidBodies() const;
75 int allocateCollidable();
77 int getStatic0Index() const
79 return m_static0Index;
81 b3Collidable& getCollidableCpu(int collidableIndex);
82 const b3Collidable& getCollidableCpu(int collidableIndex) const;
84 const b3CpuNarrowPhaseInternalData* getInternalData() const
89 const struct b3Aabb& getLocalSpaceAabb(int collidableIndex) const;
92 #endif //B3_CPU_NARROWPHASE_H