From 71d18ae3a99140e5c2b76df3a8365e5ee9277aa8 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 17 Nov 2024 04:58:15 +0300 Subject: [PATCH] minor refactor --- src/constants.hpp | 8 +++++--- src/graphics/render/ChunksRenderer.cpp | 9 ++++----- src/graphics/render/ChunksRenderer.hpp | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/constants.hpp b/src/constants.hpp index 12e12c75..84d8b22c 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -35,9 +35,6 @@ inline constexpr int CHUNK_D = 16; inline constexpr uint VOXEL_USER_BITS = 8; inline constexpr uint VOXEL_USER_BITS_OFFSET = sizeof(blockstate_t)*8-VOXEL_USER_BITS; -/// @brief pixel size of an item inventory icon -inline constexpr int ITEM_ICON_SIZE = 48; - /// @brief chunk volume (count of voxels per Chunk) inline constexpr int CHUNK_VOL = (CHUNK_W * CHUNK_H * CHUNK_D); @@ -53,6 +50,11 @@ inline constexpr uint vox_index(uint x, uint y, uint z, uint w=CHUNK_W, uint d=C return (y * d + z) * w + x; } +/// @brief pixel size of an item inventory icon +inline constexpr int ITEM_ICON_SIZE = 48; + +inline constexpr int TRANSLUCENT_BLOCKS_SORT_INTERVAL = 8; + inline const std::string SHADERS_FOLDER = "shaders"; inline const std::string TEXTURES_FOLDER = "textures"; inline const std::string FONTS_FOLDER = "fonts"; diff --git a/src/graphics/render/ChunksRenderer.cpp b/src/graphics/render/ChunksRenderer.cpp index edbf83f3..d3686a86 100644 --- a/src/graphics/render/ChunksRenderer.cpp +++ b/src/graphics/render/ChunksRenderer.cpp @@ -14,9 +14,6 @@ #include "util/listutil.hpp" #include "settings.hpp" -#include -#include - static debug::Logger logger("chunks-render"); size_t ChunksRenderer::visibleChunks = 0; @@ -204,7 +201,9 @@ void ChunksRenderer::drawChunks( auto mesh = retrieveChunk(indices[i].index, camera, shader, culling); if (mesh) { - glm::vec3 coord(chunk->x * CHUNK_W + 0.5f, 0.5f, chunk->z * CHUNK_D + 0.5f); + glm::vec3 coord( + chunk->x * CHUNK_W + 0.5f, 0.5f, chunk->z * CHUNK_D + 0.5f + ); glm::mat4 model = glm::translate(glm::mat4(1.0f), coord); shader.uniformMatrix("u_model", model); mesh->draw(); @@ -228,7 +227,7 @@ static inline void write_sorting_mesh_entries( } void ChunksRenderer::drawSortedMeshes(const Camera& camera, Shader& shader) { - const int sortInterval = 8; + const int sortInterval = TRANSLUCENT_BLOCKS_SORT_INTERVAL; static int frameid = 0; frameid++; diff --git a/src/graphics/render/ChunksRenderer.hpp b/src/graphics/render/ChunksRenderer.hpp index 5317c544..859bca9e 100644 --- a/src/graphics/render/ChunksRenderer.hpp +++ b/src/graphics/render/ChunksRenderer.hpp @@ -4,10 +4,12 @@ #include #include #include + #include +#define GLM_ENABLE_EXPERIMENTAL +#include #include "voxels/Block.hpp" -#include "voxels/ChunksStorage.hpp" #include "util/ThreadPool.hpp" #include "graphics/core/MeshData.hpp" #include "commons.hpp" @@ -17,7 +19,6 @@ class Chunk; class Level; class Camera; class Shader; -class Chunks; class Assets; class Frustum; class BlocksRenderer;