Lint: clang-tidy --fix mecánico (trailing return, default member init, auto, enum size)
Pase automático de clang-tidy --fix sobre el conjunto de checks que son puro transform de sintaxis y no rompen API. Invocado con --format-style=none para que clang-tidy NO arrastre clang-format sobre las líneas tocadas (evita la regla NamespaceIndentation: All del .clang-format reformateando solo trozos del archivo). Checks aplicados: - modernize-use-trailing-return-type (193 hits): 'int foo()' → 'auto foo() -> int'. Estilo coherente con la convención del proyecto. - modernize-use-default-member-init (36 hits): inicialización de miembros pasa de la lista del constructor a la declaración. Reduce duplicación cuando hay varios constructores con los mismos defaults. - modernize-use-auto (6 hits): tipos largos sustituidos por auto donde el tipo es evidente del contexto (new T, dynamic_cast, etc). - modernize-use-starts-ends-with (2 hits): s.rfind(x) == 0 → s.starts_with(x), aprovechando C++20. - performance-enum-size (10 hits): enums pequeños declaran tipo subyacente (uint8_t / similar) para reducir tamaño y precisar layout. NO aplicado en este pase (riesgo de cambios semánticos o de API): - readability-identifier-naming (renames pueden romper callsites parciales) - readability-convert-member-functions-to-static (cambia firma) - readability-use-anyofallof (reescribe loops, side effects) - readability-function-cognitive-complexity (requiere refactor manual) - bugs reales (bugprone-*, clang-diagnostic-*) → uno a uno Cambios manuales asociados: - SDLManager::clear() ahora devuelve bool: propaga el resultado de beginFrame al caller para que Director::runFrameLoop salte draw+present cuando la swapchain no esté disponible (ventana minimizada). Antes la función ignoraba el [[nodiscard]] del beginFrame y los vértices se acumulaban en el batch sin nadie que los consumiera. - vector_text.cpp: borrada la línea suelta "// Test pre-commit hook" que quedó como cruft. clang-tidy crashea en LLVM 19.1 con performance-noexcept-move-constructor (recursión infinita en ExceptionSpecAnalyzer al procesar std::set); check deshabilitado en .clang-tidy con comentario explicativo. Build limpio, smoke test OK. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,20 +11,20 @@ namespace Rendering {
|
||||
extern float g_current_scale_factor;
|
||||
|
||||
// Transforma coordenada lógica a física con arrodoniment
|
||||
inline int transform_x(int logical_x, float scale) {
|
||||
inline auto transform_x(int logical_x, float scale) -> int {
|
||||
return static_cast<int>(std::round(logical_x * scale));
|
||||
}
|
||||
|
||||
inline int transform_y(int logical_y, float scale) {
|
||||
inline auto transform_y(int logical_y, float scale) -> int {
|
||||
return static_cast<int>(std::round(logical_y * scale));
|
||||
}
|
||||
|
||||
// Variant que usa el factor de scale global
|
||||
inline int transform_x(int logical_x) {
|
||||
inline auto transform_x(int logical_x) -> int {
|
||||
return transform_x(logical_x, g_current_scale_factor);
|
||||
}
|
||||
|
||||
inline int transform_y(int logical_y) {
|
||||
inline auto transform_y(int logical_y) -> int {
|
||||
return transform_y(logical_y, g_current_scale_factor);
|
||||
}
|
||||
|
||||
|
||||
@@ -239,8 +239,8 @@ void GpuFrameRenderer::flushBatch() {
|
||||
|
||||
SDL_GPUDevice* dev = device_.get();
|
||||
|
||||
const uint32_t VBO_SIZE = static_cast<uint32_t>(vertices_.size() * sizeof(LineVertex));
|
||||
const uint32_t IBO_SIZE = static_cast<uint32_t>(indices_.size() * sizeof(uint16_t));
|
||||
const auto VBO_SIZE = static_cast<uint32_t>(vertices_.size() * sizeof(LineVertex));
|
||||
const auto IBO_SIZE = static_cast<uint32_t>(indices_.size() * sizeof(uint16_t));
|
||||
|
||||
SDL_GPUBufferCreateInfo vbo_info{};
|
||||
vbo_info.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
|
||||
|
||||
@@ -25,10 +25,10 @@ void linea(Renderer* renderer,
|
||||
|
||||
// Coords lógicas (1280×720). El shader hace el mapeo a NDC; el viewport
|
||||
// del SDLManager hace el letterbox a píxeles físicos.
|
||||
const float FX1 = static_cast<float>(x1);
|
||||
const float FY1 = static_cast<float>(y1);
|
||||
const float FX2 = static_cast<float>(x2);
|
||||
const float FY2 = static_cast<float>(y2);
|
||||
const auto FX1 = static_cast<float>(x1);
|
||||
const auto FY1 = static_cast<float>(y1);
|
||||
const auto FX2 = static_cast<float>(x2);
|
||||
const auto FY2 = static_cast<float>(y2);
|
||||
|
||||
// color.alpha==0 → usar color global (verde fósforo). alpha>0 → color directo.
|
||||
const SDL_Color SOURCE = (color.a > 0) ? color : g_current_line_color;
|
||||
|
||||
@@ -316,14 +316,18 @@ auto SDLManager::handleWindowEvent(const SDL_Event& event) -> bool {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) {
|
||||
auto SDLManager::clear(uint8_t r, uint8_t g, uint8_t b) -> bool {
|
||||
// El fondo lo dibuja ahora el shader de postpro (background pulse). El
|
||||
// offscreen se limpia en negro dentro de beginFrame. Los argumentos r/g/b
|
||||
// se mantienen por compatibilidad de API.
|
||||
(void)r;
|
||||
(void)g;
|
||||
(void)b;
|
||||
gpu_renderer_.beginFrame(0.0F, 0.0F, 0.0F);
|
||||
// beginFrame devuelve false si la swapchain no está disponible (ventana
|
||||
// minimizada, por ejemplo). Propagamos el bool al caller para que pueda
|
||||
// saltarse draw+present ese frame; si no, los vértices se acumulan en
|
||||
// el batch interno sin que nadie los consuma.
|
||||
return gpu_renderer_.beginFrame(0.0F, 0.0F, 0.0F);
|
||||
}
|
||||
|
||||
void SDLManager::present() {
|
||||
|
||||
@@ -31,8 +31,10 @@ class SDLManager {
|
||||
void toggleVSync(); // F4
|
||||
auto handleWindowEvent(const SDL_Event& event) -> bool; // Per a SDL_EVENT_WINDOW_RESIZED
|
||||
|
||||
// Funciones principals (renderizado)
|
||||
void clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0);
|
||||
// Funciones principals (renderizado).
|
||||
// clear() devuelve false si la swapchain no está disponible (p.ej.
|
||||
// ventana minimizada). El caller debe saltarse draw+present ese frame.
|
||||
[[nodiscard]] auto clear(uint8_t r = 0, uint8_t g = 0, uint8_t b = 0) -> bool;
|
||||
void present();
|
||||
|
||||
// Getters
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace Rendering {
|
||||
|
||||
// Helper: aplicar rotación 3D a un point 2D (assumeix Z=0)
|
||||
static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
static auto apply_3d_rotation(float x, float y, const Rotation3D& rot) -> Vec2 {
|
||||
float z = 0.0F; // Todos los points 2D comencen a Z=0
|
||||
|
||||
// Pitch (rotación eix X): cabeceo arriba/baix
|
||||
@@ -42,7 +42,7 @@ static Vec2 apply_3d_rotation(float x, float y, const Rotation3D& rot) {
|
||||
}
|
||||
|
||||
// Helper: transformar un point con rotación, scale i traslación
|
||||
static Vec2 transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale, const Rotation3D* rotation_3d) {
|
||||
static auto transform_point(const Vec2& point, const Vec2& shape_centre, const Vec2& position, float angle, float scale, const Rotation3D* rotation_3d) -> Vec2 {
|
||||
// 1. Centrar el point respecte al centro de la shape
|
||||
float centered_x = point.x - shape_centre.x;
|
||||
float centered_y = point.y - shape_centre.y;
|
||||
|
||||
@@ -29,7 +29,7 @@ struct Rotation3D {
|
||||
yaw(y),
|
||||
roll(r) {}
|
||||
|
||||
[[nodiscard]] bool has_rotation() const {
|
||||
[[nodiscard]] auto has_rotation() const -> bool {
|
||||
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user