Browse Source

Convert DrawContext and GraphicsSettings struct members to snake_case

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 1 week ago
parent
commit
bb8ac4939e

+ 1 - 1
render/entity/nations/carthage/catapult_renderer.cpp

@@ -245,7 +245,7 @@ void register_catapult_renderer(EntityRendererRegistry &registry) {
         drawBaseFrame(p, out, unit_cube, white_tex, palette);
         drawWheels(p, out, unit_cube, white_tex, palette);
         drawTorsionMechanism(p, out, unit_cube, white_tex, palette);
-        drawThrowingArm(p, out, unit_cube, white_tex, palette, p.animationTime);
+        drawThrowingArm(p, out, unit_cube, white_tex, palette, p.animation_time);
         drawWindlass(p, out, unit_cube, white_tex, palette);
         drawDecorations(p, out, unit_cube, white_tex, palette);
       });

+ 1 - 1
render/entity/nations/roman/catapult_renderer.cpp

@@ -230,7 +230,7 @@ void register_catapult_renderer(EntityRendererRegistry &registry) {
         drawBaseFrame(p, out, unit_cube, white_tex, palette);
         drawWheels(p, out, unit_cube, white_tex, palette);
         drawTorsionMechanism(p, out, unit_cube, white_tex, palette);
-        drawThrowingArm(p, out, unit_cube, white_tex, palette, p.animationTime);
+        drawThrowingArm(p, out, unit_cube, white_tex, palette, p.animation_time);
         drawWindlass(p, out, unit_cube, white_tex, palette);
         drawDecorations(p, out, unit_cube, white_tex, palette);
       });

+ 2 - 2
render/entity/registry.h

@@ -44,8 +44,8 @@ struct DrawContext {
   QMatrix4x4 model;
   bool selected = false;
   bool hovered = false;
-  float animationTime = 0.0F;
-  std::string rendererId;
+  float animation_time = 0.0F;
+  std::string renderer_id;
   class Backend *backend = nullptr;
   const Camera *camera = nullptr;
 };

+ 1 - 1
render/gl/humanoid/animation/animation_inputs.cpp

