浏览代码

Use PascalCase for namespace names

- Rename math_constants → MathConstants
- Rename hash_xor_shift → HashXorShift
- Rename hash_constants → HashConstants
- Update all namespace references in cpp files
- Keep constants and functions in snake_case with k_ prefix
- Namespaces now follow project convention (PascalCase)

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 月之前
父节点
当前提交
2d3c58b2ca

+ 1 - 1
render/entity/archer_renderer.cpp

@@ -528,7 +528,7 @@ private:
              v.palette.leather, nullptr, 1.0F);
 
     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;
+    float const k = (hash_01(seed ^ HashXorShift::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),

+ 1 - 1
render/entity/arrow_vfx_renderer.cpp

@@ -298,7 +298,7 @@ static inline void drawQuiver(const DrawContext &p, ISubmitter &out,
            C.leather, nullptr, 1.0F);
 
   float j = (hash_01(seed) - 0.5F) * 0.04F;
-  float k = (hash_01(seed ^ hash_xor_shift::k_golden_ratio) - 0.5F) * 0.04F;
+  float k = (hash_01(seed ^ HashXorShift::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),

+ 4 - 4
render/gl/render_constants.h

@@ -2,10 +2,10 @@
 
 #include <numbers>
 
-namespace Render::GL::math_constants {
+namespace Render::GL::MathConstants {
 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::MathConstants
 
 namespace Render::GL::VertexAttrib {
 inline constexpr int Position = 0;
@@ -89,9 +89,9 @@ inline constexpr float Mask24BitFloat = 16777215.0F;
 inline constexpr unsigned int k_mask_24bit_hex = 0x01000000U;
 } // namespace Render::GL::BitShift
 
-namespace Render::GL::hash_xor_shift {
+namespace Render::GL::HashXorShift {
 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
+} // namespace Render::GL::HashXorShift

+ 3 - 3
render/ground/biome_renderer.cpp

@@ -275,8 +275,8 @@ void BiomeRenderer::generateGrassInstances() {
 
     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;
+    float const sway_phase = rand_01(state) * MathConstants::k_two_pi;
+    float const orientation = rand_01(state) * MathConstants::k_two_pi;
 
     GrassInstanceGpu instance;
     instance.posHeight = QVector4D(world_x, world_y, world_z, height);
@@ -436,7 +436,7 @@ void BiomeRenderer::generateGrassInstances() {
               (0.45F + 0.55F * rand_01(state)) * scatter_base * tile_safe;
 
           for (int blade = 0; blade < blades; ++blade) {
-            float const angle = rand_01(state) * math_constants::k_two_pi;
+            float const angle = rand_01(state) * MathConstants::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;

+ 2 - 2
render/ground/firecamp_renderer.cpp

@@ -140,7 +140,7 @@ void FireCampRenderer::submit(Renderer &renderer, ResourceManager *resources) {
         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() *
-                                         hash_constants::k_temporal_variation_frequency));
+                                         HashConstants::k_temporal_variation_frequency));
 
     const float time = params.time;
     const float char_amount =
@@ -299,7 +299,7 @@ void FireCampRenderer::generateFireCampInstances() {
     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 = rand_01(state) * math_constants::k_two_pi;
+    float const phase = rand_01(state) * MathConstants::k_two_pi;
 
     float const duration = 1.0F;
 

+ 20 - 20
render/ground/ground_utils.h

@@ -8,11 +8,11 @@ namespace Render::Ground {
 
 using std::uint32_t;
 
-namespace math_constants {
-inline constexpr float k_two_pi = ::Render::GL::math_constants::k_two_pi;
-} // namespace math_constants
+namespace MathConstants {
+inline constexpr float k_two_pi = ::Render::GL::MathConstants::k_two_pi;
+} // namespace MathConstants
 
-namespace hash_constants {
+namespace HashConstants {
 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;
@@ -29,17 +29,17 @@ 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
+} // namespace HashConstants
 
 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);
+  auto const ux = static_cast<uint32_t>(x * HashConstants::k_spatial_hash_prime_1);
+  auto const uz = static_cast<uint32_t>(z * HashConstants::k_spatial_hash_prime_2);
+  return ux ^ uz ^ (salt * HashConstants::k_spatial_hash_prime_3);
 }
 
 inline auto rand_01(uint32_t &state) -> float {
-  state = state * hash_constants::k_linear_congruential_multiplier +
-          hash_constants::k_linear_congruential_increment;
+  state = state * HashConstants::k_linear_congruential_multiplier +
+          HashConstants::k_linear_congruential_increment;
   return static_cast<float>((state >> ::Render::GL::BitShift::Shift8) &
                             ::Render::GL::BitShift::Mask24Bit) /
          ::Render::GL::BitShift::Mask24BitFloat;
@@ -50,22 +50,22 @@ inline auto remap(float value, float min_out, float max_out) -> float {
 }
 
 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;
+  h ^= h >> HashConstants::k_xor_shift_amount_17;
+  h *= HashConstants::k_hash_mix_multiplier_1;
+  h ^= h >> HashConstants::k_xor_shift_amount_11;
+  h *= HashConstants::k_hash_mix_multiplier_2;
+  h ^= h >> HashConstants::k_xor_shift_amount_15;
+  h *= HashConstants::k_hash_mix_multiplier_3;
+  h ^= h >> HashConstants::k_xor_shift_amount_14;
   return static_cast<float>((h >> ::Render::GL::BitShift::Shift8) &
                             ::Render::GL::BitShift::Mask24Bit) /
          ::Render::GL::BitShift::Mask24BitFloat;
 }
 
 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;
+  float const n = std::sin(x * HashConstants::k_noise_frequency_x +
+                           y * HashConstants::k_noise_frequency_y) *
+                  HashConstants::k_noise_amplitude;
   return n - std::floor(n);
 }
 

+ 2 - 2
render/ground/pine_renderer.cpp

@@ -199,9 +199,9 @@ void PineRenderer::generatePineInstances() {
     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 = rand_01(state) * math_constants::k_two_pi;
+    float const sway_phase = rand_01(state) * MathConstants::k_two_pi;
 
-    float const rotation = rand_01(state) * math_constants::k_two_pi;
+    float const rotation = rand_01(state) * MathConstants::k_two_pi;
 
     float const silhouette_seed = rand_01(state);
     float const needle_seed = rand_01(state);

+ 2 - 2
render/ground/plant_renderer.cpp

@@ -275,11 +275,11 @@ void PlantRenderer::generatePlantInstances() {
     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 = rand_01(state) * math_constants::k_two_pi;
+    float const sway_phase = rand_01(state) * MathConstants::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 = rand_01(state) * math_constants::k_two_pi;
+    float const rotation = rand_01(state) * MathConstants::k_two_pi;
 
     PlantInstanceGpu instance;
 

+ 1 - 1
render/ground/stone_renderer.cpp

@@ -218,7 +218,7 @@ void StoneRenderer::generateStoneInstances() {
     QVector3D const brown_tint(0.45F, 0.38F, 0.30F);
     color = color * (1.0F - brown_mix) + brown_tint * brown_mix;
 
-    float const rotation = rand_01(state) * math_constants::k_two_pi;
+    float const rotation = rand_01(state) * MathConstants::k_two_pi;
 
     StoneInstanceGpu instance;
     instance.posScale = QVector4D(world_x, world_y + 0.01F, world_z, scale);

+ 1 - 1
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_xor_shift;
+using namespace Render::GL::HashXorShift;
 using namespace Render::Ground;
 
 const QMatrix4x4 k_identity_matrix;

+ 3 - 3
render/humanoid_math.h

@@ -8,9 +8,9 @@
 namespace Render::GL {
 
 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;
+  x ^= x << HashXorShift::k_xor_shift_amount_13;
+  x ^= x >> HashXorShift::k_xor_shift_amount_17;
+  x ^= x << HashXorShift::k_xor_shift_amount_5;
   return (x & BitShift::Mask24Bit) / float(BitShift::k_mask_24bit_hex);
 }