fix function naming

This commit is contained in:
eliotbyte 2025-11-01 23:50:44 +03:00 • committed by eliotbyte
parent 1dfb415843
commit 34cb2bfdd5
2 changed files with 22 additions and 22 deletions

View file

@ -17,26 +17,26 @@ static constexpr float kChunkCenterBias = 0.5f;
static constexpr float kAoNormalPush = 0.75f; static constexpr float kAoNormalPush = 0.75f;
static constexpr float kFaceOffsetEps = 1e-3f; static constexpr float kFaceOffsetEps = 1e-3f;
static inline void expandAabbPoint(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); }
} }
static inline float applyDirectionalFactor(float d) { static inline float apply_directional_factor(float d) {
return (1.0f - DIRECTIONAL_LIGHT_FACTOR) + d * DIRECTIONAL_LIGHT_FACTOR; return (1.0f - DIRECTIONAL_LIGHT_FACTOR) + d * DIRECTIONAL_LIGHT_FACTOR;
} }
static inline void expandAabb4( static inline void expand_aabb_4(
AABB& aabb, bool& init, AABB& aabb, bool& init,
const glm::vec3& p0, const glm::vec3& p1, const glm::vec3& p0, const glm::vec3& p1,
const glm::vec3& p2, const glm::vec3& p3 const glm::vec3& p2, const glm::vec3& p3
) { ) {
expandAabbPoint(aabb, init, p0); expand_aabb_point(aabb, init, p0);
expandAabbPoint(aabb, init, p1); expand_aabb_point(aabb, init, p1);
expandAabbPoint(aabb, init, p2); expand_aabb_point(aabb, init, p2);
expandAabbPoint(aabb, init, p3); expand_aabb_point(aabb, init, p3);
} }
static inline void fillTexfaces( static inline void fill_texfaces(
const ContentGfxCache& cache, const ContentGfxCache& cache,
blockid_t id, uint8_t variantId, bool densePass, blockid_t id, uint8_t variantId, bool densePass,
UVRegion (&out)[6] UVRegion (&out)[6]
@ -147,7 +147,7 @@ void BlocksRenderer::face(
// Expand local opaque AABB while vertices are still in chunk-local space // Expand local opaque AABB while vertices are still in chunk-local space
if (!densePass) { if (!densePass) {
expandAabb4(localAabb, localAabbInit, p0, p1, p2, p3); expand_aabb_4(localAabb, localAabbInit, p0, p1, p2, p3);
} }
} }
@ -187,7 +187,7 @@ void BlocksRenderer::faceAO(
float s = kChunkCenterBias; float s = kChunkCenterBias;
if (lights) { if (lights) {
const auto nZ = glm::normalize(Z); const auto nZ = glm::normalize(Z);
float d = applyDirectionalFactor(glm::dot(nZ, SUN_VECTOR)); float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
auto axisX = glm::normalize(X); auto axisX = glm::normalize(X);
auto axisY = glm::normalize(Y); auto axisY = glm::normalize(Y);
@ -204,7 +204,7 @@ void BlocksRenderer::faceAO(
vertexAO(p2, region.u2, region.v2, tint, nh, axisX, axisY, axisZ); vertexAO(p2, region.u2, region.v2, tint, nh, axisX, axisY, axisZ);
vertexAO(p3, region.u1, region.v2, tint, nh, axisX, axisY, axisZ); vertexAO(p3, region.u1, region.v2, tint, nh, axisX, axisY, axisZ);
if (!densePass) { if (!densePass) {
expandAabb4(localAabb, localAabbInit, p0, p1, p2, p3); expand_aabb_4(localAabb, localAabbInit, p0, p1, p2, p3);
} }
} else { } else {
auto axisZ = glm::normalize(Z); auto axisZ = glm::normalize(Z);
@ -218,7 +218,7 @@ void BlocksRenderer::faceAO(
vertex(p2, region.u2, region.v2, tint, axisZ, 1); vertex(p2, region.u2, region.v2, tint, axisZ, 1);
vertex(p3, region.u1, region.v2, tint, axisZ, 1); vertex(p3, region.u1, region.v2, tint, axisZ, 1);
if (!densePass) { if (!densePass) {
expandAabb4(localAabb, localAabbInit, p0, p1, p2, p3); expand_aabb_4(localAabb, localAabbInit, p0, p1, p2, p3);
} }
} }
index(0, 1, 2, 0, 2, 3); index(0, 1, 2, 0, 2, 3);
@ -241,7 +241,7 @@ void BlocksRenderer::face(
float s = kChunkCenterBias; float s = kChunkCenterBias;
const auto nZ = glm::normalize(Z); const auto nZ = glm::normalize(Z);
if (lights) { if (lights) {
float d = applyDirectionalFactor(glm::dot(nZ, SUN_VECTOR)); float d = apply_directional_factor(glm::dot(nZ, SUN_VECTOR));
tint *= d; tint *= d;
} }
const auto nZ2 = lights ? nZ : Z; const auto nZ2 = lights ? nZ : Z;
@ -404,7 +404,7 @@ void BlocksRenderer::blockCustomModel(
continue; continue;
} }
float d = applyDirectionalFactor(glm::dot(n, SUN_VECTOR)); float d = apply_directional_factor(glm::dot(n, SUN_VECTOR));
glm::vec3 t = glm::cross(r, n); glm::vec3 t = glm::cross(r, n);
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -576,7 +576,7 @@ void BlocksRenderer::render(
continue; continue;
} }
UVRegion texfaces[6]; UVRegion texfaces[6];
fillTexfaces(cache, id, variantId, densePass, texfaces); fill_texfaces(cache, id, variantId, densePass, texfaces);
int x = i % CHUNK_W; int x = i % CHUNK_W;
int y = i / (CHUNK_D * CHUNK_W); int y = i / (CHUNK_D * CHUNK_W);
int z = (i / CHUNK_D) % CHUNK_W; int z = (i / CHUNK_D) % CHUNK_W;
@ -648,7 +648,7 @@ SortingMeshData BlocksRenderer::renderTranslucent(
continue; continue;
} }
UVRegion texfaces[6]; UVRegion texfaces[6];
fillTexfaces(cache, id, variantId, densePass, texfaces); fill_texfaces(cache, id, variantId, densePass, texfaces);
int x = i % CHUNK_W; int x = i % CHUNK_W;
int y = i / (CHUNK_D * CHUNK_W); int y = i / (CHUNK_D * CHUNK_W);
int z = (i / CHUNK_D) % CHUNK_W; int z = (i / CHUNK_D) % CHUNK_W;

View file

@ -23,12 +23,12 @@ 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 kChunkCenterBias = 0.5f;
static inline bool hasVolume(const AABB& aabb) { static inline bool has_volume(const AABB& aabb) {
auto s = aabb.size(); auto s = aabb.size();
return s.x > 0.0f || s.y > 0.0f || s.z > 0.0f; return s.x > 0.0f || s.y > 0.0f || s.z > 0.0f;
} }
static inline CullingBounds computeChunkCullingBounds( static inline CullingBounds compute_chunk_culling_bounds(
const Chunk& chunk, const Chunk& chunk,
const std::unordered_map<glm::ivec2, ChunkMesh>& meshes const std::unordered_map<glm::ivec2, ChunkMesh>& meshes
) { ) {
@ -41,7 +41,7 @@ static inline CullingBounds computeChunkCullingBounds(
auto it = meshes.find({chunk.x, chunk.z}); auto it = meshes.find({chunk.x, chunk.z});
if (it != meshes.end()) { if (it != meshes.end()) {
const auto& aabb = it->second.localAabb; const auto& aabb = it->second.localAabb;
if (hasVolume(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 + kChunkCenterBias,
(std::max)(static_cast<float>(chunk.bottom), aabb.min().y + kChunkCenterBias), (std::max)(static_cast<float>(chunk.bottom), aabb.min().y + kChunkCenterBias),
chunk.z * CHUNK_D + aabb.min().z + kChunkCenterBias); chunk.z * CHUNK_D + aabb.min().z + kChunkCenterBias);
@ -214,7 +214,7 @@ const Mesh<ChunkVertex>* ChunksRenderer::retrieveChunk(
chunk->updateHeights(); chunk->updateHeights();
} }
if (culling) { if (culling) {
const auto bounds = computeChunkCullingBounds(*chunk, meshes); const auto bounds = compute_chunk_culling_bounds(*chunk, meshes);
if (!frustum.isBoxVisible(bounds.min, bounds.max)) return nullptr; if (!frustum.isBoxVisible(bounds.min, bounds.max)) return nullptr;
} }
return mesh; return mesh;
@ -247,7 +247,7 @@ void ChunksRenderer::drawShadowsPass(
pos.x * CHUNK_W + kChunkCenterBias, kChunkCenterBias, pos.y * CHUNK_D + kChunkCenterBias pos.x * CHUNK_W + kChunkCenterBias, kChunkCenterBias, pos.y * CHUNK_D + kChunkCenterBias
); );
const auto bounds = computeChunkCullingBounds(*chunk, meshes); const auto bounds = compute_chunk_culling_bounds(*chunk, meshes);
if (!frustum.isBoxVisible(bounds.min, bounds.max)) { if (!frustum.isBoxVisible(bounds.min, bounds.max)) {
continue; continue;
} }
@ -366,7 +366,7 @@ void ChunksRenderer::drawSortedMeshes(const Camera& camera, Shader& shader) {
} }
if (culling) { if (culling) {
const auto bounds = computeChunkCullingBounds(*chunk, meshes); const auto bounds = compute_chunk_culling_bounds(*chunk, meshes);
if (!frustum.isBoxVisible(bounds.min, bounds.max)) continue; if (!frustum.isBoxVisible(bounds.min, bounds.max)) continue;
} }