btSoftBodySolverTriangleData_DX11.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 #include "BulletMultiThreaded/GpuSoftBodySolvers/Shared/btSoftBodySolverData.h"
00017 #include "btSoftBodySolverBuffer_DX11.h"
00018 
00019 
00020 #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H
00021 #define BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H
00022 
00023 struct ID3D11Device;
00024 struct ID3D11DeviceContext;
00025 
00026 class btSoftBodyTriangleDataDX11 : public btSoftBodyTriangleData
00027 {
00028 public:
00029         bool                            m_onGPU;
00030         ID3D11Device            *m_d3dDevice;
00031         ID3D11DeviceContext *m_d3dDeviceContext;
00032 
00033         btDX11Buffer<btSoftBodyTriangleData::TriangleNodeSet>                                                   m_dx11VertexIndices;
00034         btDX11Buffer<float>                                                                     m_dx11Area;
00035         btDX11Buffer<Vectormath::Aos::Vector3>                          m_dx11Normal;
00036 
00037         struct BatchPair
00038         {
00039                 int start;
00040                 int length;
00041 
00042                 BatchPair() :
00043                         start(0),
00044                         length(0)
00045                 {
00046                 }
00047 
00048                 BatchPair( int s, int l ) : 
00049                         start( s ),
00050                         length( l )
00051                 {
00052                 }
00053         };
00054 
00055 
00060         btAlignedObjectArray< int >                                                     m_triangleAddresses;
00061 
00065         btAlignedObjectArray< BatchPair >               m_batchStartLengths;
00066 
00067         //ID3D11Buffer*               readBackBuffer;
00068 
00069 public:
00070         btSoftBodyTriangleDataDX11( ID3D11Device *d3dDevice, ID3D11DeviceContext *d3dDeviceContext );
00071 
00072         virtual ~btSoftBodyTriangleDataDX11();
00073 
00074 
00076         virtual void createTriangles( int numTriangles );
00077         
00079         virtual void setTriangleAt( const btSoftBodyTriangleData::TriangleDescription &triangle, int triangleIndex );
00080 
00081         virtual bool onAccelerator();
00082         virtual bool moveToAccelerator();
00083 
00084         virtual bool moveFromAccelerator();
00091         void generateBatches();
00092 };
00093 
00094 
00095 
00096 #endif // #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H