@@ -11,7 +11,7 @@ namespace Render::GL {
 
 auto sampleAnimState(const DrawContext &ctx) -> AnimationInputs {
   AnimationInputs anim{};
-  anim.time = ctx.animationTime;
+  anim.time = ctx.animation_time;
   anim.is_moving = false;
   anim.is_attacking = false;
   anim.is_melee = false;

+ 134 - 134
render/graphics_settings.h

@@ -12,36 +12,36 @@ enum class GraphicsQuality : uint8_t {
 };
 
 struct LODMultipliers {
-  float humanoidFull;
-  float humanoidReduced;
-  float humanoidMinimal;
-  float humanoidBillboard;
-
-  float horseFull;
-  float horseReduced;
-  float horseMinimal;
-  float horseBillboard;
-
-  float shadowDistance;
-  bool enableShadows;
+  float humanoid_full;
+  float humanoid_reduced;
+  float humanoid_minimal;
+  float humanoid_billboard;
+
+  float horse_full;
+  float horse_reduced;
+  float horse_minimal;
+  float horse_billboard;
+
+  float shadow_distance;
+  bool enable_shadows;
 };
 
 struct GraphicsFeatures {
-  bool enableFacialHair;
-  bool enableManeDetail;
-  bool enableTailDetail;
-  bool enableArmorDetail;
-  bool enableEquipmentDetail;
-  bool enableGroundShadows;
-  bool enablePoseCache;
+  bool enable_facial_hair;
+  bool enable_mane_detail;
+  bool enable_tail_detail;
+  bool enable_armor_detail;
+  bool enable_equipment_detail;
+  bool enable_ground_shadows;
+  bool enable_pose_cache;
 };
 
 struct BatchingConfig {
-  bool forceBatching;
-  bool neverBatch;
-  int batchingUnitThreshold;
-  float batchingZoomStart;
-  float batchingZoomFull;
+  bool force_batching;
+  bool never_batch;
+  int batching_unit_threshold;
+  float batching_zoom_start;
+  float batching_zoom_full;
 };
 
 class GraphicsSettings {
@@ -75,30 +75,30 @@ public:
   [[nodiscard]] auto
   calculateBatchingRatio(int visibleUnits,
                          float cameraHeight) const noexcept -> float {
-    if (m_batchingConfig.neverBatch) {
+    if (m_batchingConfig.never_batch) {
       return 0.0F;
     }
-    if (m_batchingConfig.forceBatching) {
+    if (m_batchingConfig.force_batching) {
       return 1.0F;
     }
 
     float unitFactor = 0.0F;
-    if (visibleUnits > m_batchingConfig.batchingUnitThreshold) {
+    if (visibleUnits > m_batchingConfig.batching_unit_threshold) {
 
-      int excess = visibleUnits - m_batchingConfig.batchingUnitThreshold;
-      int range = m_batchingConfig.batchingUnitThreshold * 3;
+      int excess = visibleUnits - m_batchingConfig.batching_unit_threshold;
+      int range = m_batchingConfig.batching_unit_threshold * 3;
       unitFactor = static_cast<float>(excess) / static_cast<float>(range);
       unitFactor =
           unitFactor < 0.0F ? 0.0F : (unitFactor > 1.0F ? 1.0F : unitFactor);
     }
 
     float zoomFactor = 0.0F;
-    if (cameraHeight > m_batchingConfig.batchingZoomStart) {
-      float range = m_batchingConfig.batchingZoomFull -
-                    m_batchingConfig.batchingZoomStart;
+    if (cameraHeight > m_batchingConfig.batching_zoom_start) {
+      float range = m_batchingConfig.batching_zoom_full -
+                    m_batchingConfig.batching_zoom_start;
       if (range > 0.0F) {
         zoomFactor =
-            (cameraHeight - m_batchingConfig.batchingZoomStart) / range;
+            (cameraHeight - m_batchingConfig.batching_zoom_start) / range;
         zoomFactor =
             zoomFactor < 0.0F ? 0.0F : (zoomFactor > 1.0F ? 1.0F : zoomFactor);
       }
@@ -108,36 +108,36 @@ public:
   }
 
   [[nodiscard]] auto humanoidFullDetailDistance() const noexcept -> float {
-    return kBaseHumanoidFull * m_lodMultipliers.humanoidFull;
+    return kBaseHumanoidFull * m_lodMultipliers.humanoid_full;
   }
   [[nodiscard]] auto humanoidReducedDetailDistance() const noexcept -> float {
-    return kBaseHumanoidReduced * m_lodMultipliers.humanoidReduced;
+    return kBaseHumanoidReduced * m_lodMultipliers.humanoid_reduced;
   }
   [[nodiscard]] auto humanoidMinimalDetailDistance() const noexcept -> float {
-    return kBaseHumanoidMinimal * m_lodMultipliers.humanoidMinimal;
+    return kBaseHumanoidMinimal * m_lodMultipliers.humanoid_minimal;
   }
   [[nodiscard]] auto humanoidBillboardDistance() const noexcept -> float {
-    return kBaseHumanoidBillboard * m_lodMultipliers.humanoidBillboard;
+    return kBaseHumanoidBillboard * m_lodMultipliers.humanoid_billboard;
   }
 
   [[nodiscard]] auto horseFullDetailDistance() const noexcept -> float {
-    return kBaseHorseFull * m_lodMultipliers.horseFull;
+    return kBaseHorseFull * m_lodMultipliers.horse_full;
   }
   [[nodiscard]] auto horseReducedDetailDistance() const noexcept -> float {
-    return kBaseHorseReduced * m_lodMultipliers.horseReduced;
+    return kBaseHorseReduced * m_lodMultipliers.horse_reduced;
   }
   [[nodiscard]] auto horseMinimalDetailDistance() const noexcept -> float {
-    return kBaseHorseMinimal * m_lodMultipliers.horseMinimal;
+    return kBaseHorseMinimal * m_lodMultipliers.horse_minimal;
   }
   [[nodiscard]] auto horseBillboardDistance() const noexcept -> float {
-    return kBaseHorseBillboard * m_lodMultipliers.horseBillboard;
+    return kBaseHorseBillboard * m_lodMultipliers.horse_billboard;
   }
 
   [[nodiscard]] auto shadowMaxDistance() const noexcept -> float {
-    return m_lodMultipliers.shadowDistance;
+    return m_lodMultipliers.shadow_distance;
   }
   [[nodiscard]] auto shadowsEnabled() const noexcept -> bool {
-    return m_lodMultipliers.enableShadows;
+    return m_lodMultipliers.enable_shadows;
   }
 
 private:
@@ -147,109 +147,109 @@ private:
     switch (q) {
     case GraphicsQuality::Low:
 
-      m_lodMultipliers = {.humanoidFull = 0.8F,
-                          .humanoidReduced = 0.8F,
-                          .humanoidMinimal = 0.8F,
-                          .humanoidBillboard = 0.8F,
-                          .horseFull = 0.8F,
-                          .horseReduced = 0.8F,
-                          .horseMinimal = 0.8F,
-                          .horseBillboard = 0.8F,
-                          .shadowDistance = 25.0F,
-                          .enableShadows = true};
-      m_features = {.enableFacialHair = false,
-                    .enableManeDetail = false,
-                    .enableTailDetail = false,
-                    .enableArmorDetail = true,
-                    .enableEquipmentDetail = true,
-                    .enableGroundShadows = true,
-                    .enablePoseCache = true};
-      m_batchingConfig = {.forceBatching = true,
-                          .neverBatch = false,
-                          .batchingUnitThreshold = 0,
-                          .batchingZoomStart = 0.0F,
-                          .batchingZoomFull = 0.0F};
+      m_lodMultipliers = {.humanoid_full = 0.8F,
+                          .humanoid_reduced = 0.8F,
+                          .humanoid_minimal = 0.8F,
+                          .humanoid_billboard = 0.8F,
+                          .horse_full = 0.8F,
+                          .horse_reduced = 0.8F,
+                          .horse_minimal = 0.8F,
+                          .horse_billboard = 0.8F,
+                          .shadow_distance = 25.0F,
+                          .enable_shadows = true};
+      m_features = {.enable_facial_hair = false,
+                    .enable_mane_detail = false,
+                    .enable_tail_detail = false,
+                    .enable_armor_detail = true,
+                    .enable_equipment_detail = true,
+                    .enable_ground_shadows = true,
+                    .enable_pose_cache = true};
+      m_batchingConfig = {.force_batching = true,
+                          .never_batch = false,
+                          .batching_unit_threshold = 0,
+                          .batching_zoom_start = 0.0F,
+                          .batching_zoom_full = 0.0F};
       break;
 
     case GraphicsQuality::Medium:
 
-      m_lodMultipliers = {.humanoidFull = 1.0F,
-                          .humanoidReduced = 1.0F,
-                          .humanoidMinimal = 1.0F,
-                          .humanoidBillboard = 1.0F,
-                          .horseFull = 1.0F,
-                          .horseReduced = 1.0F,
-                          .horseMinimal = 1.0F,
-                          .horseBillboard = 1.0F,
-                          .shadowDistance = 40.0F,
-                          .enableShadows = true};
-      m_features = {.enableFacialHair = true,
-                    .enableManeDetail = true,
-                    .enableTailDetail = true,
-                    .enableArmorDetail = true,
-                    .enableEquipmentDetail = true,
-                    .enableGroundShadows = true,
-                    .enablePoseCache = true};
-
-      m_batchingConfig = {.forceBatching = false,
-                          .neverBatch = false,
-                          .batchingUnitThreshold = 30,
-                          .batchingZoomStart = 60.0F,
-                          .batchingZoomFull = 90.0F};
+      m_lodMultipliers = {.humanoid_full = 1.0F,
+                          .humanoid_reduced = 1.0F,
+                          .humanoid_minimal = 1.0F,
+                          .humanoid_billboard = 1.0F,
+                          .horse_full = 1.0F,
+                          .horse_reduced = 1.0F,
+                          .horse_minimal = 1.0F,
+                          .horse_billboard = 1.0F,
+                          .shadow_distance = 40.0F,
+                          .enable_shadows = true};
+      m_features = {.enable_facial_hair = true,
+                    .enable_mane_detail = true,
+                    .enable_tail_detail = true,
+                    .enable_armor_detail = true,
+                    .enable_equipment_detail = true,
+                    .enable_ground_shadows = true,
+                    .enable_pose_cache = true};
+
+      m_batchingConfig = {.force_batching = false,
+                          .never_batch = false,
+                          .batching_unit_threshold = 30,
+                          .batching_zoom_start = 60.0F,
+                          .batching_zoom_full = 90.0F};
       break;
 
     case GraphicsQuality::High:
 
-      m_lodMultipliers = {.humanoidFull = 2.0F,
-                          .humanoidReduced = 2.0F,
-                          .humanoidMinimal = 2.0F,
-                          .humanoidBillboard = 2.0F,
-                          .horseFull = 2.0F,
-                          .horseReduced = 2.0F,
-                          .horseMinimal = 2.0F,
-                          .horseBillboard = 2.0F,
-                          .shadowDistance = 80.0F,
-                          .enableShadows = true};
-      m_features = {.enableFacialHair = true,
-                    .enableManeDetail = true,
-                    .enableTailDetail = true,
-                    .enableArmorDetail = true,
-                    .enableEquipmentDetail = true,
-                    .enableGroundShadows = true,
-                    .enablePoseCache = true};
-
-      m_batchingConfig = {.forceBatching = false,
-                          .neverBatch = false,
-                          .batchingUnitThreshold = 50,
-                          .batchingZoomStart = 80.0F,
-                          .batchingZoomFull = 120.0F};
+      m_lodMultipliers = {.humanoid_full = 2.0F,
+                          .humanoid_reduced = 2.0F,
+                          .humanoid_minimal = 2.0F,
+                          .humanoid_billboard = 2.0F,
+                          .horse_full = 2.0F,
+                          .horse_reduced = 2.0F,
+                          .horse_minimal = 2.0F,
+                          .horse_billboard = 2.0F,
+                          .shadow_distance = 80.0F,
+                          .enable_shadows = true};
+      m_features = {.enable_facial_hair = true,
+                    .enable_mane_detail = true,
+                    .enable_tail_detail = true,
+                    .enable_armor_detail = true,
+                    .enable_equipment_detail = true,
+                    .enable_ground_shadows = true,
+                    .enable_pose_cache = true};
+
+      m_batchingConfig = {.force_batching = false,
+                          .never_batch = false,
+                          .batching_unit_threshold = 50,
+                          .batching_zoom_start = 80.0F,
+                          .batching_zoom_full = 120.0F};
       break;
 
     case GraphicsQuality::Ultra:
 
-      m_lodMultipliers = {.humanoidFull = 100.0F,
-                          .humanoidReduced = 100.0F,
-                          .humanoidMinimal = 100.0F,
-                          .humanoidBillboard = 100.0F,
-                          .horseFull = 100.0F,
-                          .horseReduced = 100.0F,
-                          .horseMinimal = 100.0F,
-                          .horseBillboard = 100.0F,
-                          .shadowDistance = 200.0F,
-                          .enableShadows = true};
-      m_features = {.enableFacialHair = true,
-                    .enableManeDetail = true,
-                    .enableTailDetail = true,
-                    .enableArmorDetail = true,
-                    .enableEquipmentDetail = true,
-                    .enableGroundShadows = true,
-                    .enablePoseCache = false};
-
-      m_batchingConfig = {.forceBatching = false,
-                          .neverBatch = true,
-                          .batchingUnitThreshold = 999999,
-                          .batchingZoomStart = 999999.0F,
-                          .batchingZoomFull = 999999.0F};
+      m_lodMultipliers = {.humanoid_full = 100.0F,
+                          .humanoid_reduced = 100.0F,
+                          .humanoid_minimal = 100.0F,
+                          .humanoid_billboard = 100.0F,
+                          .horse_full = 100.0F,
+                          .horse_reduced = 100.0F,
+                          .horse_minimal = 100.0F,
+                          .horse_billboard = 100.0F,
+                          .shadow_distance = 200.0F,
+                          .enable_shadows = true};
+      m_features = {.enable_facial_hair = true,
+                    .enable_mane_detail = true,
+                    .enable_tail_detail = true,
+                    .enable_armor_detail = true,
+                    .enable_equipment_detail = true,
+                    .enable_ground_shadows = true,
+                    .enable_pose_cache = false};
+
+      m_batchingConfig = {.force_batching = false,
+                          .never_batch = true,
+                          .batching_unit_threshold = 999999,
+                          .batching_zoom_start = 999999.0F,
+                          .batching_zoom_full = 999999.0F};
       break;
     }
   }

+ 2 - 2
render/humanoid/rig.cpp

@@ -1369,8 +1369,8 @@ void HumanoidRendererBase::render(const DrawContext &ctx,
     DrawContext inst_ctx{ctx.resources, ctx.entity, ctx.world, inst_model};
     inst_ctx.selected = ctx.selected;
     inst_ctx.hovered = ctx.hovered;
-    inst_ctx.animationTime = ctx.animationTime;
-    inst_ctx.rendererId = ctx.rendererId;
+    inst_ctx.animation_time = ctx.animation_time;
+    inst_ctx.renderer_id = ctx.renderer_id;
     inst_ctx.backend = ctx.backend;
     inst_ctx.camera = ctx.camera;
 

+ 4 - 4
render/scene_renderer.cpp

@@ -423,7 +423,7 @@ void Renderer::render_world(Engine::Core::World *world) {
   }
 
   float fullShaderMaxDistance = 30.0F * (1.0F - batchingRatio * 0.7F);
-  if (batchConfig.forceBatching) {
+  if (batchConfig.force_batching) {
     fullShaderMaxDistance = 0.0F;
   }
 
@@ -508,15 +508,15 @@ void Renderer::render_world(Engine::Core::World *world) {
 
         ctx.selected = is_selected;
         ctx.hovered = is_hovered;
-        ctx.animationTime = m_accumulated_time;
-        ctx.rendererId = renderer_key;
+        ctx.animation_time = m_accumulated_time;
+        ctx.renderer_id = renderer_key;
         ctx.backend = m_backend.get();
         ctx.camera = m_camera;
 
         bool useBatching = (batchingRatio > 0.0F) &&
                            (distanceToCamera > fullShaderMaxDistance) &&
                            !is_selected && !is_hovered &&
-                           !batchConfig.neverBatch;
+                           !batchConfig.never_batch;
 
         if (useBatching) {
           fn(ctx, batchSubmitter);