mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +00:00
fix constant naming
This commit is contained in:
parent
34cb2bfdd5
commit
3a78d5f334
2 changed files with 16 additions and 16 deletions
|
|
@ -13,9 +13,9 @@ const glm::vec3 BlocksRenderer::SUN_VECTOR(0.528265f, 0.833149f, -0.163704f);
|
||||||
const float DIRECTIONAL_LIGHT_FACTOR = 0.3f;
|
const float DIRECTIONAL_LIGHT_FACTOR = 0.3f;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static constexpr float kChunkCenterBias = 0.5f;
|
static constexpr float K_CHUNK_CENTER_BIAS = 0.5f;
|
||||||
static constexpr float kAoNormalPush = 0.75f;
|
static constexpr float K_AO_NORMAL_PUSH = 0.75f;
|
||||||
static constexpr float kFaceOffsetEps = 1e-3f;
|
static constexpr float K_FACE_OFFSET_EPS = 1e-3f;
|
||||||
|
|
||||||
static inline void expand_aabb_point(AABB& aabb, bool& init, const glm::vec3& p) {
|
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); }
|
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 X = axisX * w;
|
||||||
auto Y = axisY * h;
|
auto Y = axisY * h;
|
||||||
auto Z = axisZ * d;
|
auto Z = axisZ * d;
|
||||||
float s = kChunkCenterBias;
|
float s = K_CHUNK_CENTER_BIAS;
|
||||||
auto p0 = coord + (-X - Y + Z) * s;
|
auto p0 = coord + (-X - Y + Z) * s;
|
||||||
auto p1 = coord + ( X - Y + Z) * s;
|
auto p1 = coord + ( X - Y + Z) * s;
|
||||||
auto p2 = coord + ( X + Y + Z) * s;
|
auto p2 = coord + ( X + Y + Z) * s;
|
||||||
|
|
@ -184,7 +184,7 @@ void BlocksRenderer::faceAO(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float s = kChunkCenterBias;
|
float s = K_CHUNK_CENTER_BIAS;
|
||||||
if (lights) {
|
if (lights) {
|
||||||
const auto nZ = glm::normalize(Z);
|
const auto nZ = glm::normalize(Z);
|
||||||
float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
|
float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
|
||||||
|
|
@ -194,7 +194,7 @@ void BlocksRenderer::faceAO(
|
||||||
auto axisZ = nZ;
|
auto axisZ = nZ;
|
||||||
|
|
||||||
glm::vec4 tint(d);
|
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 p0 = coord + (-X - Y + Z) * s;
|
||||||
auto p1 = coord + ( X - Y + Z) * s;
|
auto p1 = coord + ( X - Y + Z) * s;
|
||||||
auto p2 = coord + ( X + Y + Z) * s;
|
auto p2 = coord + ( X + Y + Z) * s;
|
||||||
|
|
@ -238,7 +238,7 @@ void BlocksRenderer::face(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
float s = kChunkCenterBias;
|
float s = K_CHUNK_CENTER_BIAS;
|
||||||
const auto nZ = glm::normalize(Z);
|
const auto nZ = glm::normalize(Z);
|
||||||
if (lights) {
|
if (lights) {
|
||||||
float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
|
float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ size_t ChunksRenderer::visibleChunks = 0;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
struct CullingBounds { glm::vec3 min; glm::vec3 max; };
|
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) {
|
static inline bool has_volume(const AABB& aabb) {
|
||||||
auto s = aabb.size();
|
auto s = aabb.size();
|
||||||
|
|
@ -42,12 +42,12 @@ static inline CullingBounds compute_chunk_culling_bounds(
|
||||||
if (it != meshes.end()) {
|
if (it != meshes.end()) {
|
||||||
const auto& aabb = it->second.localAabb;
|
const auto& aabb = it->second.localAabb;
|
||||||
if (has_volume(aabb)) {
|
if (has_volume(aabb)) {
|
||||||
min = glm::vec3(chunk.x * CHUNK_W + aabb.min().x + kChunkCenterBias,
|
min = glm::vec3(chunk.x * CHUNK_W + aabb.min().x + K_CHUNK_CENTER_BIAS,
|
||||||
(std::max)(static_cast<float>(chunk.bottom), aabb.min().y + kChunkCenterBias),
|
(std::max)(static_cast<float>(chunk.bottom), aabb.min().y + K_CHUNK_CENTER_BIAS),
|
||||||
chunk.z * CHUNK_D + aabb.min().z + kChunkCenterBias);
|
chunk.z * CHUNK_D + aabb.min().z + K_CHUNK_CENTER_BIAS);
|
||||||
max = glm::vec3(chunk.x * CHUNK_W + aabb.max().x + kChunkCenterBias,
|
max = glm::vec3(chunk.x * CHUNK_W + aabb.max().x + K_CHUNK_CENTER_BIAS,
|
||||||
(std::min)(static_cast<float>(chunk.top), aabb.max().y + kChunkCenterBias),
|
(std::min)(static_cast<float>(chunk.top), aabb.max().y + K_CHUNK_CENTER_BIAS),
|
||||||
chunk.z * CHUNK_D + aabb.max().z + kChunkCenterBias);
|
chunk.z * CHUNK_D + aabb.max().z + K_CHUNK_CENTER_BIAS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {min, max};
|
return {min, max};
|
||||||
|
|
@ -244,7 +244,7 @@ void ChunksRenderer::drawShadowsPass(
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 coord(
|
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);
|
const auto bounds = compute_chunk_culling_bounds(*chunk, meshes);
|
||||||
|
|
@ -302,7 +302,7 @@ void ChunksRenderer::drawChunks(
|
||||||
|
|
||||||
if (mesh) {
|
if (mesh) {
|
||||||
glm::vec3 coord(
|
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);
|
glm::mat4 model = glm::translate(glm::mat4(1.0f), coord);
|
||||||
shader.uniformMatrix("u_model", model);
|
shader.uniformMatrix("u_model", model);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue