00001 /* 00002 Bullet Continuous Collision Detection and Physics Library 00003 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ 00004 00005 This software is provided 'as-is', without any express or implied warranty. 00006 In no event will the authors be held liable for any damages arising from the use of this software. 00007 Permission is granted to anyone to use this software for any purpose, 00008 including commercial applications, and to alter it and redistribute it freely, 00009 subject to the following restrictions: 00010 00011 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. 00012 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 00013 3. This notice may not be removed or altered from any source distribution. 00014 */ 00015 00016 #include "BulletMultiThreaded/GpuSoftBodySolvers/Shared/btSoftBodySolverData.h" 00017 #include "btSoftBodySolverBuffer_OpenCL.h" 00018 00019 00020 #ifndef BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H 00021 #define BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H 00022 00023 00024 class btSoftBodyLinkDataOpenCL : public btSoftBodyLinkData 00025 { 00026 public: 00027 bool m_onGPU; 00028 00029 cl_command_queue m_cqCommandQue; 00030 00031 00032 btOpenCLBuffer<LinkNodePair> m_clLinks; 00033 btOpenCLBuffer<float> m_clLinkStrength; 00034 btOpenCLBuffer<float> m_clLinksMassLSC; 00035 btOpenCLBuffer<float> m_clLinksRestLengthSquared; 00036 btOpenCLBuffer<Vectormath::Aos::Vector3> m_clLinksCLength; 00037 btOpenCLBuffer<float> m_clLinksLengthRatio; 00038 btOpenCLBuffer<float> m_clLinksRestLength; 00039 btOpenCLBuffer<float> m_clLinksMaterialLinearStiffnessCoefficient; 00040 00041 struct BatchPair 00042 { 00043 int start; 00044 int length; 00045 00046 BatchPair() : 00047 start(0), 00048 length(0) 00049 { 00050 } 00051 00052 BatchPair( int s, int l ) : 00053 start( s ), 00054 length( l ) 00055 { 00056 } 00057 }; 00058 00063 btAlignedObjectArray< int > m_linkAddresses; 00064 00068 btAlignedObjectArray< BatchPair > m_batchStartLengths; 00069 00070 btSoftBodyLinkDataOpenCL(cl_command_queue queue, cl_context ctx); 00071 00072 virtual ~btSoftBodyLinkDataOpenCL(); 00073 00075 virtual void createLinks( int numLinks ); 00076 00078 virtual void setLinkAt( 00079 const LinkDescription &link, 00080 int linkIndex ); 00081 00082 virtual bool onAccelerator(); 00083 00084 virtual bool moveToAccelerator(); 00085 00086 virtual bool moveFromAccelerator(); 00087 00094 void generateBatches(); 00095 }; 00096 00097 00098 00099 #endif // #ifndef BT_SOFT_BODY_SOLVER_LINK_DATA_OPENCL_H