style: aplicar checks modernize-* (215 fixes)

Cambios aplicados:
- [[nodiscard]] añadido a funciones que retornan valores
- .starts_with() en lugar de .find() == 0
- Inicializadores designados {.x=0, .y=0}
- auto en castings obvios
- = default para constructores triviales
- Funciones deleted movidas a public
- std::numbers::pi_v<float> (C++20)

Checks excluidos:
- use-trailing-return-type: Estilo controversial
- avoid-c-arrays: Arrays C aceptables en ciertos contextos
This commit is contained in:
2025-12-18 20:16:46 +01:00
parent fdfb84170f
commit 7f6af6dd00
42 changed files with 178 additions and 178 deletions

View File

@@ -12,14 +12,14 @@ namespace Rendering {
ColorOscillator::ColorOscillator()
: accumulated_time_(0.0F) {
// Inicialitzar amb el color mínim
current_line_color_ = {Defaults::Color::LINE_MIN_R,
Defaults::Color::LINE_MIN_G,
Defaults::Color::LINE_MIN_B,
255};
current_background_color_ = {Defaults::Color::BACKGROUND_MIN_R,
Defaults::Color::BACKGROUND_MIN_G,
Defaults::Color::BACKGROUND_MIN_B,
255};
current_line_color_ = {.r = Defaults::Color::LINE_MIN_R,
.g = Defaults::Color::LINE_MIN_G,
.b = Defaults::Color::LINE_MIN_B,
.a = 255};
current_background_color_ = {.r = Defaults::Color::BACKGROUND_MIN_R,
.g = Defaults::Color::BACKGROUND_MIN_G,
.b = Defaults::Color::BACKGROUND_MIN_B,
.a = 255};
}
void ColorOscillator::update(float delta_time) {

View File

@@ -12,8 +12,8 @@ class ColorOscillator {
void update(float delta_time);
SDL_Color getCurrentLineColor() const { return current_line_color_; }
SDL_Color getCurrentBackgroundColor() const {
[[nodiscard]] SDL_Color getCurrentLineColor() const { return current_line_color_; }
[[nodiscard]] SDL_Color getCurrentBackgroundColor() const {
return current_background_color_;
}

View File

@@ -40,7 +40,7 @@ class SDLManager {
// Getters
SDL_Renderer* obte_renderer() { return renderer_; }
float getScaleFactor() const { return zoom_factor_; }
[[nodiscard]] float getScaleFactor() const { return zoom_factor_; }
// [NUEVO] Actualitzar títol de la finestra
void setWindowTitle(const std::string& title);

View File

@@ -38,7 +38,7 @@ static Punt apply_3d_rotation(float x, float y, const Rotation3D& rot) {
constexpr float perspective_factor = 500.0F;
float scale_factor = perspective_factor / (perspective_factor + z2);
return {x3 * scale_factor, y3 * scale_factor};
return {.x = x3 * scale_factor, .y = y3 * scale_factor};
}
// Helper: transformar un punt amb rotació, escala i trasllació
@@ -69,7 +69,7 @@ static Punt transform_point(const Punt& point, const Punt& shape_centre, const P
float rotated_y = (scaled_x * sin_a) + (scaled_y * cos_a);
// 5. Aplicar trasllació a posició mundial
return {rotated_x + posicio.x, rotated_y + posicio.y};
return {.x = rotated_x + posicio.x, .y = rotated_y + posicio.y};
}
void render_shape(SDL_Renderer* renderer,

View File

@@ -27,7 +27,7 @@ struct Rotation3D {
yaw(y),
roll(r) {}
bool has_rotation() const {
[[nodiscard]] bool has_rotation() const {
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
}
};