Browse Source

apply format

djeada 1 month ago
parent
commit
7e68026cdb

+ 5 - 4
render/entity/horse_archer_renderer_base.h

@@ -53,10 +53,11 @@ public:
 protected:
 protected:
   const HorseArcherRendererConfig &config() const { return m_config; }
   const HorseArcherRendererConfig &config() const { return m_config; }
 
 
-  void apply_riding_animation(
-      MountedPoseController &controller, MountedAttachmentFrame &mount,
-      const HumanoidAnimationContext &anim_ctx, HumanoidPose &pose,
-      const HorseDimensions &dims, const ReinState &reins) const override;
+  void apply_riding_animation(MountedPoseController &controller,
+                              MountedAttachmentFrame &mount,
+                              const HumanoidAnimationContext &anim_ctx,
+                              HumanoidPose &pose, const HorseDimensions &dims,
+                              const ReinState &reins) const override;
 
 
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
                       const HumanoidPose &pose,
                       const HumanoidPose &pose,

+ 5 - 4
render/entity/horse_spearman_renderer_base.h

@@ -53,10 +53,11 @@ public:
 protected:
 protected:
   const HorseSpearmanRendererConfig &config() const { return m_config; }
   const HorseSpearmanRendererConfig &config() const { return m_config; }
 
 
-  void apply_riding_animation(
-      MountedPoseController &controller, MountedAttachmentFrame &mount,
-      const HumanoidAnimationContext &anim_ctx, HumanoidPose &pose,
-      const HorseDimensions &dims, const ReinState &reins) const override;
+  void apply_riding_animation(MountedPoseController &controller,
+                              MountedAttachmentFrame &mount,
+                              const HumanoidAnimationContext &anim_ctx,
+                              HumanoidPose &pose, const HorseDimensions &dims,
+                              const ReinState &reins) const override;
 
 
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
                       const HumanoidPose &pose,
                       const HumanoidPose &pose,

+ 0 - 3
render/entity/mounted_humanoid_renderer_base.cpp

@@ -90,8 +90,6 @@ void MountedHumanoidRendererBase::addAttachments(
                                        0xFFFFFFFFU);
                                        0xFFFFFFFFU);
   }
   }
 
 
-  // We need a non-const profile because render() might modify it if motion is not shared
-  // (though in our case motion IS shared if is_current_pose is true)
   const HorseProfile &profile_const = get_cached_horse_profile(horse_seed, v);
   const HorseProfile &profile_const = get_cached_horse_profile(horse_seed, v);
   HorseProfile &profile = const_cast<HorseProfile &>(profile_const);
   HorseProfile &profile = const_cast<HorseProfile &>(profile_const);
 
 
@@ -107,7 +105,6 @@ void MountedHumanoidRendererBase::addAttachments(
   m_horseRenderer.render(ctx, anim, anim_ctx, profile, mount_ptr, rein_ptr,
   m_horseRenderer.render(ctx, anim, anim_ctx, profile, mount_ptr, rein_ptr,
                          motion_ptr, out);
                          motion_ptr, out);
 
 
-  // Reset state
   m_last_pose = nullptr;
   m_last_pose = nullptr;
   m_has_last_reins = false;
   m_has_last_reins = false;
 
 

+ 4 - 9
render/entity/mounted_humanoid_renderer_base.h

@@ -1,8 +1,8 @@
 #pragma once
 #pragma once
 
 
+#include "../humanoid/mounted_pose_controller.h"
 #include "../humanoid/rig.h"
 #include "../humanoid/rig.h"
 #include "horse_renderer.h"
 #include "horse_renderer.h"
-#include "../humanoid/mounted_pose_controller.h"
 
 
 #include <unordered_map>
 #include <unordered_map>
 
 
@@ -13,7 +13,6 @@ public:
   MountedHumanoidRendererBase();
   MountedHumanoidRendererBase();
   ~MountedHumanoidRendererBase() override = default;
   ~MountedHumanoidRendererBase() override = default;
 
 
-  // Common HumanoidRendererBase overrides
   void customize_pose(const DrawContext &ctx,
   void customize_pose(const DrawContext &ctx,
                       const HumanoidAnimationContext &anim_ctx, uint32_t seed,
                       const HumanoidAnimationContext &anim_ctx, uint32_t seed,
                       HumanoidPose &pose) const override;
                       HumanoidPose &pose) const override;
@@ -23,7 +22,6 @@ public:
                       const HumanoidAnimationContext &anim_ctx,
                       const HumanoidAnimationContext &anim_ctx,
                       ISubmitter &out) const override;
                       ISubmitter &out) const override;
 
 
