btSoftBodySolverTriangleData_OpenCL.h

Go to the documentation of this file.
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 
00017 #include "BulletMultiThreaded/GpuSoftBodySolvers/Shared/btSoftBodySolverData.h"
00018 #include "btSoftBodySolverBuffer_OpenCL.h"
00019 
00020 
00021 #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H
00022 #define BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H
00023 
00024 
00025 class btSoftBodyTriangleDataOpenCL : public btSoftBodyTriangleData
00026 {
00027 public:
00028         bool                            m_onGPU;
00029         cl_command_queue    m_queue;
00030 
00031         btOpenCLBuffer<btSoftBodyTriangleData::TriangleNodeSet>                                 m_clVertexIndices;
00032         btOpenCLBuffer<float>                                                           m_clArea;
00033         btOpenCLBuffer<Vectormath::Aos::Vector3>                        m_clNormal;
00034 
00039         btAlignedObjectArray< int >                                                     m_triangleAddresses;
00040 
00044         struct btSomePair
00045         {
00046                 btSomePair() {}
00047                 btSomePair(int f,int s)
00048                         :first(f),second(s)
00049                 {
00050                 }
00051                 int first;
00052                 int second;
00053         };
00054         btAlignedObjectArray< btSomePair >              m_batchStartLengths;
00055 
00056 public:
00057         btSoftBodyTriangleDataOpenCL( cl_command_queue queue, cl_context ctx );
00058 
00059         virtual ~btSoftBodyTriangleDataOpenCL();
00060 
00062         virtual void createTriangles( int numTriangles );
00063         
00065         virtual void setTriangleAt( const btSoftBodyTriangleData::TriangleDescription &triangle, int triangleIndex );
00066 
00067         virtual bool onAccelerator();
00068 
00069         virtual bool moveToAccelerator();
00070 
00071         virtual bool moveFromAccelerator();
00072 
00079         void generateBatches();
00080 }; // class btSoftBodyTriangleDataOpenCL
00081 
00082 
00083 #endif // #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H
00084