minor refactor

This commit is contained in:
MihailRis 2024-11-17 04:58:15 +03:00
parent 5f71522653
commit 71d18ae3a9
3 changed files with 12 additions and 10 deletions

View File

@ -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";

View File

@ -14,9 +14,6 @@
#include "util/listutil.hpp"
#include "settings.hpp"
#include <glm/glm.hpp>
#include <glm/ext.hpp>
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++;

View File

@ -4,10 +4,12 @@
#include <memory>
#include <vector>
#include <unordered_map>
#include <glm/glm.hpp>
#define GLM_ENABLE_EXPERIMENTAL
#include <glm/gtx/hash.hpp>
#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;