style: aplicar fixes de clang-tidy (todo excepto uppercase-literal-suffix)

Corregidos ~2570 issues automáticamente con clang-tidy --fix-errors
más ajustes manuales posteriores:

- modernize: designated-initializers, trailing-return-type, use-auto,
  avoid-c-arrays (→ std::array<>), use-ranges, use-emplace,
  deprecated-headers, use-equals-default, pass-by-value,
  return-braced-init-list, use-default-member-init
- readability: math-missing-parentheses, implicit-bool-conversion,
  braces-around-statements, isolate-declaration, use-std-min-max,
  identifier-naming, else-after-return, redundant-casting,
  convert-member-functions-to-static, make-member-function-const,
  static-accessed-through-instance
- performance: avoid-endl, unnecessary-value-param, type-promotion,
  inefficient-vector-operation
- dead code: XOR_KEY (orphan tras eliminar encryptData/decryptData),
  dead stores en engine.cpp y png_shape.cpp
- NOLINT justificado en 10 funciones con alta complejidad cognitiva
  (initialize, render, main, processEvents, update×3, performDemoAction,
  randomizeOnDemoStart, renderDebugHUD, AppLogo::update)

Compilación: gcc -Wall sin warnings. clang-tidy: 0 issues.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 10:52:07 +01:00
parent 4801f287df
commit c9bcce6f9b
71 changed files with 3469 additions and 2838 deletions

View File

