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

Bullet Collision Detection & Physics Library

btSoftBodySolverVertexBuffer.h
Go to the documentation of this file.
1/*
2Bullet Continuous Collision Detection and Physics Library
3Copyright (c) 2003-2006 Erwin Coumans https://bulletphysics.org
4
5This software is provided 'as-is', without any express or implied warranty.
6In no event will the authors be held liable for any damages arising from the use of this software.
7Permission is granted to anyone to use this software for any purpose,
8including commercial applications, and to alter it and redistribute it freely,
9subject to the following restrictions:
10
111. 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.
122. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
133. 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{
21public:
22 enum BufferTypes
23 {
24 CPU_BUFFER,
25 DX11_BUFFER,
26 OPENGL_BUFFER
27 };
28
29protected:
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
39public:
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{
104protected:
105 float *m_basePointer;
106
107public:
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
btCPUVertexBufferDescriptor::btCPUVertexBufferDescriptor
btCPUVertexBufferDescriptor(float *basePointer, int vertexOffset, int vertexStride)
vertexBasePointer is pointer to beginning of the buffer.
Definition btSoftBodySolverVertexBuffer.h:113
btCPUVertexBufferDescriptor::~btCPUVertexBufferDescriptor
virtual ~btCPUVertexBufferDescriptor()
Definition btSoftBodySolverVertexBuffer.h:139
btCPUVertexBufferDescriptor::m_basePointer
float * m_basePointer
Definition btSoftBodySolverVertexBuffer.h:105
btCPUVertexBufferDescriptor::getBasePointer
virtual float * getBasePointer() const
Return the base pointer in memory to the first vertex.
Definition btSoftBodySolverVertexBuffer.h:154
btCPUVertexBufferDescriptor::getBufferType
virtual BufferTypes getBufferType() const
Return the type of the vertex buffer descriptor.
Definition btSoftBodySolverVertexBuffer.h:146
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::m_vertexOffset
int m_vertexOffset
Definition btSoftBodySolverVertexBuffer.h:33
btVertexBufferDescriptor::getBufferType
virtual BufferTypes getBufferType() const =0
Return the type of the vertex buffer descriptor.
btVertexBufferDescriptor::hasVertexPositions
virtual bool hasVertexPositions() const
Definition btSoftBodySolverVertexBuffer.h:54
btVertexBufferDescriptor::getNormalOffset
virtual int getNormalOffset() const
Return the vertex offset in floats from the base pointer.
Definition btSoftBodySolverVertexBuffer.h:88
btVertexBufferDescriptor::m_hasVertexPositions
bool m_hasVertexPositions
Definition btSoftBodySolverVertexBuffer.h:30
btVertexBufferDescriptor::getVertexOffset
virtual int getVertexOffset() const
Return the vertex offset in floats from the base pointer.
Definition btSoftBodySolverVertexBuffer.h:72
btVertexBufferDescriptor::hasNormals
virtual bool hasNormals() const
Definition btSoftBodySolverVertexBuffer.h:59
btVertexBufferDescriptor::btVertexBufferDescriptor
btVertexBufferDescriptor()
Definition btSoftBodySolverVertexBuffer.h:40
btVertexBufferDescriptor::getNormalStride
virtual int getNormalStride() const
Return the vertex stride in number of floats between vertices.
Definition btSoftBodySolverVertexBuffer.h:96
btVertexBufferDescriptor::BufferTypes
BufferTypes
Definition btSoftBodySolverVertexBuffer.h:23
btVertexBufferDescriptor::OPENGL_BUFFER
@ OPENGL_BUFFER
Definition btSoftBodySolverVertexBuffer.h:26
btVertexBufferDescriptor::CPU_BUFFER
@ CPU_BUFFER
Definition btSoftBodySolverVertexBuffer.h:24
btVertexBufferDescriptor::DX11_BUFFER
@ DX11_BUFFER
Definition btSoftBodySolverVertexBuffer.h:25
btVertexBufferDescriptor::~btVertexBufferDescriptor
virtual ~btVertexBufferDescriptor()
Definition btSoftBodySolverVertexBuffer.h:50
btVertexBufferDescriptor::m_hasNormals
bool m_hasNormals
Definition btSoftBodySolverVertexBuffer.h:31
btVertexBufferDescriptor::m_normalOffset
int m_normalOffset
Definition btSoftBodySolverVertexBuffer.h:36
btVertexBufferDescriptor::getVertexStride
virtual int getVertexStride() const
Return the vertex stride in number of floats between vertices.
Definition btSoftBodySolverVertexBuffer.h:80
btVertexBufferDescriptor::m_vertexStride
int m_vertexStride
Definition btSoftBodySolverVertexBuffer.h:34
btVertexBufferDescriptor::m_normalStride
int m_normalStride
Definition btSoftBodySolverVertexBuffer.h:37