Bullet Collision Detection & Physics Library: btSoftBodySolverVertexBuffer.h Source File

Bullet Collision Detection & Physics Library

btSoftBodySolverVertexBuffer.h
Go to the documentation of this file.
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 class btVertexBufferDescriptor
20 {
21 public:
22 enum BufferTypes
23 {
24 CPU_BUFFER,
25 DX11_BUFFER,
26 OPENGL_BUFFER
27 };
28
29 protected:
30 bool m_hasVertexPositions;
31 bool m_hasNormals;
32
33 int m_vertexOffset;
34 int m_vertexStride;
35
36 int m_normalOffset;
37 int m_normalStride;
38
39 public:
40 btVertexBufferDescriptor()
41 {
42 m_hasVertexPositions = false;
43 m_hasNormals = false;
44 m_vertexOffset = 0;
45 m_vertexStride = 0;
46 m_normalOffset = 0;
47 m_normalStride = 0;
48 }
49
50 virtual ~btVertexBufferDescriptor()
51 {
52 }
53
54 virtual bool hasVertexPositions() const
55 {
56 return m_hasVertexPositions;
57 }
58
59 virtual bool hasNormals() const
60 {
61 return m_hasNormals;
62 }
63
67 virtual BufferTypes getBufferType() const = 0;
68
72 virtual int getVertexOffset() const
73 {
74 return m_vertexOffset;
75 }
76
80 virtual int getVertexStride() const
81 {
82 return m_vertexStride;
83 }
84
88 virtual int getNormalOffset() const
89 {
90 return m_normalOffset;
91 }
92
96 virtual int getNormalStride() const
97 {
98 return m_normalStride;
99 }
100 };
101
102 class btCPUVertexBufferDescriptor : public btVertexBufferDescriptor
103 {
104 protected:
105 float *m_basePointer;
106
107 public:
113 btCPUVertexBufferDescriptor(float *basePointer, int vertexOffset, int vertexStride)
114 {
115 m_basePointer = basePointer;
116 m_vertexOffset = vertexOffset;
117 m_vertexStride = vertexStride;
118 m_hasVertexPositions = true;
119 }
120
126 btCPUVertexBufferDescriptor(float *basePointer, int vertexOffset, int vertexStride, int normalOffset, int normalStride)
127 {
128 m_basePointer = basePointer;
129
130 m_vertexOffset = vertexOffset;
131 m_vertexStride = vertexStride;
132 m_hasVertexPositions = true;
133
134 m_normalOffset = normalOffset;
135 m_normalStride = normalStride;
136 m_hasNormals = true;
137 }
138
139 virtual ~btCPUVertexBufferDescriptor()
140 {
141 }
142
146 virtual BufferTypes getBufferType() const
147 {
148 return CPU_BUFFER;
149 }
150
154 virtual float *getBasePointer() const
155 {
156 return m_basePointer;
157 }
158 };
159
160 #endif // #ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H
btVertexBufferDescriptor::DX11_BUFFER
Definition: btSoftBodySolverVertexBuffer.h:25
btVertexBufferDescriptor::OPENGL_BUFFER
Definition: btSoftBodySolverVertexBuffer.h:26
btVertexBufferDescriptor::getVertexStride
virtual int getVertexStride() const
Return the vertex stride in number of floats between vertices.
Definition: btSoftBodySolverVertexBuffer.h:80
btVertexBufferDescriptor::getBufferType
virtual BufferTypes getBufferType() const =0
Return the type of the vertex buffer descriptor.
btCPUVertexBufferDescriptor::btCPUVertexBufferDescriptor
btCPUVertexBufferDescriptor(float *basePointer, int vertexOffset, int vertexStride, int normalOffset, int normalStride)
vertexBasePointer is pointer to beginning of the buffer.
Definition: btSoftBodySolverVertexBuffer.h:126
btVertexBufferDescriptor::getNormalOffset
virtual int getNormalOffset() const
Return the vertex offset in floats from the base pointer.
Definition: btSoftBodySolverVertexBuffer.h:88
btCPUVertexBufferDescriptor::btCPUVertexBufferDescriptor
btCPUVertexBufferDescriptor(float *basePointer, int vertexOffset, int vertexStride)
vertexBasePointer is pointer to beginning of the buffer.
Definition: btSoftBodySolverVertexBuffer.h:113
btVertexBufferDescriptor::m_normalStride
int m_normalStride
Definition: btSoftBodySolverVertexBuffer.h:37
btCPUVertexBufferDescriptor::~btCPUVertexBufferDescriptor
virtual ~btCPUVertexBufferDescriptor()
Definition: btSoftBodySolverVertexBuffer.h:139
btVertexBufferDescriptor::CPU_BUFFER
Definition: btSoftBodySolverVertexBuffer.h:24
btVertexBufferDescriptor::m_normalOffset
int m_normalOffset
Definition: btSoftBodySolverVertexBuffer.h:36
btVertexBufferDescriptor::m_hasVertexPositions
bool m_hasVertexPositions
Definition: btSoftBodySolverVertexBuffer.h:30
btCPUVertexBufferDescriptor::getBufferType
virtual BufferTypes getBufferType() const
Return the type of the vertex buffer descriptor.
Definition: btSoftBodySolverVertexBuffer.h:146
btVertexBufferDescriptor::hasNormals
virtual bool hasNormals() const
Definition: btSoftBodySolverVertexBuffer.h:59
btVertexBufferDescriptor::getNormalStride
virtual int getNormalStride() const
Return the vertex stride in number of floats between vertices.
Definition: btSoftBodySolverVertexBuffer.h:96
btVertexBufferDescriptor::~btVertexBufferDescriptor
virtual ~btVertexBufferDescriptor()
Definition: btSoftBodySolverVertexBuffer.h:50
btVertexBufferDescriptor::BufferTypes
BufferTypes
Definition: btSoftBodySolverVertexBuffer.h:22
btVertexBufferDescriptor::btVertexBufferDescriptor
btVertexBufferDescriptor()
Definition: btSoftBodySolverVertexBuffer.h:40
btCPUVertexBufferDescriptor::getBasePointer
virtual float * getBasePointer() const
Return the base pointer in memory to the first vertex.
Definition: btSoftBodySolverVertexBuffer.h:154
btVertexBufferDescriptor::m_hasNormals
bool m_hasNormals
Definition: btSoftBodySolverVertexBuffer.h:31
btVertexBufferDescriptor::m_vertexStride
int m_vertexStride
Definition: btSoftBodySolverVertexBuffer.h:34
btVertexBufferDescriptor::m_vertexOffset
int m_vertexOffset
Definition: btSoftBodySolverVertexBuffer.h:33
btCPUVertexBufferDescriptor::m_basePointer
float * m_basePointer
Definition: btSoftBodySolverVertexBuffer.h:105
btCPUVertexBufferDescriptor
Definition: btSoftBodySolverVertexBuffer.h:102
btVertexBufferDescriptor::getVertexOffset
virtual int getVertexOffset() const
Return the vertex offset in floats from the base pointer.
Definition: btSoftBodySolverVertexBuffer.h:72
btVertexBufferDescriptor::hasVertexPositions
virtual bool hasVertexPositions() const
Definition: btSoftBodySolverVertexBuffer.h:54
btVertexBufferDescriptor
Definition: btSoftBodySolverVertexBuffer.h:19