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

« back to all changes in this revision

Viewing changes to tests/bullet/src/BulletSoftBody/btSoftBodySolverVertexBuffer.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
#ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H
 
17
#define BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H
 
18
 
 
19
 
 
20
class btVertexBufferDescriptor
 
21
{
 
22
public:
 
23
        enum BufferTypes
 
24
        {
 
25
                CPU_BUFFER,
 
26
                DX11_BUFFER,
 
27
                OPENGL_BUFFER
 
28
        };
 
29
 
 
30
protected:      
 
31
 
 
32
        bool m_hasVertexPositions;
 
33
        bool m_hasNormals;
 
34
 
 
35
        int m_vertexOffset;
 
36
        int m_vertexStride;
 
37
 
 
38
        int m_normalOffset;
 
39
        int m_normalStride;
 
40
 
 
41
public:
 
42
        btVertexBufferDescriptor()
 
43
        {
 
44
                m_hasVertexPositions = false;
 
45
                m_hasNormals = false;
 
46
                m_vertexOffset = 0;
 
47
                m_vertexStride = 0;
 
48
                m_normalOffset = 0;
 
49
                m_normalStride = 0;
 
50
        }
 
51
 
 
52
        virtual ~btVertexBufferDescriptor()
 
53
        {
 
54
 
 
55
        }
 
56
 
 
57
        virtual bool hasVertexPositions() const
 
58
        {
 
59
                return m_hasVertexPositions;
 
60
        }
 
61
 
 
62
        virtual bool hasNormals() const
 
63
        {
 
64
                return m_hasNormals;
 
65
        }
 
66
 
 
67
        /**
 
68
         * Return the type of the vertex buffer descriptor.
 
69
         */
 
70
        virtual BufferTypes getBufferType() const = 0;
 
71
 
 
72
        /**
 
73
         * Return the vertex offset in floats from the base pointer.
 
74
         */
 
75
        virtual int getVertexOffset() const
 
76
        {
 
77
                return m_vertexOffset;
 
78
        }
 
79
 
 
80
        /**
 
81
         * Return the vertex stride in number of floats between vertices.
 
82
         */
 
83
        virtual int getVertexStride() const
 
84
        {
 
85
                return m_vertexStride;
 
86
        }
 
87
 
 
88
        /**
 
89
         * Return the vertex offset in floats from the base pointer.
 
90
         */
 
91
        virtual int getNormalOffset() const
 
92
        {
 
93
                return m_normalOffset;
 
94
        }
 
95
 
 
96
        /**
 
97
         * Return the vertex stride in number of floats between vertices.
 
98
         */
 
99
        virtual int getNormalStride() const
 
100
        {
 
101
                return m_normalStride;
 
102
        }
 
103
};
 
104
 
 
105
 
 
106
class btCPUVertexBufferDescriptor : public btVertexBufferDescriptor
 
107
{
 
108
protected:
 
109
        float *m_basePointer;
 
110
 
 
111
public:
 
112
        /**
 
113
         * vertexBasePointer is pointer to beginning of the buffer.
 
114
         * vertexOffset is the offset in floats to the first vertex.
 
115
         * vertexStride is the stride in floats between vertices.
 
116
         */
 
117
        btCPUVertexBufferDescriptor( float *basePointer, int vertexOffset, int vertexStride )
 
118
        {
 
119
                m_basePointer = basePointer;
 
120
                m_vertexOffset = vertexOffset;
 
121
                m_vertexStride = vertexStride;
 
122
                m_hasVertexPositions = true;
 
123
        }
 
124
 
 
125
        /**
 
126
         * vertexBasePointer is pointer to beginning of the buffer.
 
127
         * vertexOffset is the offset in floats to the first vertex.
 
128
         * vertexStride is the stride in floats between vertices.
 
129
         */
 
130
        btCPUVertexBufferDescriptor( float *basePointer, int vertexOffset, int vertexStride, int normalOffset, int normalStride )
 
131
        {
 
132
                m_basePointer = basePointer;
 
133
 
 
134
                m_vertexOffset = vertexOffset;
 
135
                m_vertexStride = vertexStride;
 
136
                m_hasVertexPositions = true;
 
137
 
 
138
                m_normalOffset = normalOffset;
 
139
                m_normalStride = normalStride;
 
140
                m_hasNormals = true;
 
141
        }
 
142
 
 
143
        virtual ~btCPUVertexBufferDescriptor()
 
144
        {
 
145
 
 
146
        }
 
147
 
 
148
        /**
 
149
         * Return the type of the vertex buffer descriptor.
 
150
         */
 
151
        virtual BufferTypes getBufferType() const
 
152
        {
 
153
                return CPU_BUFFER;
 
154
        }
 
155
 
 
156
        /**
 
157
         * Return the base pointer in memory to the first vertex.
 
158
         */
 
159
        virtual float *getBasePointer() const
 
160
        {
 
161
                return m_basePointer;
 
162
        }
 
163
};
 
164
 
 
165
#endif // #ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H