浏览代码

Extract visual constants to header file

- Add k_indicator_height_base, k_indicator_size constants
- Add k_indicator_alpha for transparency
- Add k_indicator_height_multiplier for scaling
- Add k_hold_mode_color and k_guard_mode_color
- Replace all hard-coded values in scene_renderer.cpp with named constants
- Improves configurability and maintainability

Co-authored-by: djeada <[email protected]>
copilot-swe-agent[bot] 6 天之前
父节点
当前提交
8eb369f9e7
共有 2 个文件被更改,包括 21 次插入7 次删除
  1. 11 0
      render/geom/mode_indicator.h
  2. 10 7
      render/scene_renderer.cpp

+ 11 - 0
render/geom/mode_indicator.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include "../gl/mesh.h"
+#include <QVector3D>
 #include <memory>
 
 namespace Render::Geom {
@@ -9,6 +10,16 @@ namespace Render::Geom {
 constexpr int k_mode_type_hold = 0;
 constexpr int k_mode_type_guard = 1;
 
+// Visual constants for mode indicators
+constexpr float k_indicator_height_base = 2.0F;    // Height above unit
+constexpr float k_indicator_size = 0.4F;           // Size of indicator mesh
+constexpr float k_indicator_alpha = 0.85F;         // Transparency level
+constexpr float k_indicator_height_multiplier = 2.0F; // Scale multiplier
+
+// Mode indicator colors
+const QVector3D k_hold_mode_color(1.0F, 0.3F, 0.3F);  // Red for hold mode
+const QVector3D k_guard_mode_color(0.3F, 0.5F, 1.0F); // Blue for guard mode
+
 class ModeIndicator {
 public:
   static auto get_hold_mode_mesh() -> Render::GL::Mesh *;

+ 10 - 7
render/scene_renderer.cpp

@@ -463,8 +463,8 @@ void Renderer::enqueue_mode_indicator(
   }
 
   // Calculate position above unit
-  float indicator_height = 2.0F; // Height above unit
-  float indicator_size = 0.4F;   // Size of indicator mesh
+  float indicator_height = Render::Geom::k_indicator_height_base;
+  float indicator_size = Render::Geom::k_indicator_size;
 
   // Adjust based on unit scale
   if (unit_comp != nullptr) {
@@ -483,7 +483,9 @@ void Renderer::enqueue_mode_indicator(
               nation_id, *troop_type_opt);
 
       // Use unit height to position indicator
-      indicator_height += profile.visuals.selection_ring_y_offset * 2.0F;
+      indicator_height +=
+          profile.visuals.selection_ring_y_offset *
+          Render::Geom::k_indicator_height_multiplier;
     }
   }
 
@@ -529,15 +531,16 @@ void Renderer::enqueue_mode_indicator(
   }
 
   // Determine mode type and color
-  int mode_type = Render::Geom::k_mode_type_hold; // Hold mode by default
-  QVector3D color(1.0F, 0.3F, 0.3F);               // Red for hold mode
+  int mode_type = Render::Geom::k_mode_type_hold;
+  QVector3D color = Render::Geom::k_hold_mode_color;
 
   if (has_guard_mode) {
     mode_type = Render::Geom::k_mode_type_guard;
-    color = QVector3D(0.3F, 0.5F, 1.0F); // Blue for guard mode
+    color = Render::Geom::k_guard_mode_color;
   }
 
-  mode_indicator(indicator_model, mode_type, color, 0.85F);
+  mode_indicator(indicator_model, mode_type, color,
+                 Render::Geom::k_indicator_alpha);
 }
 
 void Renderer::render_world(Engine::Core::World *world) {