Merge pull request #1874 from John3/readmeUpdate
[Torque-3d.git] / Engine / lib / bullet / src / BulletMultiThreaded / GpuSoftBodySolvers / OpenCL / btSoftBodySolverTriangleData_OpenCL.h
blob7e3767855d280096b672c40bc38c48668732157f
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
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:
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.
17 #include "BulletMultiThreaded/GpuSoftBodySolvers/Shared/btSoftBodySolverData.h"
18 #include "btSoftBodySolverBuffer_OpenCL.h"
21 #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H
22 #define BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H
25 class btSoftBodyTriangleDataOpenCL : public btSoftBodyTriangleData
27 public:
28 bool m_onGPU;
29 cl_command_queue m_queue;
31 btOpenCLBuffer<btSoftBodyTriangleData::TriangleNodeSet> m_clVertexIndices;
32 btOpenCLBuffer<float> m_clArea;
33 btOpenCLBuffer<Vectormath::Aos::Vector3> m_clNormal;
35 /**
36 * Link addressing information for each cloth.
37 * Allows link locations to be computed independently of data batching.
39 btAlignedObjectArray< int > m_triangleAddresses;
41 /**
42 * Start and length values for computation batches over link data.
44 struct btSomePair
46 btSomePair() {}
47 btSomePair(int f,int s)
48 :first(f),second(s)
51 int first;
52 int second;
54 btAlignedObjectArray< btSomePair > m_batchStartLengths;
56 public:
57 btSoftBodyTriangleDataOpenCL( cl_command_queue queue, cl_context ctx );
59 virtual ~btSoftBodyTriangleDataOpenCL();
61 /** Allocate enough space in all link-related arrays to fit numLinks links */
62 virtual void createTriangles( int numTriangles );
64 /** Insert the link described into the correct data structures assuming space has already been allocated by a call to createLinks */
65 virtual void setTriangleAt( const btSoftBodyTriangleData::TriangleDescription &triangle, int triangleIndex );
67 virtual bool onAccelerator();
69 virtual bool moveToAccelerator();
71 virtual bool moveFromAccelerator();
73 /**
74 * Generate (and later update) the batching for the entire triangle set.
75 * This redoes a lot of work because it batches the entire set when each cloth is inserted.
76 * In theory we could delay it until just before we need the cloth.
77 * It's a one-off overhead, though, so that is a later optimisation.
79 void generateBatches();
80 }; // class btSoftBodyTriangleDataOpenCL
83 #endif // #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_OPENCL_H