minor refactor
This commit is contained in:
+5
-3
@@ -35,9 +35,6 @@ inline constexpr int CHUNK_D = 16;
|
|||||||
inline constexpr uint VOXEL_USER_BITS = 8;
|
inline constexpr uint VOXEL_USER_BITS = 8;
|
||||||
inline constexpr uint VOXEL_USER_BITS_OFFSET = sizeof(blockstate_t)*8-VOXEL_USER_BITS;
|
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)
|
/// @brief chunk volume (count of voxels per Chunk)
|
||||||
inline constexpr int CHUNK_VOL = (CHUNK_W * CHUNK_H * CHUNK_D);
|
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;
|
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 SHADERS_FOLDER = "shaders";
|
||||||
inline const std::string TEXTURES_FOLDER = "textures";
|
inline const std::string TEXTURES_FOLDER = "textures";
|
||||||
inline const std::string FONTS_FOLDER = "fonts";
|
inline const std::string FONTS_FOLDER = "fonts";
|
||||||
|
|||||||
@@ -14,9 +14,6 @@
|
|||||||
#include "util/listutil.hpp"
|
#include "util/listutil.hpp"
|
||||||
#include "settings.hpp"
|
#include "settings.hpp"
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
|
||||||
#include <glm/ext.hpp>
|
|
||||||
|
|
||||||
static debug::Logger logger("chunks-render");
|
static debug::Logger logger("chunks-render");
|
||||||
|
|
||||||
size_t ChunksRenderer::visibleChunks = 0;
|
size_t ChunksRenderer::visibleChunks = 0;
|
||||||
@@ -204,7 +201,9 @@ void ChunksRenderer::drawChunks(
|
|||||||
auto mesh = retrieveChunk(indices[i].index, camera, shader, culling);
|
auto mesh = retrieveChunk(indices[i].index, camera, shader, culling);
|
||||||
|
|
||||||
if (mesh) {
|
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);
|
glm::mat4 model = glm::translate(glm::mat4(1.0f), coord);
|
||||||
shader.uniformMatrix("u_model", model);
|
shader.uniformMatrix("u_model", model);
|
||||||
mesh->draw();
|
mesh->draw();
|
||||||
@@ -228,7 +227,7 @@ static inline void write_sorting_mesh_entries(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ChunksRenderer::drawSortedMeshes(const Camera& camera, Shader& shader) {
|
void ChunksRenderer::drawSortedMeshes(const Camera& camera, Shader& shader) {
|
||||||
const int sortInterval = 8;
|
const int sortInterval = TRANSLUCENT_BLOCKS_SORT_INTERVAL;
|
||||||
static int frameid = 0;
|
static int frameid = 0;
|
||||||
frameid++;
|
frameid++;
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
#define GLM_ENABLE_EXPERIMENTAL
|
||||||
|
#include <glm/gtx/hash.hpp>
|
||||||
|
|
||||||
#include "voxels/Block.hpp"
|
#include "voxels/Block.hpp"
|
||||||
#include "voxels/ChunksStorage.hpp"
|
|
||||||
#include "util/ThreadPool.hpp"
|
#include "util/ThreadPool.hpp"
|
||||||
#include "graphics/core/MeshData.hpp"
|
#include "graphics/core/MeshData.hpp"
|
||||||
#include "commons.hpp"
|
#include "commons.hpp"
|
||||||
@@ -17,7 +19,6 @@ class Chunk;
|
|||||||
class Level;
|
class Level;
|
||||||
class Camera;
|
class Camera;
|
||||||
class Shader;
|
class Shader;
|
||||||
class Chunks;
|
|
||||||
class Assets;
|
class Assets;
|
||||||
class Frustum;
|
class Frustum;
|
||||||
class BlocksRenderer;
|
class BlocksRenderer;
|
||||||
|
|||||||
Reference in New Issue
Block a user