-  // Pure virtuals to be implemented by specific mounted units
   virtual auto get_mount_scale() const -> float = 0;
   virtual auto get_mount_scale() const -> float = 0;
 
 
 protected:
 protected:
@@ -33,25 +31,22 @@ protected:
                                       HumanoidPose &pose,
                                       HumanoidPose &pose,
                                       const HorseDimensions &dims,
                                       const HorseDimensions &dims,
                                       const ReinState &reins) const = 0;
                                       const ReinState &reins) const = 0;
-  
-  // Optional hook for drawing specific equipment (bow, spear, shield, etc.)
+
   virtual void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
   virtual void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
                               const HumanoidPose &pose,
                               const HumanoidPose &pose,
                               const HumanoidAnimationContext &anim_ctx,
                               const HumanoidAnimationContext &anim_ctx,
                               ISubmitter &out) const {}
                               ISubmitter &out) const {}
 
 
-  // Helper methods
   auto get_scaled_horse_dimensions(uint32_t seed) const -> HorseDimensions;
   auto get_scaled_horse_dimensions(uint32_t seed) const -> HorseDimensions;
-  auto get_cached_horse_profile(uint32_t seed, const HumanoidVariant &v) const -> const HorseProfile&;
+  auto get_cached_horse_profile(uint32_t seed, const HumanoidVariant &v) const
+      -> const HorseProfile &;
 
 
-  // Members
   HorseRenderer m_horseRenderer;
   HorseRenderer m_horseRenderer;
 
 
 private:
 private:
   mutable std::unordered_map<uint32_t, HorseProfile> m_profile_cache;
   mutable std::unordered_map<uint32_t, HorseProfile> m_profile_cache;
   static constexpr size_t MAX_PROFILE_CACHE_SIZE = 100;
   static constexpr size_t MAX_PROFILE_CACHE_SIZE = 100;
 
 
-  // State for synchronization (Jitter Fix)
   mutable const HumanoidPose *m_last_pose = nullptr;
   mutable const HumanoidPose *m_last_pose = nullptr;
   mutable MountedAttachmentFrame m_last_mount{};
   mutable MountedAttachmentFrame m_last_mount{};
   mutable HorseMotionSample m_last_motion{};
   mutable HorseMotionSample m_last_motion{};

+ 5 - 4
render/entity/mounted_knight_renderer_base.h

@@ -53,10 +53,11 @@ public:
 protected:
 protected:
   const MountedKnightRendererConfig &config() const { return m_config; }
   const MountedKnightRendererConfig &config() const { return m_config; }
 
 
