Ocean
Loading...
Searching...
No Matches
QuadFace.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_RENDERING_QUAD_FACE_H
9#define META_OCEAN_RENDERING_QUAD_FACE_H
10
12
13#include <vector>
14
15namespace Ocean
16{
17
18namespace Rendering
19{
20
21/// Foward declaration.
22class QuadFace;
23
24/**
25 * Definition of a vector holding quad faces.
26 * @ingroup rendering
27 */
28typedef std::vector<QuadFace> QuadFaces;
29
30/**
31 * Definition of a quad face with four vertex indices.
32 * @ingroup rendering
33 */
34class OCEAN_RENDERING_EXPORT QuadFace
35{
36 public:
37
38 /**
39 * Creates a new quad face object with undefined indices.
40 */
41 inline QuadFace();
42
43 /**
44 * Creates a new quad face object with successive indices.<br>
45 * The first index is given, the following indices will be set to successive values.
46 * @param startIndex Index of the first vertex
47 */
48 inline explicit QuadFace(const VertexIndex startIndex);
49
50 /**
51 * Creates a new quad face object with four given indices.
52 * @param first First vertex index
53 * @param second Second vertex index
54 * @param third Third vertex index
55 * @param fourth Fourth vertex index
56 */
57 inline QuadFace(const VertexIndex first, const VertexIndex second, const VertexIndex third, const VertexIndex fourth);
58
59 /**
60 * Creates a new quad face object by an array of at least four indices.
61 * @param arrayValue Array with at least four vertex indices
62 */
63 inline explicit QuadFace(const VertexIndex* arrayValue);
64
65 /**
66 * Returns a specific vertex index specified by it's index inside the face.
67 * Beware: No range check will be done!
68 * @param index Index of the vertex index with range [0, 3]
69 * @return Specified vertex index
70 */
71 inline VertexIndex index(const unsigned int index) const;
72
73 /**
74 * Returns a specific vertex index specified by it's index inside the face.
75 * Beware: No range check will be done!
76 * @param index Index of the vertex index with range [0, 3]
77 * @return Specified vertex index
78 */
79 inline VertexIndex& index(const unsigned int index);
80
81 /**
82 * Returns a specific vertex index specified by it's index inside the face.
83 * Beware: No range check will be done!
84 * @param index Index of the vertex index with range [0, 3]
85 * @return Specified vertex index
86 */
87 inline VertexIndex operator[](const unsigned int index) const;
88
89 /**
90 * Returns a specific vertex index specified by it's index inside the face.
91 * Beware: No range check will be done!
92 * @param index Index of the vertex index with range [0, 3]
93 * @return Specified vertex index
94 */
95 inline VertexIndex& operator[](const unsigned int index);
96
97 /**
98 * Returns the pointer to the first element of the vertex indices.
99 * @return Array with vertex indices
100 */
101 inline const VertexIndex* operator()() const;
102
103 /**
104 * Returns the pointer to the first element of the vertex indices.
105 * @return Array with vertex indices
106 */
107 inline VertexIndex* operator()();
108
109 protected:
110
111 /// The four vertex indices.
112 VertexIndex faceIndices[4];
113};
114
116{
117 // nothing to do here
118}
119
120inline QuadFace::QuadFace(const VertexIndex startIndex)
121{
122 faceIndices[0] = startIndex;
123 faceIndices[1] = startIndex + 1;
124 faceIndices[2] = startIndex + 2;
125 faceIndices[3] = startIndex + 3;
126}
127
128inline QuadFace::QuadFace(const VertexIndex first, const VertexIndex second, const VertexIndex third, const VertexIndex fourth)
129{
130 faceIndices[0] = first;
131 faceIndices[1] = second;
132 faceIndices[2] = third;
133 faceIndices[3] = fourth;
134}
135
136inline QuadFace::QuadFace(const VertexIndex* arrayValue)
137{
138 memcpy(faceIndices, arrayValue, sizeof(VertexIndex) * 4);
139}
140
141inline VertexIndex QuadFace::index(const unsigned int index) const
142{
143 ocean_assert(index < 4);
144 return faceIndices[index];
145}
146
147inline VertexIndex& QuadFace::index(const unsigned int index)
148{
149 ocean_assert(index < 4);
150 return faceIndices[index];
151}
152
153inline VertexIndex QuadFace::operator[](const unsigned int index) const
154{
155 ocean_assert(index < 4);
156 return faceIndices[index];
157}
158
159inline VertexIndex& QuadFace::operator[](const unsigned int index)
160{
161 ocean_assert(index < 4);
162 return faceIndices[index];
163}
164
166{
167 return faceIndices;
168}
169
171{
172 return faceIndices;
173}
174
175}
176
177}
178
179#endif // META_OCEAN_RENDERING_QUAD_FACE_H
Definition of a quad face with four vertex indices.
Definition QuadFace.h:35
const VertexIndex * operator()() const
Returns the pointer to the first element of the vertex indices.
Definition QuadFace.h:165
QuadFace()
Creates a new quad face object with undefined indices.
Definition QuadFace.h:115
VertexIndex index(const unsigned int index) const
Returns a specific vertex index specified by it's index inside the face.
Definition QuadFace.h:141
VertexIndex faceIndices[4]
The four vertex indices.
Definition QuadFace.h:112
VertexIndex operator[](const unsigned int index) const
Returns a specific vertex index specified by it's index inside the face.
Definition QuadFace.h:153
std::vector< QuadFace > QuadFaces
Definition of a vector holding quad faces.
Definition QuadFace.h:28
unsigned int VertexIndex
Definition of a vertex index.
Definition rendering/Rendering.h:71
The namespace covering the entire Ocean framework.
Definition Accessor.h:15