1 
2 #ifndef B3_GPU_JACOBI_CONTACT_SOLVER_H
3 #define B3_GPU_JACOBI_CONTACT_SOLVER_H
4 #include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
5 //#include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
6 #include "Bullet3Collision/NarrowPhaseCollision/shared/b3RigidBodyData.h"
7 
8 #include "Bullet3Collision/NarrowPhaseCollision/shared/b3Contact4Data.h"
9 #include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
10 
11 //struct b3InertiaData;
12 //b3InertiaData
13 
14 class b3TypedConstraint;
15 
16 struct b3JacobiSolverInfo
17 {
18 	int m_fixedBodyIndex;
19 
20 	float m_deltaTime;
21 	float m_positionDrift;
22 	float m_positionConstraintCoeff;
23 	int m_numIterations;
24 
b3JacobiSolverInfob3JacobiSolverInfo25 	b3JacobiSolverInfo()
26 		: m_fixedBodyIndex(0),
27 		  m_deltaTime(1. / 60.f),
28 		  m_positionDrift(0.005f),
29 		  m_positionConstraintCoeff(0.99f),
30 		  m_numIterations(7)
31 	{
32 	}
33 };
34 class b3GpuJacobiContactSolver
35 {
36 protected:
37 	struct b3GpuJacobiSolverInternalData* m_data;
38 
39 	cl_context m_context;
40 	cl_device_id m_device;
41 	cl_command_queue m_queue;
42 
43 public:
44 	b3GpuJacobiContactSolver(cl_context ctx, cl_device_id device, cl_command_queue queue, int pairCapacity);
45 	virtual ~b3GpuJacobiContactSolver();
46 
47 	void solveContacts(int numBodies, cl_mem bodyBuf, cl_mem inertiaBuf, int numContacts, cl_mem contactBuf, const struct b3Config& config, int static0Index);
48 	void solveGroupHost(b3RigidBodyData* bodies, b3InertiaData* inertias, int numBodies, struct b3Contact4* manifoldPtr, int numManifolds, const b3JacobiSolverInfo& solverInfo);
49 	//void  solveGroupHost(btRigidBodyCL* bodies,b3InertiaData* inertias,int numBodies,btContact4* manifoldPtr, int numManifolds,btTypedConstraint** constraints,int numConstraints,const btJacobiSolverInfo& solverInfo);
50 
51 	//b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
52 
53 	//void  solveGroup(btOpenCLArray<btRigidBodyCL>* bodies,btOpenCLArray<btInertiaCL>* inertias,btOpenCLArray<btContact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo);
54 	//void  solveGroupMixed(btOpenCLArray<btRigidBodyCL>* bodies,btOpenCLArray<btInertiaCL>* inertias,btOpenCLArray<btContact4>* manifoldPtr,const btJacobiSolverInfo& solverInfo);
55 };
56 #endif  //B3_GPU_JACOBI_CONTACT_SOLVER_H
57