style: aplicar readability-math-missing-parentheses
- Agregar paréntesis explícitos en operaciones matemáticas para claridad
- Ejemplos: '1.0F - a * b' → '1.0F - (a * b)'
- 291 correcciones aplicadas automáticamente con clang-tidy
- Check 2/N completado
🤖 Generated with Claude Code
This commit is contained in:
@@ -28,8 +28,8 @@ static Punt transform_point(const Punt& point, const Punt& shape_centre, const P
|
||||
float cos_a = std::cos(angle);
|
||||
float sin_a = std::sin(angle);
|
||||
|
||||
float rotated_x = scaled_x * cos_a - scaled_y * sin_a;
|
||||
float rotated_y = scaled_x * sin_a + scaled_y * cos_a;
|
||||
float rotated_x = (scaled_x * cos_a) - (scaled_y * sin_a);
|
||||
float rotated_y = (scaled_x * sin_a) + (scaled_y * cos_a);
|
||||
|
||||
// 4. Aplicar trasllació a posició mundial
|
||||
return {rotated_x + posicio.x, rotated_y + posicio.y};
|
||||
@@ -105,12 +105,12 @@ void DebrisManager::explotar(const std::shared_ptr<Graphics::Shape>& shape,
|
||||
// 5. Velocitat inicial (base ± variació aleatòria + velocitat heretada)
|
||||
float speed =
|
||||
velocitat_base +
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) * 2.0F - 1.0F) *
|
||||
Defaults::Physics::Debris::VARIACIO_VELOCITAT;
|
||||
(((std::rand() / static_cast<float>(RAND_MAX)) * 2.0F - 1.0F) *
|
||||
Defaults::Physics::Debris::VARIACIO_VELOCITAT);
|
||||
|
||||
// Heredar velocitat de l'objecte original (suma vectorial)
|
||||
debris->velocitat.x = direccio.x * speed + velocitat_objecte.x;
|
||||
debris->velocitat.y = direccio.y * speed + velocitat_objecte.y;
|
||||
debris->velocitat.x = (direccio.x * speed) + velocitat_objecte.x;
|
||||
debris->velocitat.y = (direccio.y * speed) + velocitat_objecte.y;
|
||||
debris->acceleracio = Defaults::Physics::Debris::ACCELERACIO;
|
||||
|
||||
// 6. Herència de velocitat angular amb cap + conversió d'excés
|
||||
@@ -120,14 +120,14 @@ void DebrisManager::explotar(const std::shared_ptr<Graphics::Shape>& shape,
|
||||
// FASE 1: Aplicar herència i variació (igual que abans)
|
||||
float factor_herencia =
|
||||
Defaults::Physics::Debris::FACTOR_HERENCIA_MIN +
|
||||
(std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
(Defaults::Physics::Debris::FACTOR_HERENCIA_MAX -
|
||||
Defaults::Physics::Debris::FACTOR_HERENCIA_MIN);
|
||||
Defaults::Physics::Debris::FACTOR_HERENCIA_MIN));
|
||||
|
||||
float velocitat_ang_heretada = velocitat_angular * factor_herencia;
|
||||
|
||||
float variacio =
|
||||
(std::rand() / static_cast<float>(RAND_MAX)) * 0.2F - 0.1F;
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) * 0.2F) - 0.1F;
|
||||
velocitat_ang_heretada *= (1.0F + variacio);
|
||||
|
||||
// FASE 2: Aplicar cap i calcular excés
|
||||
@@ -171,15 +171,15 @@ void DebrisManager::explotar(const std::shared_ptr<Graphics::Shape>& shape,
|
||||
|
||||
// Variació aleatòria petita (±5%) per naturalitat
|
||||
float variacio_visual =
|
||||
(std::rand() / static_cast<float>(RAND_MAX)) * 0.1F - 0.05F;
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) * 0.1F) - 0.05F;
|
||||
debris->velocitat_rot_visual *= (1.0F + variacio_visual);
|
||||
} else {
|
||||
// Rotació visual aleatòria (factor = 0.0 o sin velocidad angular)
|
||||
debris->velocitat_rot_visual =
|
||||
Defaults::Physics::Debris::ROTACIO_MIN +
|
||||
(std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
((std::rand() / static_cast<float>(RAND_MAX)) *
|
||||
(Defaults::Physics::Debris::ROTACIO_MAX -
|
||||
Defaults::Physics::Debris::ROTACIO_MIN);
|
||||
Defaults::Physics::Debris::ROTACIO_MIN));
|
||||
|
||||
// 50% probabilitat de rotació en sentit contrari
|
||||
if (std::rand() % 2 == 0) {
|
||||
@@ -219,8 +219,8 @@ void DebrisManager::actualitzar(float delta_time) {
|
||||
|
||||
// 2. Actualitzar velocitat (desacceleració)
|
||||
// Aplicar fricció en la direcció del moviment
|
||||
float speed = std::sqrt(debris.velocitat.x * debris.velocitat.x +
|
||||
debris.velocitat.y * debris.velocitat.y);
|
||||
float speed = std::sqrt((debris.velocitat.x * debris.velocitat.x) +
|
||||
(debris.velocitat.y * debris.velocitat.y));
|
||||
|
||||
if (speed > 1.0F) {
|
||||
// Calcular direcció normalitzada
|
||||
@@ -228,7 +228,7 @@ void DebrisManager::actualitzar(float delta_time) {
|
||||
float dir_y = debris.velocitat.y / speed;
|
||||
|
||||
// Aplicar acceleració negativa (fricció)
|
||||
float nova_speed = speed + debris.acceleracio * delta_time;
|
||||
float nova_speed = speed + (debris.acceleracio * delta_time);
|
||||
if (nova_speed < 0.0F)
|
||||
nova_speed = 0.0F;
|
||||
|
||||
@@ -252,8 +252,8 @@ void DebrisManager::actualitzar(float delta_time) {
|
||||
float cos_a = std::cos(dangle);
|
||||
float sin_a = std::sin(dangle);
|
||||
|
||||
debris.velocitat.x = vel_x_old * cos_a - vel_y_old * sin_a;
|
||||
debris.velocitat.y = vel_x_old * sin_a + vel_y_old * cos_a;
|
||||
debris.velocitat.x = (vel_x_old * cos_a) - (vel_y_old * sin_a);
|
||||
debris.velocitat.y = (vel_x_old * sin_a) + (vel_y_old * cos_a);
|
||||
}
|
||||
|
||||
// 2c. Aplicar fricció angular (desacceleració gradual)
|
||||
@@ -290,14 +290,14 @@ void DebrisManager::actualitzar(float delta_time) {
|
||||
float dy = debris.p2.y - debris.p1.y;
|
||||
|
||||
// 7. Reconstruir segment amb nova mida i rotació
|
||||
float half_length = std::sqrt(dx * dx + dy * dy) * shrink_factor / 2.0F;
|
||||
float half_length = std::sqrt((dx * dx) + (dy * dy)) * shrink_factor / 2.0F;
|
||||
float original_angle = std::atan2(dy, dx);
|
||||
float new_angle = original_angle + debris.angle_rotacio;
|
||||
|
||||
debris.p1.x = centre.x - half_length * std::cos(new_angle);
|
||||
debris.p1.y = centre.y - half_length * std::sin(new_angle);
|
||||
debris.p2.x = centre.x + half_length * std::cos(new_angle);
|
||||
debris.p2.y = centre.y + half_length * std::sin(new_angle);
|
||||
debris.p1.x = centre.x - (half_length * std::cos(new_angle));
|
||||
debris.p1.y = centre.y - (half_length * std::sin(new_angle));
|
||||
debris.p2.x = centre.x + (half_length * std::cos(new_angle));
|
||||
debris.p2.y = centre.y + (half_length * std::sin(new_angle));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1,
|
||||
float dy = centro_seg_y - centre_objecte.y;
|
||||
|
||||
// 3. Normalitzar (obtenir vector unitari)
|
||||
float length = std::sqrt(dx * dx + dy * dy);
|
||||
float length = std::sqrt((dx * dx) + (dy * dy));
|
||||
if (length < 0.001F) {
|
||||
// Segment al centre (cas extrem molt improbable), retornar direcció aleatòria
|
||||
float angle_rand =
|
||||
@@ -357,8 +357,8 @@ Punt DebrisManager::calcular_direccio_explosio(const Punt& p1,
|
||||
float cos_v = std::cos(angle_variacio);
|
||||
float sin_v = std::sin(angle_variacio);
|
||||
|
||||
float final_x = dx * cos_v - dy * sin_v;
|
||||
float final_y = dx * sin_v + dy * cos_v;
|
||||
float final_x = (dx * cos_v) - (dy * sin_v);
|
||||
float final_y = (dx * sin_v) + (dy * cos_v);
|
||||
|
||||
return {final_x, final_y};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user