#ifndef CHUNK_H #define CHUNK_H #include #include #include #include constexpr Scop::Vec3ui CHUNK_SIZE = Scop::Vec3ui{ 32, 256, 32 }; constexpr Scop::Vec3ui CHUNK_SIZE_HALF = CHUNK_SIZE / 2 ; constexpr std::uint32_t CHUNK_VOLUME = CHUNK_SIZE.x * CHUNK_SIZE.y * CHUNK_SIZE.z; class Chunk { public: Chunk(class World& world, Scop::Vec2i offset); void GenerateChunk(); void GenerateMesh(); void UploadMesh(); [[nodiscard]] std::uint32_t GetBlock(Scop::Vec3i position) const noexcept; [[nodiscard]] inline Scop::NonOwningPtr GetActor() const noexcept { return p_actor; } [[nodiscard]] inline Scop::NonOwningPtr GetWaterActor() const noexcept { return p_water_actor; } [[nodiscard]] inline Scop::Vec2i GetPosition() const noexcept { return m_position; } ~Chunk() = default; private: std::vector m_mesh_data; std::vector m_mesh_index_data; std::vector m_water_mesh_data; std::vector m_water_mesh_index_data; std::array, CHUNK_SIZE.x * CHUNK_SIZE.z> m_data; mutable std::shared_mutex m_data_mutex; Scop::Vec2i m_offset; // In chunks Scop::Vec2i m_position; // In blocks class World& m_world; Scop::NonOwningPtr p_actor = nullptr; Scop::NonOwningPtr p_water_actor = nullptr; }; #endif