-  void apply_riding_animation(
-      MountedPoseController &controller, MountedAttachmentFrame &mount,
-      const HumanoidAnimationContext &anim_ctx, HumanoidPose &pose,
-      const HorseDimensions &dims, const ReinState &reins) const override;
+  void apply_riding_animation(MountedPoseController &controller,
+                              MountedAttachmentFrame &mount,
+                              const HumanoidAnimationContext &anim_ctx,
+                              HumanoidPose &pose, const HorseDimensions &dims,
+                              const ReinState &reins) const override;
 
 
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
   void draw_equipment(const DrawContext &ctx, const HumanoidVariant &v,
                       const HumanoidPose &pose,
                       const HumanoidPose &pose,

+ 18 - 24
render/equipment/helmets/carthage_heavy_helmet.cpp

@@ -57,13 +57,12 @@ void CarthageHeavyHelmetRenderer::render_bowl(const DrawContext &ctx,
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
@@ -93,13 +92,12 @@ void CarthageHeavyHelmetRenderer::render_cheek_guards(
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
@@ -131,13 +129,12 @@ void CarthageHeavyHelmetRenderer::render_face_plate(const DrawContext &ctx,
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
@@ -168,13 +165,12 @@ void CarthageHeavyHelmetRenderer::render_neck_guard(const DrawContext &ctx,
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
@@ -197,13 +193,12 @@ void CarthageHeavyHelmetRenderer::render_brow_arch(const DrawContext &ctx,
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
@@ -232,13 +227,12 @@ void CarthageHeavyHelmetRenderer::render_crest(const DrawContext &ctx,
   const float helm_scale = 1.2f;
   const float helm_scale = 1.2f;
   const float helmet_y_offset = R * 0.1f;
   const float helmet_y_offset = R * 0.1f;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Scale coordinates to ensure helmet parts are outside the head
     QVector3D scaled_n = n;
     QVector3D scaled_n = n;
-    // Apply extra forward offset for face-covering parts
+
     if (scaled_n.z() > 0.2f) {
     if (scaled_n.z() > 0.2f) {
-       scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
+      scaled_n.setZ(std::max(scaled_n.z(), 1.05f / helm_scale));
     }
     }
-    // Apply general scale
+
     scaled_n = scaled_n * helm_scale;
     scaled_n = scaled_n * helm_scale;
 
 
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);
     QVector3D p = HumanoidRendererBase::frameLocalPosition(head, scaled_n);

+ 0 - 1
render/equipment/helmets/carthage_light_helmet.cpp

@@ -108,7 +108,6 @@ void CarthageLightHelmetRenderer::render_bowl(const DrawContext &ctx,
   QVector3D const helmet_offset = helmetLiftVector(head);
   QVector3D const helmet_offset = helmetLiftVector(head);
   QVector3D const helmet_origin = head.origin + helmet_offset;
   QVector3D const helmet_origin = head.origin + helmet_offset;
   auto headPoint = [&](const QVector3D &n) {
   auto headPoint = [&](const QVector3D &n) {
-    // Use scaled radius for helmet parts to ensure they cover the head
     QVector3D p = n * helmetScale;
     QVector3D p = n * helmetScale;
     return HumanoidRendererBase::frameLocalPosition(head, p) + helmet_offset;
     return HumanoidRendererBase::frameLocalPosition(head, p) + helmet_offset;
   };
   };

+ 1 - 1
render/equipment/helmets/roman_heavy_helmet.cpp

@@ -58,7 +58,7 @@ void RomanHeavyHelmetRenderer::render(const DrawContext &ctx,
   const AttachmentFrame &head = frames.head;
   const AttachmentFrame &head = frames.head;
   float head_r = head.radius;
   float head_r = head.radius;
   if (head_r <= 0.0f) {
   if (head_r <= 0.0f) {
-      return;
+    return;
   }
   }
 
 
   auto head_point = [&](const QVector3D &n) {
   auto head_point = [&](const QVector3D &n) {

+ 7 - 7
render/geom/transforms.cpp

@@ -1,9 +1,9 @@
 #include "transforms.h"
 #include "transforms.h"
-#include <algorithm>
-#include <cmath>
 #include <QMatrix4x4>
 #include <QMatrix4x4>
-#include <QVector3D>
 #include <QQuaternion>
 #include <QQuaternion>
+#include <QVector3D>
+#include <algorithm>
+#include <cmath>
 
 
 namespace Render::Geom {
 namespace Render::Geom {
 
 
@@ -25,13 +25,13 @@ auto cylinderBetween(const QVector3D &a, const QVector3D &b,
   if (len_sq > k_epsilon_sq) {
   if (len_sq > k_epsilon_sq) {
     const float len = std::sqrt(len_sq);
     const float len = std::sqrt(len_sq);
     const QVector3D dir = diff / len;
     const QVector3D dir = diff / len;
-    
+
     const QVector3D up(0.0F, 1.0F, 0.0F);
     const QVector3D up(0.0F, 1.0F, 0.0F);
     if (QVector3D::dotProduct(up, dir) < -0.99999F) {
     if (QVector3D::dotProduct(up, dir) < -0.99999F) {
-        m.rotate(180.0F, 1.0F, 0.0F, 0.0F);
+      m.rotate(180.0F, 1.0F, 0.0F, 0.0F);
     } else {
     } else {
-        QQuaternion rot = QQuaternion::rotationTo(up, dir);
-        m.rotate(rot);
+      QQuaternion rot = QQuaternion::rotationTo(up, dir);
+      m.rotate(rot);
     }
     }
     m.scale(radius, len, radius);
     m.scale(radius, len, radius);
   } else {
   } else {

+ 9 - 12
render/horse/rig.cpp

@@ -403,14 +403,11 @@ void apply_mount_vertical_offset(MountedAttachmentFrame &frame, float bob) {
   frame.bridle_base += offset;
   frame.bridle_base += offset;
 }
 }
 
 
-void HorseRendererBase::render(const DrawContext &ctx,
-                               const AnimationInputs &anim,
-                               const HumanoidAnimationContext &rider_ctx,
-                               HorseProfile &profile,
-                               const MountedAttachmentFrame *shared_mount,
-                               const ReinState *shared_reins,
-                               const HorseMotionSample *shared_motion,
-                               ISubmitter &out) const {
+void HorseRendererBase::render(
+    const DrawContext &ctx, const AnimationInputs &anim,
+    const HumanoidAnimationContext &rider_ctx, HorseProfile &profile,
+    const MountedAttachmentFrame *shared_mount, const ReinState *shared_reins,
+    const HorseMotionSample *shared_motion, ISubmitter &out) const {
   const HorseDimensions &d = profile.dims;
   const HorseDimensions &d = profile.dims;
   const HorseVariant &v = profile.variant;
   const HorseVariant &v = profile.variant;
   const HorseGait &g = profile.gait;
   const HorseGait &g = profile.gait;
@@ -1062,13 +1059,13 @@ void HorseRendererBase::render(const DrawContext &ctx,
         v.coatColor, is_rear ? 0.48F : 0.58F, is_rear ? -0.22F : 0.18F,
         v.coatColor, is_rear ? 0.48F : 0.58F, is_rear ? -0.22F : 0.18F,
         coat_seed_a + lateralSign * 0.07F);
         coat_seed_a + lateralSign * 0.07F);
 
 
-    draw_cylinder(out, horse_ctx.model, shoulder, knee, (shoulder_r + upper_r) * 0.5F,
-                  thigh_color, 1.0F, 6);
+    draw_cylinder(out, horse_ctx.model, shoulder, knee,
+                  (shoulder_r + upper_r) * 0.5F, thigh_color, 1.0F, 6);
 
 
     QVector3D const shin_color = darken(thigh_color, is_rear ? 0.90F : 0.92F);
     QVector3D const shin_color = darken(thigh_color, is_rear ? 0.90F : 0.92F);
 
 
-    draw_cylinder(out, horse_ctx.model, knee, cannon, (knee_r + cannon_r) * 0.5F,
-                  shin_color, 1.0F, 6);
+    draw_cylinder(out, horse_ctx.model, knee, cannon,
+                  (knee_r + cannon_r) * 0.5F, shin_color, 1.0F, 6);
 
 
     QVector3D const hoof_joint_color =
     QVector3D const hoof_joint_color =
         darken(shin_color, is_rear ? 0.92F : 0.94F);
         darken(shin_color, is_rear ? 0.92F : 0.94F);

+ 2 - 2
ui/qml/HUDBottom.qml

@@ -105,9 +105,9 @@ RowLayout {
                             onEntered: selectedUnitItem.isHovered = true
                             onEntered: selectedUnitItem.isHovered = true
                             onExited: selectedUnitItem.isHovered = false
                             onExited: selectedUnitItem.isHovered = false
                             onClicked: function(mouse) {
                             onClicked: function(mouse) {
-                                if (mouse.button === Qt.LeftButton && typeof game !== 'undefined' && game.selectUnitById && typeof unit_id !== 'undefined') {
+                                if (mouse.button === Qt.LeftButton && typeof game !== 'undefined' && game.selectUnitById && typeof unit_id !== 'undefined')
                                     game.selectUnitById(unit_id);
                                     game.selectUnitById(unit_id);
-                                }
+
                             }
                             }
                         }
                         }