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:
@@ -1,24 +1,25 @@
|
||||
#include "scene_manager.hpp"
|
||||
|
||||
#include <cstdlib> // for rand
|
||||
#include <utility>
|
||||
|
||||
#include "defines.hpp" // for BALL_COUNT_SCENARIOS, GRAVITY_MASS_MIN, etc
|
||||
#include "external/texture.hpp" // for Texture
|
||||
#include "theme_manager.hpp" // for ThemeManager
|
||||
#include "defines.hpp" // for BALL_COUNT_SCENARIOS, GRAVITY_MASS_MIN, etc
|
||||
#include "external/texture.hpp" // for Texture
|
||||
#include "theme_manager.hpp" // for ThemeManager
|
||||
|
||||
SceneManager::SceneManager(int screen_width, int screen_height)
|
||||
: current_gravity_(GravityDirection::DOWN)
|
||||
, scenario_(0)
|
||||
, screen_width_(screen_width)
|
||||
, screen_height_(screen_height)
|
||||
, current_ball_size_(10)
|
||||
, texture_(nullptr)
|
||||
, theme_manager_(nullptr) {
|
||||
: current_gravity_(GravityDirection::DOWN),
|
||||
scenario_(0),
|
||||
screen_width_(screen_width),
|
||||
screen_height_(screen_height),
|
||||
current_ball_size_(10),
|
||||
texture_(nullptr),
|
||||
theme_manager_(nullptr) {
|
||||
}
|
||||
|
||||
void SceneManager::initialize(int scenario, std::shared_ptr<Texture> texture, ThemeManager* theme_manager) {
|
||||
scenario_ = scenario;
|
||||
texture_ = texture;
|
||||
texture_ = std::move(texture);
|
||||
theme_manager_ = theme_manager;
|
||||
current_ball_size_ = texture_->getWidth();
|
||||
|
||||
@@ -48,28 +49,31 @@ void SceneManager::changeScenario(int scenario_id, SimulationMode mode) {
|
||||
? custom_ball_count_
|
||||
: BALL_COUNT_SCENARIOS[scenario_id];
|
||||
for (int i = 0; i < ball_count; ++i) {
|
||||
float X, Y, VX, VY;
|
||||
float x;
|
||||
float y;
|
||||
float vx;
|
||||
float vy;
|
||||
|
||||
// Inicialización según SimulationMode (RULES.md líneas 23-26)
|
||||
switch (mode) {
|
||||
case SimulationMode::PHYSICS: {
|
||||
// PHYSICS: Parte superior, 75% distribución central en X
|
||||
const int SIGN = ((rand() % 2) * 2) - 1;
|
||||
const int margin = static_cast<int>(screen_width_ * BALL_SPAWN_MARGIN);
|
||||
const int spawn_zone_width = screen_width_ - (2 * margin);
|
||||
X = (rand() % spawn_zone_width) + margin;
|
||||
Y = 0.0f; // Parte superior
|
||||
VX = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
VY = ((rand() % 60) - 30) * 0.1f;
|
||||
const int MARGIN = static_cast<int>(screen_width_ * BALL_SPAWN_MARGIN);
|
||||
const int SPAWN_ZONE_WIDTH = screen_width_ - (2 * MARGIN);
|
||||
x = (rand() % SPAWN_ZONE_WIDTH) + MARGIN;
|
||||
y = 0.0f; // Parte superior
|
||||
vx = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
vy = ((rand() % 60) - 30) * 0.1f;
|
||||
break;
|
||||
}
|
||||
|
||||
case SimulationMode::SHAPE: {
|
||||
// SHAPE: Centro de pantalla, sin velocidad inicial
|
||||
X = screen_width_ / 2.0f;
|
||||
Y = screen_height_ / 2.0f; // Centro vertical
|
||||
VX = 0.0f;
|
||||
VY = 0.0f;
|
||||
x = screen_width_ / 2.0f;
|
||||
y = screen_height_ / 2.0f; // Centro vertical
|
||||
vx = 0.0f;
|
||||
vy = 0.0f;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -77,48 +81,57 @@ void SceneManager::changeScenario(int scenario_id, SimulationMode mode) {
|
||||
// BOIDS: Posiciones aleatorias, velocidades aleatorias
|
||||
const int SIGN_X = ((rand() % 2) * 2) - 1;
|
||||
const int SIGN_Y = ((rand() % 2) * 2) - 1;
|
||||
X = static_cast<float>(rand() % screen_width_);
|
||||
Y = static_cast<float>(rand() % screen_height_); // Posición Y aleatoria
|
||||
VX = (((rand() % 40) + 10) * 0.1f) * SIGN_X; // 1.0 - 5.0 px/frame
|
||||
VY = (((rand() % 40) + 10) * 0.1f) * SIGN_Y;
|
||||
x = static_cast<float>(rand() % screen_width_);
|
||||
y = static_cast<float>(rand() % screen_height_); // Posición Y aleatoria
|
||||
vx = (((rand() % 40) + 10) * 0.1f) * SIGN_X; // 1.0 - 5.0 px/frame
|
||||
vy = (((rand() % 40) + 10) * 0.1f) * SIGN_Y;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Fallback a PHYSICS por seguridad
|
||||
const int SIGN = ((rand() % 2) * 2) - 1;
|
||||
const int margin = static_cast<int>(screen_width_ * BALL_SPAWN_MARGIN);
|
||||
const int spawn_zone_width = screen_width_ - (2 * margin);
|
||||
X = (rand() % spawn_zone_width) + margin;
|
||||
Y = 0.0f; // Parte superior
|
||||
VX = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
VY = ((rand() % 60) - 30) * 0.1f;
|
||||
const int MARGIN = static_cast<int>(screen_width_ * BALL_SPAWN_MARGIN);
|
||||
const int SPAWN_ZONE_WIDTH = screen_width_ - (2 * MARGIN);
|
||||
x = (rand() % SPAWN_ZONE_WIDTH) + MARGIN;
|
||||
y = 0.0f; // Parte superior
|
||||
vx = (((rand() % 20) + 10) * 0.1f) * SIGN;
|
||||
vy = ((rand() % 60) - 30) * 0.1f;
|
||||
break;
|
||||
}
|
||||
|
||||
// Seleccionar color de la paleta del tema actual (delegado a ThemeManager)
|
||||
int random_index = rand();
|
||||
Color COLOR = theme_manager_->getInitialBallColor(random_index);
|
||||
Color color = theme_manager_->getInitialBallColor(random_index);
|
||||
|
||||
// Generar factor de masa aleatorio (0.7 = ligera, 1.3 = pesada)
|
||||
float mass_factor = GRAVITY_MASS_MIN + (rand() % 1000) / 1000.0f * (GRAVITY_MASS_MAX - GRAVITY_MASS_MIN);
|
||||
float mass_factor = GRAVITY_MASS_MIN + ((rand() % 1000) / 1000.0f * (GRAVITY_MASS_MAX - GRAVITY_MASS_MIN));
|
||||
|
||||
balls_.emplace_back(std::make_unique<Ball>(
|
||||
X, Y, VX, VY, COLOR, texture_,
|
||||
screen_width_, screen_height_, current_ball_size_,
|
||||
current_gravity_, mass_factor
|
||||
));
|
||||
x,
|
||||
y,
|
||||
vx,
|
||||
vy,
|
||||
color,
|
||||
texture_,
|
||||
screen_width_,
|
||||
screen_height_,
|
||||
current_ball_size_,
|
||||
current_gravity_,
|
||||
mass_factor));
|
||||
}
|
||||
}
|
||||
|
||||
void SceneManager::updateBallTexture(std::shared_ptr<Texture> new_texture, int new_ball_size) {
|
||||
if (balls_.empty()) return;
|
||||
if (balls_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Guardar tamaño antiguo
|
||||
int old_size = current_ball_size_;
|
||||
|
||||
// Actualizar textura y tamaño
|
||||
texture_ = new_texture;
|
||||
texture_ = std::move(new_texture);
|
||||
current_ball_size_ = new_ball_size;
|
||||
|
||||
// Actualizar texturas de todas las pelotas
|
||||
@@ -136,7 +149,8 @@ void SceneManager::pushBallsAwayFromGravity() {
|
||||
const float LATERAL = (((rand() % 20) + 10) * 0.1f) * SIGNO;
|
||||
const float MAIN = ((rand() % 40) * 0.1f) + 5;
|
||||
|
||||
float vx = 0, vy = 0;
|
||||
float vx = 0;
|
||||
float vy = 0;
|
||||
switch (current_gravity_) {
|
||||
case GravityDirection::DOWN: // Impulsar ARRIBA
|
||||
vx = LATERAL;
|
||||
|
||||
Reference in New Issue
Block a user