瀏覽代碼

Convert all added constants and functions to snake_case

- Rename namespaces: MathConstants → math_constants, Hash → hash_xor_shift, HashConstants → hash_constants
- Rename constants with k_ prefix: Pi → k_pi, TwoPi → k_two_pi, GoldenRatio → k_golden_ratio, etc.
- Rename functions: hashCoords → hash_coords, rand01 → rand_01, hashTo01 → hash_to_01, hash01 → hash_01, noiseHash → noise_hash
- Rename function parameters: minOut → min_out, maxOut → max_out
- Update all usages across 13 modified files

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 月之前
父節點
當前提交
f77615c2dc

+ 4 - 4
render/entity/archer_renderer.cpp

@@ -67,8 +67,8 @@ public:
                      uint32_t seed, HumanoidPose &pose) const override {
     using HP = HumanProportions;
 
-    float const arm_height_jitter = (hash01(seed ^ 0xABCDU) - 0.5F) * 0.03F;
-    float const arm_asymmetry = (hash01(seed ^ 0xDEF0U) - 0.5F) * 0.04F;
+    float const arm_height_jitter = (hash_01(seed ^ 0xABCDU) - 0.5F) * 0.03F;
+    float const arm_asymmetry = (hash_01(seed ^ 0xDEF0U) - 0.5F) * 0.04F;
 
     float const bowX = 0.0F;
 
@@ -527,8 +527,8 @@ private:
              cylinderBetween(ctx.model, q_base, qTop, quiver_r),
              v.palette.leather, nullptr, 1.0F);
 
