blob: b96bc00b9ac1291f05cc455b80f6b34f84cfd3f5 (
plain)
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
|
#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;
};
template <uint N>
struct Primitive {
std::array<Vector<3, F32>, N> positions;
std::array<Vector<3, F32>, N> normals;
std::array<U32, N + N / 2> indices;
};
using PlanePrimitive = Primitive<4>;
PlanePrimitive plane(Math::AABB aabb, FaceSet face);
using BoxPrimitive = Primitive<4 * 6>;
BoxPrimitive box(Math::AABB aabb, FaceSet faces = FaceSet::all());
}
|