#pragma once #include "array" #include "../Math/Vector.hpp" namespace MC::World::Position { // Position within entire world. using World = Vector<3>; // Offset between block positions within single chunk. class BlockOffset : public Vector<3, I16> { public: BlockOffset(I16 x, I16 y, I16 z) : Vector(x, y, z) {} Bool fits_within_chunk() const { using namespace ChunkDimensions; return x() >= 0 && x() < Width && y() >= 0 && y() < Height && z() >= 0 && z() < Width; } }; // Position of a block within entire world. class BlockWorld : public Vector<3, I64> { public: BlockWorld(I64 x, I64 y, I64 z) : Vector(x, y, z) {} }; // Position of a block within single chunk. class BlockLocal : public Vector<3, U8> { public: BlockLocal(U8 x, U8 y, U8 z) : Vector(x, y, z) {} BlockLocal(BlockOffset offset) : BlockLocal(offset.x(), offset.y(), offset.z()) {} BlockOffset offset(BlockOffset by) { return { static_cast(x() + by.x()), static_cast(y() + by.y()), static_cast(z() + by.z()) }; } }; const std::array axis_directions = {{ {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}, }}; }