-    float const j = (hash01(seed) - 0.5F) * 0.04F;
-    float const k = (hash01(seed ^ Hash::GoldenRatio) - 0.5F) * 0.04F;
+    float const j = (hash_01(seed) - 0.5F) * 0.04F;
+    float const k = (hash_01(seed ^ hash_xor_shift::k_golden_ratio) - 0.5F) * 0.04F;
 
     QVector3D const a1 = qTop + QVector3D(0.00F + j, 0.08F, 0.00F + k);
     out.mesh(getUnitCylinder(), cylinderBetween(ctx.model, qTop, a1, 0.010F),

+ 2 - 2
render/entity/arrow_vfx_renderer.cpp

@@ -297,8 +297,8 @@ static inline void drawQuiver(const DrawContext &p, ISubmitter &out,
   out.mesh(getUnitCylinder(), cylinderBetween(p.model, q_base, qTop, quiver_r),
            C.leather, nullptr, 1.0F);
 
-  float j = (hash01(seed) - 0.5F) * 0.04F;
-  float k = (hash01(seed ^ Hash::GoldenRatio) - 0.5F) * 0.04F;
+  float j = (hash_01(seed) - 0.5F) * 0.04F;
+  float k = (hash_01(seed ^ hash_xor_shift::k_golden_ratio) - 0.5F) * 0.04F;
 
   QVector3D a1 = qTop + QVector3D(0.00F + j, 0.08F, 0.00F + k);
   out.mesh(getUnitCylinder(), cylinderBetween(p.model, qTop, a1, 0.010F),

+ 11 - 11
render/gl/render_constants.h

@@ -2,10 +2,10 @@
 
 #include <numbers>
 
-namespace Render::GL::MathConstants {
-inline constexpr float Pi = std::numbers::pi_v<float>;
-inline constexpr float TwoPi = std::numbers::pi_v<float> * 2.0F;
-} // namespace Render::GL::MathConstants
+namespace Render::GL::math_constants {
+inline constexpr float k_pi = std::numbers::pi_v<float>;
+inline constexpr float k_two_pi = std::numbers::pi_v<float> * 2.0F;
+} // namespace Render::GL::math_constants
 
 namespace Render::GL::VertexAttrib {
 inline constexpr int Position = 0;
@@ -86,12 +86,12 @@ inline constexpr int Shift16 = 16;
 inline constexpr int Shift32 = 32;
 inline constexpr unsigned int Mask24Bit = 0xFFFFFF;
 inline constexpr float Mask24BitFloat = 16777215.0F;
-inline constexpr unsigned int Mask24BitHex = 0x01000000U;
+inline constexpr unsigned int k_mask_24bit_hex = 0x01000000U;
 } // namespace Render::GL::BitShift
 
-namespace Render::GL::Hash {
-inline constexpr int XorShiftAmount5 = 5;
-inline constexpr int XorShiftAmount13 = 13;
-inline constexpr int XorShiftAmount17 = 17;
-inline constexpr uint32_t GoldenRatio = 0x9E3779B9U;
-} // namespace Render::GL::Hash
+namespace Render::GL::hash_xor_shift {
+inline constexpr int k_xor_shift_amount_5 = 5;
+inline constexpr int k_xor_shift_amount_13 = 13;
+inline constexpr int k_xor_shift_amount_17 = 17;
+inline constexpr uint32_t k_golden_ratio = 0x9E3779B9U;
+} // namespace Render::GL::hash_xor_shift

+ 24 - 24
render/ground/biome_renderer.cpp

@@ -33,10 +33,10 @@ inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
   int z1 = z0 + 1;
   float tx = x - float(x0);
   float tz = z - float(z0);
-  float const n00 = hashTo01(hashCoords(x0, z0, salt));
-  float const n10 = hashTo01(hashCoords(x1, z0, salt));
-  float const n01 = hashTo01(hashCoords(x0, z1, salt));
-  float const n11 = hashTo01(hashCoords(x1, z1, salt));
+  float const n00 = hash_to_01(hash_coords(x0, z0, salt));
+  float const n10 = hash_to_01(hash_coords(x1, z0, salt));
+  float const n01 = hash_to_01(hash_coords(x0, z1, salt));
+  float const n11 = hash_to_01(hash_coords(x1, z1, salt));
   float const nx0 = n00 * (1 - tx) + n10 * tx;
   float const nx1 = n01 * (1 - tx) + n11 * tx;
   return nx0 * (1 - tz) + nx1 * tz;
@@ -233,7 +233,7 @@ void BiomeRenderer::generateGrassInstances() {
     if (near_river_count > 0) {
 
       float const riverbank_density = 0.15F;
-      if (rand01(state) > riverbank_density) {
+      if (rand_01(state) > riverbank_density) {
         return false;
       }
     }
@@ -266,17 +266,17 @@ void BiomeRenderer::generateGrassInstances() {
     QVector3D const color =
         lush_mix * (1.0F - dryness) + m_biomeSettings.grassDry * dryness;
 
-    float const height = remap(rand01(state), m_biomeSettings.bladeHeightMin,
+    float const height = remap(rand_01(state), m_biomeSettings.bladeHeightMin,
                                m_biomeSettings.bladeHeightMax) *
                          tile_safe * 0.5F;
-    float const width = remap(rand01(state), m_biomeSettings.bladeWidthMin,
+    float const width = remap(rand_01(state), m_biomeSettings.bladeWidthMin,
                               m_biomeSettings.bladeWidthMax) *
                         tile_safe;
 
-    float const sway_strength = remap(rand01(state), 0.75F, 1.25F);
-    float const sway_speed = remap(rand01(state), 0.85F, 1.15F);
-    float const sway_phase = rand01(state) * MathConstants::TwoPi;
-    float const orientation = rand01(state) * MathConstants::TwoPi;
+    float const sway_strength = remap(rand_01(state), 0.75F, 1.25F);
+    float const sway_speed = remap(rand_01(state), 0.85F, 1.15F);
+    float const sway_phase = rand_01(state) * math_constants::k_two_pi;
+    float const orientation = rand_01(state) * math_constants::k_two_pi;
 
     GrassInstanceGpu instance;
     instance.posHeight = QVector4D(world_x, world_y, world_z, height);
@@ -368,7 +368,7 @@ void BiomeRenderer::generateGrassInstances() {
 
       float const avg_slope = chunk_slope_sum / float(sample_count);
 
-      uint32_t state = hashCoords(chunk_x, chunk_z, m_noiseSeed ^ 0xC915872BU);
+      uint32_t state = hash_coords(chunk_x, chunk_z, m_noiseSeed ^ 0xC915872BU);
       float const slope_penalty =
           1.0F - std::clamp(avg_slope * 1.35F, 0.0F, 0.75F);
 
@@ -379,7 +379,7 @@ void BiomeRenderer::generateGrassInstances() {
                              slope_penalty * type_bias * usable_coverage);
       int cluster_count = static_cast<int>(std::floor(expected_clusters));
       float const frac = expected_clusters - float(cluster_count);
-      if (rand01(state) < frac) {
+      if (rand_01(state) < frac) {
         cluster_count += 1;
       }
 
@@ -393,9 +393,9 @@ void BiomeRenderer::generateGrassInstances() {
           constexpr int k_max_attempts = 8;
           for (int attempt = 0; attempt < k_max_attempts; ++attempt) {
             float const candidate_gx =
-                float(chunk_x) + rand01(rng) * chunk_span_x;
+                float(chunk_x) + rand_01(rng) * chunk_span_x;
             float const candidate_gz =
-                float(chunk_z) + rand01(rng) * chunk_span_z;
+                float(chunk_z) + rand_01(rng) * chunk_span_z;
 
             int const cx =
                 std::clamp(int(std::round(candidate_gx)), 0, m_width - 1);
@@ -429,15 +429,15 @@ void BiomeRenderer::generateGrassInstances() {
           float const center_gx = center->x();
           float const center_gz = center->y();
 
-          int blades = 6 + static_cast<int>(rand01(state) * 6.0F);
+          int blades = 6 + static_cast<int>(rand_01(state) * 6.0F);
           blades = std::max(
-              4, int(std::round(blades * (0.85F + 0.3F * rand01(state)))));
+              4, int(std::round(blades * (0.85F + 0.3F * rand_01(state)))));
           float const scatter_radius =
-              (0.45F + 0.55F * rand01(state)) * scatter_base * tile_safe;
+              (0.45F + 0.55F * rand_01(state)) * scatter_base * tile_safe;
 
           for (int blade = 0; blade < blades; ++blade) {
-            float const angle = rand01(state) * MathConstants::TwoPi;
-            float const radius = scatter_radius * std::sqrt(rand01(state));
+            float const angle = rand_01(state) * math_constants::k_two_pi;
+            float const radius = scatter_radius * std::sqrt(rand_01(state));
             float const gx = center_gx + std::cos(angle) * radius / tile_safe;
             float const gz = center_gz + std::sin(angle) * radius / tile_safe;
             add_grass_blade(gx, gz, state);
@@ -466,17 +466,17 @@ void BiomeRenderer::generateGrassInstances() {
           continue;
         }
 
-        uint32_t state = hashCoords(
+        uint32_t state = hash_coords(
             x, z, m_noiseSeed ^ 0x51bda7U ^ static_cast<uint32_t>(idx));
         int base_count = static_cast<int>(std::floor(background_density));
         float const frac = background_density - float(base_count);
-        if (rand01(state) < frac) {
+        if (rand_01(state) < frac) {
           base_count += 1;
         }
 
         for (int i = 0; i < base_count; ++i) {
-          float const gx = float(x) + rand01(state);
-          float const gz = float(z) + rand01(state);
+          float const gx = float(x) + rand_01(state);
+          float const gz = float(z) + rand_01(state);
           add_grass_blade(gx, gz, state);
         }
       }

+ 21 - 21
render/ground/firecamp_renderer.cpp

@@ -32,15 +32,15 @@ inline auto valueNoise(float x, float z, uint32_t seed) -> float {
   fx = fx * fx * (3.0F - 2.0F * fx);
   fz = fz * fz * (3.0F - 2.0F * fz);
 
-  uint32_t s00 = hashCoords(ix, iz, seed);
-  uint32_t s10 = hashCoords(ix + 1, iz, seed);
-  uint32_t s01 = hashCoords(ix, iz + 1, seed);
-  uint32_t s11 = hashCoords(ix + 1, iz + 1, seed);
+  uint32_t s00 = hash_coords(ix, iz, seed);
+  uint32_t s10 = hash_coords(ix + 1, iz, seed);
+  uint32_t s01 = hash_coords(ix, iz + 1, seed);
+  uint32_t s11 = hash_coords(ix + 1, iz + 1, seed);
 
-  float const v00 = rand01(s00);
-  float const v10 = rand01(s10);
-  float const v01 = rand01(s01);
-  float const v11 = rand01(s11);
+  float const v00 = rand_01(s00);
+  float const v10 = rand_01(s10);
+  float const v01 = rand_01(s01);
+  float const v11 = rand_01(s11);
 
   float const v0 = v00 * (1.0F - fx) + v10 * fx;
   float const v1 = v01 * (1.0F - fx) + v11 * fx;
@@ -137,14 +137,14 @@ void FireCampRenderer::submit(Renderer &renderer, ResourceManager *resources) {
     const float base_radius = std::max(radius_phase.x(), 1.0F);
 
     uint32_t state =
-        hashCoords(static_cast<int>(std::floor(camp_pos.x())),
+        hash_coords(static_cast<int>(std::floor(camp_pos.x())),
                    static_cast<int>(std::floor(camp_pos.z())),
                    static_cast<uint32_t>(radius_phase.y() *
-                                         HashConstants::TemporalVariationFrequency));
+                                         hash_constants::k_temporal_variation_frequency));
 
     const float time = params.time;
     const float char_amount =
-        std::clamp(time * 0.015F + rand01(state) * 0.05F, 0.0F, 1.0F);
+        std::clamp(time * 0.015F + rand_01(state) * 0.05F, 0.0F, 1.0F);
 
     const QVector3D blended_log_color =
         log_color * (1.0F - char_amount) + char_color * (char_amount + 0.15F);
@@ -152,7 +152,7 @@ void FireCampRenderer::submit(Renderer &renderer, ResourceManager *resources) {
     const float log_length = std::clamp(base_radius * 0.85F, 0.45F, 1.1F);
     const float log_radius = std::clamp(base_radius * 0.08F, 0.03F, 0.08F);
 
-    const float base_yaw = (rand01(state) - 0.5F) * 0.35F;
+    const float base_yaw = (rand_01(state) - 0.5F) * 0.35F;
     const float cos_base = std::cos(base_yaw);
     const float sin_base = std::sin(base_yaw);
     const QVector3D axis_a(cos_base, 0.0F, sin_base);
@@ -167,8 +167,8 @@ void FireCampRenderer::submit(Renderer &renderer, ResourceManager *resources) {
     renderer.cylinder(base_center - base_half_b, base_center + base_half_b,
                       log_radius, blended_log_color, 1.0F);
 
-    if (rand01(state) > 0.25F) {
-      float const top_yaw = base_yaw + 0.6F + (rand01(state) - 0.5F) * 0.35F;
+    if (rand_01(state) > 0.25F) {
+      float const top_yaw = base_yaw + 0.6F + (rand_01(state) - 0.5F) * 0.35F;
       QVector3D const top_axis(std::cos(top_yaw), 0.0F, std::sin(top_yaw));
       QVector3D const top_half = top_axis * (log_length * 0.35F);
       QVector3D const top_center =
@@ -296,10 +296,10 @@ void FireCampRenderer::generateFireCampInstances() {
       return false;
     }
 
-    float const intensity = remap(rand01(state), 0.8F, 1.2F);
-    float const radius = remap(rand01(state), 2.0F, 4.0F) * tile_safe;
+    float const intensity = remap(rand_01(state), 0.8F, 1.2F);
+    float const radius = remap(rand_01(state), 2.0F, 4.0F) * tile_safe;
 
-    float const phase = rand01(state) * MathConstants::TwoPi;
+    float const phase = rand_01(state) * math_constants::k_two_pi;
 
     float const duration = 1.0F;
 
@@ -322,7 +322,7 @@ void FireCampRenderer::generateFireCampInstances() {
         continue;
       }
 
-      uint32_t state = hashCoords(
+      uint32_t state = hash_coords(
           x, z, m_noiseSeed ^ 0xF12ECA3FU ^ static_cast<uint32_t>(idx));
 
       float const world_x = (x - half_width) * m_tile_size;
@@ -343,9 +343,9 @@ void FireCampRenderer::generateFireCampInstances() {
       }
 
       float const effective_density = fire_camp_density * density_mult;
-      if (rand01(state) < effective_density) {
-        float const gx = float(x) + rand01(state) * float(k_grid_spacing);
-        float const gz = float(z) + rand01(state) * float(k_grid_spacing);
+      if (rand_01(state) < effective_density) {
+        float const gx = float(x) + rand_01(state) * float(k_grid_spacing);
+        float const gz = float(z) + rand_01(state) * float(k_grid_spacing);
         add_fire_camp(gx, gz, state);
       }
     }

+ 42 - 42
render/ground/ground_utils.h

@@ -8,64 +8,64 @@ namespace Render::Ground {
 
 using std::uint32_t;
 
-namespace MathConstants {
-inline constexpr float TwoPi = ::Render::GL::MathConstants::TwoPi;
-} // namespace MathConstants
+namespace math_constants {
+inline constexpr float k_two_pi = ::Render::GL::math_constants::k_two_pi;
+} // namespace math_constants
 
-namespace HashConstants {
-inline constexpr uint32_t SpatialHashPrime1 = 73856093U;
-inline constexpr uint32_t SpatialHashPrime2 = 19349663U;
-inline constexpr uint32_t SpatialHashPrime3 = 83492791U;
-inline constexpr uint32_t LinearCongruentialMultiplier = 1664525U;
-inline constexpr uint32_t LinearCongruentialIncrement = 1013904223U;
-inline constexpr uint32_t XorShiftAmount17 = 17;
-inline constexpr uint32_t XorShiftAmount11 = 11;
-inline constexpr uint32_t XorShiftAmount15 = 15;
-inline constexpr uint32_t XorShiftAmount14 = 14;
-inline constexpr uint32_t HashMixMultiplier1 = 0xed5ad4bbU;
-inline constexpr uint32_t HashMixMultiplier2 = 0xac4c1b51U;
-inline constexpr uint32_t HashMixMultiplier3 = 0x31848babU;
-inline constexpr float NoiseFrequencyX = 127.1F;
-inline constexpr float NoiseFrequencyY = 311.7F;
-inline constexpr float NoiseAmplitude = 43758.5453123F;
-inline constexpr float TemporalVariationFrequency = 37.0F;
-} // namespace HashConstants
+namespace hash_constants {
+inline constexpr uint32_t k_spatial_hash_prime_1 = 73856093U;
+inline constexpr uint32_t k_spatial_hash_prime_2 = 19349663U;
+inline constexpr uint32_t k_spatial_hash_prime_3 = 83492791U;
+inline constexpr uint32_t k_linear_congruential_multiplier = 1664525U;
+inline constexpr uint32_t k_linear_congruential_increment = 1013904223U;
+inline constexpr uint32_t k_xor_shift_amount_17 = 17;
+inline constexpr uint32_t k_xor_shift_amount_11 = 11;
+inline constexpr uint32_t k_xor_shift_amount_15 = 15;
+inline constexpr uint32_t k_xor_shift_amount_14 = 14;
+inline constexpr uint32_t k_hash_mix_multiplier_1 = 0xed5ad4bbU;
+inline constexpr uint32_t k_hash_mix_multiplier_2 = 0xac4c1b51U;
+inline constexpr uint32_t k_hash_mix_multiplier_3 = 0x31848babU;
+inline constexpr float k_noise_frequency_x = 127.1F;
+inline constexpr float k_noise_frequency_y = 311.7F;
+inline constexpr float k_noise_amplitude = 43758.5453123F;
+inline constexpr float k_temporal_variation_frequency = 37.0F;
+} // namespace hash_constants
 
-inline auto hashCoords(int x, int z, uint32_t salt = 0U) -> uint32_t {
-  auto const ux = static_cast<uint32_t>(x * HashConstants::SpatialHashPrime1);
-  auto const uz = static_cast<uint32_t>(z * HashConstants::SpatialHashPrime2);
-  return ux ^ uz ^ (salt * HashConstants::SpatialHashPrime3);
+inline auto hash_coords(int x, int z, uint32_t salt = 0U) -> uint32_t {
+  auto const ux = static_cast<uint32_t>(x * hash_constants::k_spatial_hash_prime_1);
+  auto const uz = static_cast<uint32_t>(z * hash_constants::k_spatial_hash_prime_2);
+  return ux ^ uz ^ (salt * hash_constants::k_spatial_hash_prime_3);
 }
 
-inline auto rand01(uint32_t &state) -> float {
-  state = state * HashConstants::LinearCongruentialMultiplier +
-          HashConstants::LinearCongruentialIncrement;
+inline auto rand_01(uint32_t &state) -> float {
+  state = state * hash_constants::k_linear_congruential_multiplier +
+          hash_constants::k_linear_congruential_increment;
   return static_cast<float>((state >> ::Render::GL::BitShift::Shift8) &
                             ::Render::GL::BitShift::Mask24Bit) /
          ::Render::GL::BitShift::Mask24BitFloat;
 }
 
-inline auto remap(float value, float minOut, float maxOut) -> float {
-  return minOut + (maxOut - minOut) * value;
+inline auto remap(float value, float min_out, float max_out) -> float {
+  return min_out + (max_out - min_out) * value;
 }
 
-inline auto hashTo01(uint32_t h) -> float {
-  h ^= h >> HashConstants::XorShiftAmount17;
-  h *= HashConstants::HashMixMultiplier1;
-  h ^= h >> HashConstants::XorShiftAmount11;
-  h *= HashConstants::HashMixMultiplier2;
-  h ^= h >> HashConstants::XorShiftAmount15;
-  h *= HashConstants::HashMixMultiplier3;
-  h ^= h >> HashConstants::XorShiftAmount14;
+inline auto hash_to_01(uint32_t h) -> float {
+  h ^= h >> hash_constants::k_xor_shift_amount_17;
+  h *= hash_constants::k_hash_mix_multiplier_1;
+  h ^= h >> hash_constants::k_xor_shift_amount_11;
+  h *= hash_constants::k_hash_mix_multiplier_2;
+  h ^= h >> hash_constants::k_xor_shift_amount_15;
+  h *= hash_constants::k_hash_mix_multiplier_3;
+  h ^= h >> hash_constants::k_xor_shift_amount_14;
   return static_cast<float>((h >> ::Render::GL::BitShift::Shift8) &
                             ::Render::GL::BitShift::Mask24Bit) /
          ::Render::GL::BitShift::Mask24BitFloat;
 }
 
-inline auto noiseHash(float x, float y) -> float {
-  float const n = std::sin(x * HashConstants::NoiseFrequencyX +
-                           y * HashConstants::NoiseFrequencyY) *
-                  HashConstants::NoiseAmplitude;
+inline auto noise_hash(float x, float y) -> float {
+  float const n = std::sin(x * hash_constants::k_noise_frequency_x +
+                           y * hash_constants::k_noise_frequency_y) *
+                  hash_constants::k_noise_amplitude;
   return n - std::floor(n);
 }
 

+ 16 - 16
render/ground/pine_renderer.cpp

@@ -26,10 +26,10 @@ inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
   int z1 = z0 + 1;
   float tx = x - float(x0);
   float tz = z - float(z0);
-  float const n00 = hashTo01(hashCoords(x0, z0, salt));
-  float const n10 = hashTo01(hashCoords(x1, z0, salt));
-  float const n01 = hashTo01(hashCoords(x0, z1, salt));
-  float const n11 = hashTo01(hashCoords(x1, z1, salt));
+  float const n00 = hash_to_01(hash_coords(x0, z0, salt));
+  float const n10 = hash_to_01(hash_coords(x1, z0, salt));
+  float const n01 = hash_to_01(hash_coords(x0, z1, salt));
+  float const n11 = hash_to_01(hash_coords(x1, z1, salt));
   float const nx0 = n00 * (1 - tx) + n10 * tx;
   float const nx1 = n01 * (1 - tx) + n11 * tx;
   return nx0 * (1 - tz) + nx1 * tz;
@@ -187,25 +187,25 @@ void PineRenderer::generatePineInstances() {
       return false;
     }
 
-    float const scale = remap(rand01(state), 3.0F, 6.0F) * tile_safe;
+    float const scale = remap(rand_01(state), 3.0F, 6.0F) * tile_safe;
 
-    float const color_var = remap(rand01(state), 0.0F, 1.0F);
+    float const color_var = remap(rand_01(state), 0.0F, 1.0F);
     QVector3D const base_color(0.15F, 0.35F, 0.20F);
     QVector3D const var_color(0.20F, 0.40F, 0.25F);
     QVector3D tint_color =
         base_color * (1.0F - color_var) + var_color * color_var;
 
-    float const brown_mix = remap(rand01(state), 0.10F, 0.25F);
+    float const brown_mix = remap(rand_01(state), 0.10F, 0.25F);
     QVector3D const brown_tint(0.35F, 0.30F, 0.20F);
     tint_color = tint_color * (1.0F - brown_mix) + brown_tint * brown_mix;
 
-    float const sway_phase = rand01(state) * MathConstants::TwoPi;
+    float const sway_phase = rand_01(state) * math_constants::k_two_pi;
 
-    float const rotation = rand01(state) * MathConstants::TwoPi;
+    float const rotation = rand_01(state) * math_constants::k_two_pi;
 
-    float const silhouette_seed = rand01(state);
-    float const needle_seed = rand01(state);
-    float const bark_seed = rand01(state);
+    float const silhouette_seed = rand_01(state);
+    float const needle_seed = rand_01(state);
+    float const bark_seed = rand_01(state);
 
     PineInstanceGpu instance;
 
@@ -228,7 +228,7 @@ void PineRenderer::generatePineInstances() {
         continue;
       }
 
-      uint32_t state = hashCoords(
+      uint32_t state = hash_coords(
           x, z, m_noiseSeed ^ 0xAB12CD34U ^ static_cast<uint32_t>(idx));
 
       float const world_x = (x - half_width) * m_tile_size;
@@ -251,13 +251,13 @@ void PineRenderer::generatePineInstances() {
       float const effective_density = pine_density * density_mult * 0.8F;
       int pine_count = static_cast<int>(std::floor(effective_density));
       float const frac = effective_density - float(pine_count);
-      if (rand01(state) < frac) {
+      if (rand_01(state) < frac) {
         pine_count += 1;
       }
 
       for (int i = 0; i < pine_count; ++i) {
-        float const gx = float(x) + rand01(state) * 6.0F;
-        float const gz = float(z) + rand01(state) * 6.0F;
+        float const gx = float(x) + rand_01(state) * 6.0F;
+        float const gz = float(z) + rand_01(state) * 6.0F;
         add_pine(gx, gz, state);
       }
     }

+ 16 - 16
render/ground/plant_renderer.cpp

@@ -26,10 +26,10 @@ inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
   int z1 = z0 + 1;
   float tx = x - float(x0);
   float tz = z - float(z0);
-  float const n00 = hashTo01(hashCoords(x0, z0, salt));
-  float const n10 = hashTo01(hashCoords(x1, z0, salt));
-  float const n01 = hashTo01(hashCoords(x0, z1, salt));
-  float const n11 = hashTo01(hashCoords(x1, z1, salt));
+  float const n00 = hash_to_01(hash_coords(x0, z0, salt));
+  float const n10 = hash_to_01(hash_coords(x1, z0, salt));
+  float const n01 = hash_to_01(hash_coords(x0, z1, salt));
+  float const n11 = hash_to_01(hash_coords(x1, z1, salt));
   float const nx0 = n00 * (1 - tx) + n10 * tx;
   float const nx1 = n01 * (1 - tx) + n11 * tx;
   return nx0 * (1 - tz) + nx1 * tz;
@@ -261,25 +261,25 @@ void PlantRenderer::generatePlantInstances() {
       return false;
     }
 
-    float const scale = remap(rand01(state), 0.30F, 0.80F) * tile_safe;
+    float const scale = remap(rand_01(state), 0.30F, 0.80F) * tile_safe;
 
-    float const plant_type = std::floor(rand01(state) * 4.0F);
+    float const plant_type = std::floor(rand_01(state) * 4.0F);
 
-    float const color_var = remap(rand01(state), 0.0F, 1.0F);
+    float const color_var = remap(rand_01(state), 0.0F, 1.0F);
     QVector3D const base_color = m_biomeSettings.grassPrimary * 0.7F;
     QVector3D const var_color = m_biomeSettings.grassSecondary * 0.8F;
     QVector3D tint_color =
         base_color * (1.0F - color_var) + var_color * color_var;
 
-    float const brown_mix = remap(rand01(state), 0.15F, 0.35F);
+    float const brown_mix = remap(rand_01(state), 0.15F, 0.35F);
     QVector3D const brown_tint(0.55F, 0.50F, 0.35F);
     tint_color = tint_color * (1.0F - brown_mix) + brown_tint * brown_mix;
 
-    float const sway_phase = rand01(state) * MathConstants::TwoPi;
-    float const sway_strength = remap(rand01(state), 0.6F, 1.2F);
-    float const sway_speed = remap(rand01(state), 0.8F, 1.3F);
+    float const sway_phase = rand_01(state) * math_constants::k_two_pi;
+    float const sway_strength = remap(rand_01(state), 0.6F, 1.2F);
+    float const sway_speed = remap(rand_01(state), 0.8F, 1.3F);
 
-    float const rotation = rand01(state) * MathConstants::TwoPi;
+    float const rotation = rand_01(state) * math_constants::k_two_pi;
 
     PlantInstanceGpu instance;
 
@@ -312,7 +312,7 @@ void PlantRenderer::generatePlantInstances() {
         continue;
       }
 
-      uint32_t state = hashCoords(
+      uint32_t state = hash_coords(
           x, z, m_noiseSeed ^ 0x8F3C5A7EU ^ static_cast<uint32_t>(idx));
 
       float const world_x = (x - half_width) * m_tile_size;
@@ -335,13 +335,13 @@ void PlantRenderer::generatePlantInstances() {
       float const effective_density = plant_density * density_mult * 2.0F;
       int plant_count = static_cast<int>(std::floor(effective_density));
       float const frac = effective_density - float(plant_count);
-      if (rand01(state) < frac) {
+      if (rand_01(state) < frac) {
         plant_count += 1;
       }
 
       for (int i = 0; i < plant_count; ++i) {
-        float const gx = float(x) + rand01(state) * 3.0F;
-        float const gz = float(z) + rand01(state) * 3.0F;
+        float const gx = float(x) + rand_01(state) * 3.0F;
+        float const gz = float(z) + rand_01(state) * 3.0F;
         if (add_plant(gx, gz, state)) {
           plants_added++;
         }

+ 4 - 4
render/ground/river_renderer.cpp

@@ -45,10 +45,10 @@ void RiverRenderer::buildMeshes() {
     fx = fx * fx * (3.0F - 2.0F * fx);
     fy = fy * fy * (3.0F - 2.0F * fy);
 
-    float const a = Ground::noiseHash(ix, iy);
-    float const b = Ground::noiseHash(ix + 1.0F, iy);
-    float const c = Ground::noiseHash(ix, iy + 1.0F);
-    float const d = Ground::noiseHash(ix + 1.0F, iy + 1.0F);
+    float const a = Ground::noise_hash(ix, iy);
+    float const b = Ground::noise_hash(ix + 1.0F, iy);
+    float const c = Ground::noise_hash(ix, iy + 1.0F);
+    float const d = Ground::noise_hash(ix + 1.0F, iy + 1.0F);
 
     return a * (1.0F - fx) * (1.0F - fy) + b * fx * (1.0F - fy) +
            c * (1.0F - fx) * fy + d * fx * fy;

+ 4 - 4
render/ground/riverbank_renderer.cpp

@@ -50,10 +50,10 @@ void RiverbankRenderer::buildMeshes() {
     fx = fx * fx * (3.0F - 2.0F * fx);
     fy = fy * fy * (3.0F - 2.0F * fy);
 
-    float const a = Ground::noiseHash(ix, iy);
-    float const b = Ground::noiseHash(ix + 1.0F, iy);
-    float const c = Ground::noiseHash(ix, iy + 1.0F);
-    float const d = Ground::noiseHash(ix + 1.0F, iy + 1.0F);
+    float const a = Ground::noise_hash(ix, iy);
+    float const b = Ground::noise_hash(ix + 1.0F, iy);
+    float const c = Ground::noise_hash(ix, iy + 1.0F);
+    float const d = Ground::noise_hash(ix + 1.0F, iy + 1.0F);
 
     return a * (1.0F - fx) * (1.0F - fy) + b * fx * (1.0F - fy) +
            c * (1.0F - fx) * fy + d * fx * fy;

+ 12 - 12
render/ground/stone_renderer.cpp

@@ -29,10 +29,10 @@ inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
   int z1 = z0 + 1;
   float tx = x - float(x0);
   float tz = z - float(z0);
-  float const n00 = hashTo01(hashCoords(x0, z0, salt));
-  float const n10 = hashTo01(hashCoords(x1, z0, salt));
-  float const n01 = hashTo01(hashCoords(x0, z1, salt));
-  float const n11 = hashTo01(hashCoords(x1, z1, salt));
+  float const n00 = hash_to_01(hash_coords(x0, z0, salt));
+  float const n10 = hash_to_01(hash_coords(x1, z0, salt));
+  float const n01 = hash_to_01(hash_coords(x0, z1, salt));
+  float const n11 = hash_to_01(hash_coords(x1, z1, salt));
   float const nx0 = n00 * (1 - tx) + n10 * tx;
   float const nx1 = n01 * (1 - tx) + n11 * tx;
   return nx0 * (1 - tz) + nx1 * tz;
@@ -207,18 +207,18 @@ void StoneRenderer::generateStoneInstances() {
       return false;
     }
 
-    float const scale = remap(rand01(state), 0.08F, 0.25F) * tile_safe;
+    float const scale = remap(rand_01(state), 0.08F, 0.25F) * tile_safe;
 
-    float const color_var = remap(rand01(state), 0.0F, 1.0F);
+    float const color_var = remap(rand_01(state), 0.0F, 1.0F);
     QVector3D const base_rock = m_biomeSettings.rockLow;
     QVector3D const high_rock = m_biomeSettings.rockHigh;
     QVector3D color = base_rock * (1.0F - color_var) + high_rock * color_var;
 
-    float const brown_mix = remap(rand01(state), 0.0F, 0.4F);
+    float const brown_mix = remap(rand_01(state), 0.0F, 0.4F);
     QVector3D const brown_tint(0.45F, 0.38F, 0.30F);
     color = color * (1.0F - brown_mix) + brown_tint * brown_mix;
 
-    float const rotation = rand01(state) * MathConstants::TwoPi;
+    float const rotation = rand_01(state) * math_constants::k_two_pi;
 
     StoneInstanceGpu instance;
     instance.posScale = QVector4D(world_x, world_y + 0.01F, world_z, scale);
@@ -243,7 +243,7 @@ void StoneRenderer::generateStoneInstances() {
         continue;
       }
 
-      uint32_t state = hashCoords(
+      uint32_t state = hash_coords(
           x, z, m_noiseSeed ^ 0xABCDEF12U ^ static_cast<uint32_t>(idx));
 
       float const world_x = (x - half_width) * m_tile_size;
@@ -257,13 +257,13 @@ void StoneRenderer::generateStoneInstances() {
 
       int stone_count = static_cast<int>(std::floor(stone_density));
       float const frac = stone_density - float(stone_count);
-      if (rand01(state) < frac) {
+      if (rand_01(state) < frac) {
         stone_count += 1;
       }
 
       for (int i = 0; i < stone_count; ++i) {
-        float const gx = float(x) + rand01(state) * 2.0F;
-        float const gz = float(z) + rand01(state) * 2.0F;
+        float const gx = float(x) + rand_01(state) * 2.0F;
+        float const gz = float(z) + rand_01(state) * 2.0F;
         add_stone(gx, gz, state);
       }
     }

+ 11 - 11
render/ground/terrain_renderer.cpp

@@ -31,7 +31,7 @@ namespace {
 using std::uint32_t;
 using namespace Render::GL::BitShift;
 using namespace Render::GL::Geometry;
-using namespace Render::GL::Hash;
+using namespace Render::GL::hash_xor_shift;
 using namespace Render::Ground;
 
 const QMatrix4x4 k_identity_matrix;
@@ -62,10 +62,10 @@ inline auto valueNoise(float x, float z, uint32_t salt = 0U) -> float {
   int z1 = z0 + 1;
   float tx = x - float(x0);
   float tz = z - float(z0);
-  float const n00 = hashTo01(hashCoords(x0, z0, salt));
-  float const n10 = hashTo01(hashCoords(x1, z0, salt));
-  float const n01 = hashTo01(hashCoords(x0, z1, salt));
-  float const n11 = hashTo01(hashCoords(x1, z1, salt));
+  float const n00 = hash_to_01(hash_coords(x0, z0, salt));
+  float const n10 = hash_to_01(hash_coords(x1, z0, salt));
+  float const n01 = hash_to_01(hash_coords(x0, z1, salt));
+  float const n11 = hash_to_01(hash_coords(x1, z1, salt));
   float const nx0 = n00 * (1 - tx) + n10 * tx;
   float const nx1 = n01 * (1 - tx) + n11 * tx;
   return nx0 * (1 - tz) + nx1 * tz;
@@ -346,8 +346,8 @@ void TerrainRenderer::buildMeshes() {
 
       SectionData sections[3];
 
-      uint32_t const chunk_seed = hashCoords(chunk_x, chunk_z, m_noiseSeed);
-      uint32_t const variant_seed = chunk_seed ^ GoldenRatio;
+      uint32_t const chunk_seed = hash_coords(chunk_x, chunk_z, m_noiseSeed);
+      uint32_t const variant_seed = chunk_seed ^ k_golden_ratio;
       float const rotation_step =
           static_cast<float>((variant_seed >> 5) & 3) * 90.0F;
       bool const flip = ((variant_seed >> 7) & 1U) != 0U;
@@ -648,11 +648,11 @@ void TerrainRenderer::buildMeshes() {
                                      : 0.95F));
 
         const uint32_t noise_key_a =
-            hashCoords(chunk.minX, chunk.minZ, m_noiseSeed ^ 0xB5297A4DU);
+            hash_coords(chunk.minX, chunk.minZ, m_noiseSeed ^ 0xB5297A4DU);
         const uint32_t noise_key_b =
-            hashCoords(chunk.minX, chunk.minZ, m_noiseSeed ^ 0x68E31DA4U);
-        params.noiseOffset = QVector2D(hashTo01(noise_key_a) * 256.0F,
-                                       hashTo01(noise_key_b) * 256.0F);
+            hash_coords(chunk.minX, chunk.minZ, m_noiseSeed ^ 0x68E31DA4U);
+        params.noiseOffset = QVector2D(hash_to_01(noise_key_a) * 256.0F,
+                                       hash_to_01(noise_key_b) * 256.0F);
 
         float base_amp =
             m_biomeSettings.heightNoiseAmplitude *

+ 5 - 5
render/humanoid_math.h

@@ -7,11 +7,11 @@
 
 namespace Render::GL {
 
-inline auto hash01(uint32_t x) -> float {
-  x ^= x << Hash::XorShiftAmount13;
-  x ^= x >> Hash::XorShiftAmount17;
-  x ^= x << Hash::XorShiftAmount5;
-  return (x & BitShift::Mask24Bit) / float(BitShift::Mask24BitHex);
+inline auto hash_01(uint32_t x) -> float {
+  x ^= x << hash_xor_shift::k_xor_shift_amount_13;
+  x ^= x >> hash_xor_shift::k_xor_shift_amount_17;
+  x ^= x << hash_xor_shift::k_xor_shift_amount_5;
+  return (x & BitShift::Mask24Bit) / float(BitShift::k_mask_24bit_hex);
 }
 
 inline auto rotY(const QVector3D &v, float angle_rad) -> QVector3D {