1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#pragma once
#include "../../Common/Sizes.hpp"
#include "../../Math/AABB.hpp"
#include <array>
namespace MC::GFX::Util::Primitives {
class FaceSet {
public:
enum Value : U8 {
Front = 1 << 0,
Back = 1 << 1,
Top = 1 << 2,
Bottom = 1 << 3,
Right = 1 << 4,
Left = 1 << 5,
};
static constexpr UInt Size = 6;
FaceSet() = default;
FaceSet(const Value set) : m_set(set) {}
operator Value() const { return m_set; }
static FaceSet all() {
return static_cast<Value>(Front | Back | Top | Bottom | Right | Left);
}
private:
Value m_set;
};
// A base primitive, could represent lines, triangles, quads primitives, etc.
template <uint N, uint I>
struct BasePrimitive {
std::array<Vector<3, F32>, N> positions;
std::array<Vector<3, F32>, N> normals;
std::array<U32, I> indices;
};
// Primitive made out of triangles (GL_TRIANGLES)
template <uint N>
using Primitive = BasePrimitive<N, N + N / 2>;
using PlanePrimitive = Primitive<4>;
PlanePrimitive plane(AABB aabb, FaceSet face);
using BoxPrimitive = Primitive<4 * 6>;
BoxPrimitive box(AABB aabb, FaceSet faces = FaceSet::all());
using LineBoxPrimitive = BasePrimitive<4 * 2, 4 * 6>;
LineBoxPrimitive line_box(AABB aabb);
}
|