OSDN Git Service

merge from MikuMikuStudio nativebullet.
[mikumikustudio/libgdx-mikumikustudio.git] / extensions / gdx-bullet / jni / src / bullet / BulletMultiThreaded / GpuSoftBodySolvers / OpenCL / btSoftBodySolver_OpenCLSIMDAware.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  http://continuousphysics.com/Bullet/
4
5 This software is provided 'as-is', without any express or implied warranty.
6 In no event will the authors be held liable for any damages arising from the use of this software.
7 Permission is granted to anyone to use this software for any purpose, 
8 including commercial applications, and to alter it and redistribute it freely, 
9 subject to the following restrictions:
10
11 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
12 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
13 3. This notice may not be removed or altered from any source distribution.
14 */
15
16 #ifndef BT_SOFT_BODY_SOLVER_OPENCL_SIMDAWARE_H
17 #define BT_SOFT_BODY_SOLVER_OPENCL_SIMDAWARE_H
18
19 #include "stddef.h" //for size_t
20 #include "vectormath/vmInclude.h"
21
22 #include "btSoftBodySolver_OpenCL.h"
23 #include "btSoftBodySolverBuffer_OpenCL.h"
24 #include "btSoftBodySolverLinkData_OpenCLSIMDAware.h"
25 #include "btSoftBodySolverVertexData_OpenCL.h"
26 #include "btSoftBodySolverTriangleData_OpenCL.h"
27
28
29
30
31
32 class btOpenCLSoftBodySolverSIMDAware : public btOpenCLSoftBodySolver
33 {
34 protected:
35         
36
37         btSoftBodyLinkDataOpenCLSIMDAware m_linkData;
38
39
40
41
42         virtual bool buildShaders();
43
44
45         void updateConstants( float timeStep );
46
47         float computeTriangleArea( 
48                 const Vectormath::Aos::Point3 &vertex0,
49                 const Vectormath::Aos::Point3 &vertex1,
50                 const Vectormath::Aos::Point3 &vertex2 );
51
52
53         //////////////////////////////////////
54         // Kernel dispatches
55         void solveLinksForPosition( int startLink, int numLinks, float kst, float ti );
56         
57         void solveCollisionsAndUpdateVelocities( float isolverdt );
58         // End kernel dispatches
59         /////////////////////////////////////
60
61 public:
62         btOpenCLSoftBodySolverSIMDAware(cl_command_queue queue,cl_context       ctx, bool bUpdateAchchoredNodePos = false);
63
64         virtual ~btOpenCLSoftBodySolverSIMDAware();
65
66         virtual SolverTypes getSolverType() const
67         {
68                 return CL_SIMD_SOLVER;
69         }
70
71
72         virtual btSoftBodyLinkData &getLinkData();
73
74
75         virtual void optimize( btAlignedObjectArray< btSoftBody * > &softBodies , bool forceUpdate=false);
76
77         virtual void solveConstraints( float solverdt );
78
79 }; // btOpenCLSoftBodySolverSIMDAware
80
81 #endif // #ifndef BT_SOFT_BODY_SOLVER_OPENCL_SIMDAWARE_H