@@ -1,32 +1,32 @@
#pragma once
#include <SDL3/SDL_events.h> // for SDL_Event
#include <SDL3/SDL_render.h> // for SDL_Renderer (ui_renderer_ software renderer)
#include <SDL3/SDL_stdinc.h> // for Uint64
#include <SDL3/SDL_surface.h> // for SDL_Surface (ui_surface_)
#include <SDL3/SDL_video.h> // for SDL_Window
#include <SDL3/SDL_events.h> // for SDL_Event
#include <SDL3/SDL_render.h> // for SDL_Renderer (ui_renderer_ software renderer)
#include <SDL3/SDL_stdinc.h> // for Uint64
#include <SDL3/SDL_surface.h> // for SDL_Surface (ui_surface_)
#include <SDL3/SDL_video.h> // for SDL_Window
#include <array> // for array
#include <memory> // for unique_ptr, shared_ptr
#include <string> // for string
#include <vector> // for vector
#include "ui/app_logo.hpp" // for AppLogo
#include "ball.hpp" // for Ball
#include "boids_mgr/boid_manager.hpp" // for BoidManager
#include "defines.hpp" // for GravityDirection, ColorTheme, ShapeType
#include "external/texture.hpp" // for Texture
#include "gpu/gpu_ball_buffer.hpp" // for GpuBallBuffer, BallGPUData
#include "gpu/gpu_context.hpp" // for GpuContext
#include "gpu/gpu_pipeline.hpp" // for GpuPipeline
#include "gpu/gpu_sprite_batch.hpp" // for GpuSpriteBatch
#include "gpu/gpu_texture.hpp" // for GpuTexture
#include "input/input_handler.hpp" // for InputHandler
#include "scene/scene_manager.hpp" // for SceneManager
#include "shapes_mgr/shape_manager.hpp" // for ShapeManager
#include "state/state_manager.hpp" // for StateManager
#include "theme_manager.hpp" // for ThemeManager
#include "ui/ui_manager.hpp" // for UIManager
#include "ball.hpp" // for Ball
#include "boids_mgr/boid_manager.hpp" // for BoidManager
#include "defines.hpp" // for GravityDirection, ColorTheme, ShapeType
#include "external/texture.hpp" // for Texture
#include "gpu/gpu_ball_buffer.hpp" // for GpuBallBuffer, BallGPUData
#include "gpu/gpu_context.hpp" // for GpuContext
#include "gpu/gpu_pipeline.hpp" // for GpuPipeline
#include "gpu/gpu_sprite_batch.hpp" // for GpuSpriteBatch
#include "gpu/gpu_texture.hpp" // for GpuTexture
#include "input/input_handler.hpp" // for InputHandler
#include "scene/scene_manager.hpp" // for SceneManager
#include "shapes_mgr/shape_manager.hpp" // for ShapeManager
#include "state/state_manager.hpp" // for StateManager
#include "theme_manager.hpp" // for ThemeManager
#include "ui/app_logo.hpp" // for AppLogo
#include "ui/ui_manager.hpp" // for UIManager
class Engine {
public:
@@ -97,8 +97,8 @@ class Engine {
// Escenario custom (tecla 9, --custom-balls)
void setCustomScenario(int balls);
bool isCustomScenarioEnabled() const { return custom_scenario_enabled_; }
bool isCustomAutoAvailable() const { return custom_auto_available_; }
int getCustomScenarioBalls() const { return custom_scenario_balls_; }
bool isCustomAutoAvailable() const { return custom_auto_available_; }
int getCustomScenarioBalls() const { return custom_scenario_balls_; }
// Control manual del benchmark (--skip-benchmark, --max-balls)
void setSkipBenchmark();
@@ -113,10 +113,10 @@ class Engine {
void toggleLogoMode();
// === Métodos públicos para StateManager (automatización DEMO/LOGO sin notificación) ===
void enterShapeMode(ShapeType type); // Activar figura (sin notificación)
void exitShapeMode(bool force_gravity = true); // Volver a física (sin notificación)
void switchTextureSilent(); // Cambiar textura (sin notificación)
void setTextureByIndex(size_t index); // Restaurar textura específica
void enterShapeMode(ShapeType type); // Activar figura (sin notificación)
void exitShapeMode(bool force_gravity = true); // Volver a física (sin notificación)
void switchTextureSilent(); // Cambiar textura (sin notificación)
void setTextureByIndex(size_t index); // Restaurar textura específica
// === Getters públicos para UIManager (Debug HUD) ===
bool getVSyncEnabled() const { return vsync_enabled_; }
@@ -133,11 +133,11 @@ class Engine {
int getBaseScreenHeight() const { return base_screen_height_; }
int getMaxAutoScenario() const { return max_auto_scenario_; }
size_t getCurrentTextureIndex() const { return current_texture_index_; }
bool isPostFXEnabled() const { return postfx_enabled_; }
int getPostFXMode() const { return postfx_effect_mode_; }
float getPostFXVignette() const { return postfx_uniforms_.vignette_strength; }
float getPostFXChroma() const { return postfx_uniforms_.chroma_strength; }
float getPostFXScanline() const { return postfx_uniforms_.scanline_strength; }
bool isPostFXEnabled() const { return postfx_enabled_; }
int getPostFXMode() const { return postfx_effect_mode_; }
float getPostFXVignette() const { return postfx_uniforms_.vignette_strength; }
float getPostFXChroma() const { return postfx_uniforms_.chroma_strength; }
float getPostFXScanline() const { return postfx_uniforms_.scanline_strength; }
private:
// === Componentes del sistema (Composición) ===
@@ -153,23 +153,23 @@ class Engine {
SDL_Window* window_ = nullptr;
// === SDL_GPU rendering pipeline ===
std::unique_ptr<GpuContext> gpu_ctx_; // Device + swapchain
std::unique_ptr<GpuPipeline> gpu_pipeline_; // Sprite + ball + postfx pipelines
std::unique_ptr<GpuSpriteBatch> sprite_batch_; // Per-frame vertex/index batch (bg + shape + UI)
std::unique_ptr<GpuBallBuffer> gpu_ball_buffer_; // Instanced ball instance data (PHYSICS/BOIDS)
std::vector<BallGPUData> ball_gpu_data_; // CPU-side staging vector (reused each frame)
std::unique_ptr<GpuTexture> offscreen_tex_; // Offscreen render target (Pass 1)
std::unique_ptr<GpuTexture> white_tex_; // 1×1 white (background gradient)
std::unique_ptr<GpuTexture> ui_tex_; // UI text overlay texture
std::unique_ptr<GpuContext> gpu_ctx_; // Device + swapchain
std::unique_ptr<GpuPipeline> gpu_pipeline_; // Sprite + ball + postfx pipelines
std::unique_ptr<GpuSpriteBatch> sprite_batch_; // Per-frame vertex/index batch (bg + shape + UI)
std::unique_ptr<GpuBallBuffer> gpu_ball_buffer_; // Instanced ball instance data (PHYSICS/BOIDS)
std::vector<BallGPUData> ball_gpu_data_; // CPU-side staging vector (reused each frame)
std::unique_ptr<GpuTexture> offscreen_tex_; // Offscreen render target (Pass 1)
std::unique_ptr<GpuTexture> white_tex_; // 1×1 white (background gradient)
std::unique_ptr<GpuTexture> ui_tex_; // UI text overlay texture
// GPU sprite textures (one per ball skin, parallel to textures_/texture_names_)
std::unique_ptr<GpuTexture> gpu_texture_; // Active GPU sprite texture
std::unique_ptr<GpuTexture> gpu_texture_; // Active GPU sprite texture
std::vector<std::unique_ptr<GpuTexture>> gpu_textures_; // All GPU sprite textures
// === SDL_Renderer (software, for UI text via SDL3_ttf) ===
// Renders to ui_surface_, then uploaded as gpu texture overlay.
SDL_Renderer* ui_renderer_ = nullptr;
SDL_Surface* ui_surface_ = nullptr;
SDL_Surface* ui_surface_ = nullptr;
// Legacy Texture objects — kept for ball physics sizing and AppLogo
std::shared_ptr<Texture> texture_ = nullptr; // Textura activa actual
@@ -190,7 +190,7 @@ class Engine {
int postfx_effect_mode_ = 3;
bool postfx_enabled_ = false;
float postfx_override_vignette_ = -1.f; // -1 = sin override
float postfx_override_chroma_ = -1.f;
float postfx_override_chroma_ = -1.f;
// Sistema de escala de ventana
float current_window_scale_ = 1.0f;
@@ -228,10 +228,10 @@ class Engine {
int max_auto_scenario_ = 5;
// Escenario custom (--custom-balls)
int custom_scenario_balls_ = 0;
int custom_scenario_balls_ = 0;
bool custom_scenario_enabled_ = false;
bool custom_auto_available_ = false;
bool skip_benchmark_ = false;
bool custom_auto_available_ = false;
bool skip_benchmark_ = false;
// Bucket sort per z-ordering (SHAPE mode)
static constexpr int DEPTH_SORT_BUCKETS = 256;
@@ -273,9 +273,8 @@ class Engine {
bool isScenarioAllowedForBoids(int scenario_id) const;
// GPU helpers
bool loadGpuSpriteTexture(size_t index); // Upload one sprite texture to GPU
void recreateOffscreenTexture(); // Recreate when resolution changes
void renderUIToSurface(); // Render text/UI to ui_surface_
bool loadGpuSpriteTexture(size_t index); // Upload one sprite texture to GPU
void recreateOffscreenTexture(); // Recreate when resolution changes
void renderUIToSurface(); // Render text/UI to ui_surface_
void uploadUISurface(SDL_GPUCommandBuffer* cmd_buf); // Upload ui_surface_ → ui_tex_
};