~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletMultiThreaded/GpuSoftBodySolvers/DX11/btSoftBodySolverTriangleData_DX11.h

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
#include "BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolverData.h"
 
17
#include "btSoftBodySolverBuffer_DX11.h"
 
18
 
 
19
 
 
20
#ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H
 
21
#define BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H
 
22
 
 
23
struct ID3D11Device;
 
24
struct ID3D11DeviceContext;
 
25
 
 
26
class btSoftBodyTriangleDataDX11 : public btSoftBodyTriangleData
 
27
{
 
28
public:
 
29
        bool                            m_onGPU;
 
30
        ID3D11Device            *m_d3dDevice;
 
31
        ID3D11DeviceContext *m_d3dDeviceContext;
 
32
 
 
33
        btDX11Buffer<btSoftBodyTriangleData::TriangleNodeSet>                                                   m_dx11VertexIndices;
 
34
        btDX11Buffer<float>                                                                     m_dx11Area;
 
35
        btDX11Buffer<Vectormath::Aos::Vector3>                          m_dx11Normal;
 
36
 
 
37
        struct BatchPair
 
38
        {
 
39
                int start;
 
40
                int length;
 
41
 
 
42
                BatchPair() :
 
43
                        start(0),
 
44
                        length(0)
 
45
                {
 
46
                }
 
47
 
 
48
                BatchPair( int s, int l ) : 
 
49
                        start( s ),
 
50
                        length( l )
 
51
                {
 
52
                }
 
53
        };
 
54
 
 
55
 
 
56
        /**
 
57
         * Link addressing information for each cloth.
 
58
         * Allows link locations to be computed independently of data batching.
 
59
         */
 
60
        btAlignedObjectArray< int >                                                     m_triangleAddresses;
 
61
 
 
62
        /**
 
63
         * Start and length values for computation batches over link data.
 
64
         */
 
65
        btAlignedObjectArray< BatchPair >               m_batchStartLengths;
 
66
 
 
67
        //ID3D11Buffer*               readBackBuffer;
 
68
 
 
69
public:
 
70
        btSoftBodyTriangleDataDX11( ID3D11Device *d3dDevice, ID3D11DeviceContext *d3dDeviceContext );
 
71
 
 
72
        virtual ~btSoftBodyTriangleDataDX11();
 
73
 
 
74
 
 
75
        /** Allocate enough space in all link-related arrays to fit numLinks links */
 
76
        virtual void createTriangles( int numTriangles );
 
77
        
 
78
        /** Insert the link described into the correct data structures assuming space has already been allocated by a call to createLinks */
 
79
        virtual void setTriangleAt( const btSoftBodyTriangleData::TriangleDescription &triangle, int triangleIndex );
 
80
 
 
81
        virtual bool onAccelerator();
 
82
        virtual bool moveToAccelerator();
 
83
 
 
84
        virtual bool moveFromAccelerator();
 
85
        /**
 
86
         * Generate (and later update) the batching for the entire triangle set.
 
87
         * This redoes a lot of work because it batches the entire set when each cloth is inserted.
 
88
         * In theory we could delay it until just before we need the cloth.
 
89
         * It's a one-off overhead, though, so that is a later optimisation.
 
90
         */
 
91
        void generateBatches();
 
92
};
 
93
 
 
94
 
 
95
 
 
96
#endif // #ifndef BT_SOFT_BODY_SOLVER_TRIANGLE_DATA_DX11_H