diff --git a/src/graphics/render/BlocksRenderer.cpp b/src/graphics/render/BlocksRenderer.cpp index c937ff95c..f4f096fd1 100644 --- a/src/graphics/render/BlocksRenderer.cpp +++ b/src/graphics/render/BlocksRenderer.cpp @@ -13,9 +13,9 @@ const glm::vec3 BlocksRenderer::SUN_VECTOR(0.528265f, 0.833149f, -0.163704f); const float DIRECTIONAL_LIGHT_FACTOR = 0.3f; namespace { -static constexpr float kChunkCenterBias = 0.5f; -static constexpr float kAoNormalPush = 0.75f; -static constexpr float kFaceOffsetEps = 1e-3f; +static constexpr float K_CHUNK_CENTER_BIAS = 0.5f; +static constexpr float K_AO_NORMAL_PUSH = 0.75f; +static constexpr float K_FACE_OFFSET_EPS = 1e-3f; static inline void expand_aabb_point(AABB& aabb, bool& init, const glm::vec3& p) { if (!init) { aabb.a = aabb.b = p; init = true; } else { aabb.addPoint(p); } @@ -134,7 +134,7 @@ void BlocksRenderer::face( auto X = axisX * w; auto Y = axisY * h; auto Z = axisZ * d; - float s = kChunkCenterBias; + float s = K_CHUNK_CENTER_BIAS; auto p0 = coord + (-X - Y + Z) * s; auto p1 = coord + ( X - Y + Z) * s; auto p2 = coord + ( X + Y + Z) * s; @@ -184,7 +184,7 @@ void BlocksRenderer::faceAO( return; } - float s = kChunkCenterBias; + float s = K_CHUNK_CENTER_BIAS; if (lights) { const auto nZ = glm::normalize(Z); float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR)); @@ -194,7 +194,7 @@ void BlocksRenderer::faceAO( auto axisZ = nZ; glm::vec4 tint(d); - const float nh = kAoNormalPush; // push AO sample a bit farther along normal + const float nh = K_AO_NORMAL_PUSH; // push AO sample a bit farther along normal auto p0 = coord + (-X - Y + Z) * s; auto p1 = coord + ( X - Y + Z) * s; auto p2 = coord + ( X + Y + Z) * s; @@ -238,7 +238,7 @@ void BlocksRenderer::face( return; } - float s = kChunkCenterBias; + float s = K_CHUNK_CENTER_BIAS; const auto nZ = glm::normalize(Z); if (lights) { float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR)); diff --git a/src/graphics/render/ChunksRenderer.cpp b/src/graphics/render/ChunksRenderer.cpp index 070ab82d0..7e98f686e 100644 --- a/src/graphics/render/ChunksRenderer.cpp +++ b/src/graphics/render/ChunksRenderer.cpp @@ -21,7 +21,7 @@ size_t ChunksRenderer::visibleChunks = 0; namespace { struct CullingBounds { glm::vec3 min; glm::vec3 max; }; -static constexpr float kChunkCenterBias = 0.5f; +static constexpr float K_CHUNK_CENTER_BIAS = 0.5f; static inline bool has_volume(const AABB& aabb) { auto s = aabb.size(); @@ -42,12 +42,12 @@ static inline CullingBounds compute_chunk_culling_bounds( if (it != meshes.end()) { const auto& aabb = it->second.localAabb; if (has_volume(aabb)) { - min = glm::vec3(chunk.x * CHUNK_W + aabb.min().x + kChunkCenterBias, - (std::max)(static_cast(chunk.bottom), aabb.min().y + kChunkCenterBias), - chunk.z * CHUNK_D + aabb.min().z + kChunkCenterBias); - max = glm::vec3(chunk.x * CHUNK_W + aabb.max().x + kChunkCenterBias, - (std::min)(static_cast(chunk.top), aabb.max().y + kChunkCenterBias), - chunk.z * CHUNK_D + aabb.max().z + kChunkCenterBias); + min = glm::vec3(chunk.x * CHUNK_W + aabb.min().x + K_CHUNK_CENTER_BIAS, + (std::max)(static_cast(chunk.bottom), aabb.min().y + K_CHUNK_CENTER_BIAS), + chunk.z * CHUNK_D + aabb.min().z + K_CHUNK_CENTER_BIAS); + max = glm::vec3(chunk.x * CHUNK_W + aabb.max().x + K_CHUNK_CENTER_BIAS, + (std::min)(static_cast(chunk.top), aabb.max().y + K_CHUNK_CENTER_BIAS), + chunk.z * CHUNK_D + aabb.max().z + K_CHUNK_CENTER_BIAS); } } return {min, max}; @@ -244,7 +244,7 @@ void ChunksRenderer::drawShadowsPass( } glm::vec3 coord( - pos.x * CHUNK_W + kChunkCenterBias, kChunkCenterBias, pos.y * CHUNK_D + kChunkCenterBias + pos.x * CHUNK_W + K_CHUNK_CENTER_BIAS, K_CHUNK_CENTER_BIAS, pos.y * CHUNK_D + K_CHUNK_CENTER_BIAS ); const auto bounds = compute_chunk_culling_bounds(*chunk, meshes); @@ -302,7 +302,7 @@ void ChunksRenderer::drawChunks( if (mesh) { glm::vec3 coord( - chunk->x * CHUNK_W + kChunkCenterBias, kChunkCenterBias, chunk->z * CHUNK_D + kChunkCenterBias + chunk->x * CHUNK_W + K_CHUNK_CENTER_BIAS, K_CHUNK_CENTER_BIAS, chunk->z * CHUNK_D + K_CHUNK_CENTER_BIAS ); glm::mat4 model = glm::translate(glm::mat4(1.0f), coord); shader.uniformMatrix("u_model", model);