#pragma once #include #include #include "BlockType.hpp" #include "../GFX/Mesh.hpp" #include "BlockSide.hpp" #include "../GFX/Binder.hpp" namespace MC::World { class Chunk { public: static constexpr const uint32_t Width = 16; static constexpr const uint32_t Height = 64; Chunk(int64_t x, int64_t y) : m_blocks{}, m_position{(float)x * Chunk::Width, 0.0f, (float)y * Chunk::Width} {}; void set(uint32_t x, uint32_t y, uint32_t z, BlockType type); Vector<3> position(); GFX::Mesh mesh(); private: bool is_face_visible(uint32_t x, uint32_t y, uint32_t z, BlockSide side); static std::array, 4> face_tex_coords(BlockType type, BlockSide side); static std::array, 4> face_normals(BlockSide side); struct BlockData { BlockType type; }; Vector<3> m_position; BlockData m_blocks[Chunk::Width][Chunk::Height][Chunk::Width]; }; }