#pragma once #include #include #include #include #include #include #include "AssetManager.hpp" #include "Section.hpp" #include "World.hpp" #include "Vector.hpp" #include "Renderer.hpp" struct RendererSectionData { std::vector models; std::vector textures; std::vector colors; std::vector lights; size_t hash; Vector sectionPos; RendererSectionData(World *world, Vector sectionPosition); private: void AddFacesByBlockModel(const std::vector §ionsList, World *world, Vector blockPos, const BlockModel &model, glm::mat4 transform, unsigned char light, unsigned char skyLight, const std::array& visibility); std::array GetBlockVisibilityData(World *world); AssetManager& am = AssetManager::Instance(); std::vector> idModels; const BlockModel* GetInternalBlockModel(const BlockId& id); std::array blockIdData; void SetBlockIdData(World *world); inline const BlockId& GetBlockId(const Vector& pos) { return blockIdData[pos.y * 256 + pos.z * 16 + pos.x]; } inline const BlockId& GetBlockId(int x, int y, int z) { return blockIdData[y * 256 +z * 16 + x]; } }; class RendererSection { enum Vbos { MODELS = 0, TEXTURES, COLORS, LIGHTS, VBOCOUNT, }; GLuint Vao = { 0 }; GLuint Vbo[VBOCOUNT] = { 0 }; static GLuint VboVertices, VboUvs; size_t hash; Vector sectionPos; RendererSection(const RendererSection &other) = delete; public: RendererSection(RendererSectionData data); RendererSection(RendererSection &&other); ~RendererSection(); void Render(RenderState &renderState); Vector GetPosition(); size_t GetHash(); size_t numOfFaces; friend void swap(RendererSection &lhs, RendererSection &rhs); };