diff options
Diffstat (limited to 'src/GFX/Util/Primitives.hpp')
| -rw-r--r-- | src/GFX/Util/Primitives.hpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/GFX/Util/Primitives.hpp b/src/GFX/Util/Primitives.hpp new file mode 100644 index 0000000..b96bc00 --- /dev/null +++ b/src/GFX/Util/Primitives.hpp @@ -0,0 +1,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()); + +} |
