[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-physics / third-party / bullet3 / src / BulletSoftBody / btSoftBodySolverVertexBuffer.h
1 /*
2 Bullet Continuous Collision Detection and Physics Library
3 Copyright (c) 2003-2006 Erwin Coumans  https://bulletphysics.org
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
64         /**
65          * Return the type of the vertex buffer descriptor.
66          */
67         virtual BufferTypes getBufferType() const = 0;
68
69         /**
70          * Return the vertex offset in floats from the base pointer.
71          */
72         virtual int getVertexOffset() const
73         {
74                 return m_vertexOffset;
75         }
76
77         /**
78          * Return the vertex stride in number of floats between vertices.
79          */
80         virtual int getVertexStride() const
81         {
82                 return m_vertexStride;
83         }
84
85         /**
86          * Return the vertex offset in floats from the base pointer.
87          */
88         virtual int getNormalOffset() const
89         {
90                 return m_normalOffset;
91         }
92
93         /**
94          * Return the vertex stride in number of floats between vertices.
95          */
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:
108         /**
109          * vertexBasePointer is pointer to beginning of the buffer.
110          * vertexOffset is the offset in floats to the first vertex.
111          * vertexStride is the stride in floats between vertices.
112          */
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
121         /**
122          * vertexBasePointer is pointer to beginning of the buffer.
123          * vertexOffset is the offset in floats to the first vertex.
124          * vertexStride is the stride in floats between vertices.
125          */
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
143         /**
144          * Return the type of the vertex buffer descriptor.
145          */
146         virtual BufferTypes getBufferType() const
147         {
148                 return CPU_BUFFER;
149         }
150
151         /**
152          * Return the base pointer in memory to the first vertex.
153          */
154         virtual float *getBasePointer() const
155         {
156                 return m_basePointer;
157         }
158 };
159
160 #endif  // #ifndef BT_SOFT_BODY_SOLVER_VERTEX_BUFFER_H