X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FChunkRenderer.hpp;h=7234941b7a472128d8f685355b2eb0161213a55c;hb=1bc2f230105ad6e1ee8d999ddc079cd85d244bf9;hp=fe4f6a66d0062a6a81fac5ed5fcee89a291d62f5;hpb=9ebe2c320fd9f94266ab93fa2f9d9908a0a284d3;p=blank.git diff --git a/src/world/ChunkRenderer.hpp b/src/world/ChunkRenderer.hpp index fe4f6a6..7234941 100644 --- a/src/world/ChunkRenderer.hpp +++ b/src/world/ChunkRenderer.hpp @@ -4,7 +4,7 @@ #include "Block.hpp" #include "Chunk.hpp" #include "../graphics/ArrayTexture.hpp" -#include "../model/BlockModel.hpp" +#include "../graphics/BlockMesh.hpp" #include @@ -12,52 +12,32 @@ namespace blank { class AssetLoader; -class TextureIndex; +class BlockMesh; +class ChunkIndex; +class ResourceIndex; class Viewport; -class World; class ChunkRenderer { public: - /// render_distance in chunks, excluding the base chunk which is always rendered - ChunkRenderer(World &, int render_distance); + explicit ChunkRenderer(ChunkIndex &); + ~ChunkRenderer(); - void LoadTextures(const AssetLoader &, const TextureIndex &); + void LoadTextures(const AssetLoader &, const ResourceIndex &); void FogDensity(float d) noexcept { fog_density = d; } - bool InRange(const Chunk::Pos &) const noexcept; - int IndexOf(const Chunk::Pos &) const noexcept; + int MissingChunks() const noexcept; - int TotalChunks() const noexcept { return total_length; } - int IndexedChunks() const noexcept { return total_indexed; } - int MissingChunks() const noexcept { return total_length - total_indexed; } - - void Rebase(const Chunk::Pos &); - void Rescan(); - void Scan(); void Update(int dt); void Render(Viewport &); private: - int GetCol(int) const noexcept; - - void Shift(Block::Face); + ChunkIndex &index; + std::vector models; -private: - World &world; ArrayTexture block_tex; - int render_dist; - int side_length; - int total_length; - int total_indexed; - glm::ivec3 stride; - std::vector models; - std::vector chunks; - - Chunk::Pos base; - float fog_density; };