From 9ae851d5b657ecf7431b0fa01a3874fc30e6fc13 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Sat, 21 Mar 2026 01:13:17 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20limitar=20modo=20BOIDS=20a=20escenarios?= =?UTF-8?q?=20con=20=E2=89=A41.000=20bolas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pulsar B en escenarios 6-8 (o custom >1K) no activa boids y muestra notificación. Cambiar de escenario estando en BOIDS queda bloqueado si el destino supera BOIDS_MAX_BALLS (= SCENE_BALLS_5). Co-Authored-By: Claude Sonnet 4.6 --- source/defines.hpp | 2 ++ source/engine.cpp | 20 ++++++++++++++++++++ source/engine.hpp | 3 +++ 3 files changed, 25 insertions(+) diff --git a/source/defines.hpp b/source/defines.hpp index e5b0e53..ed0e6af 100644 --- a/source/defines.hpp +++ b/source/defines.hpp @@ -74,6 +74,8 @@ constexpr int BALL_COUNT_SCENARIOS[SCENARIO_COUNT] = { SCENE_BALLS_5, SCENE_BALLS_6, SCENE_BALLS_7, SCENE_BALLS_8 }; +constexpr int BOIDS_MAX_BALLS = SCENE_BALLS_5; // 1 000 bolas máximo en modo BOIDS + // Límites de escenario para modos automáticos (índices en BALL_COUNT_SCENARIOS) // 0 1 2 3 4 5 6 7 constexpr int DEMO_AUTO_MIN_SCENARIO = 2; // mínimo 100 bolas diff --git a/source/engine.cpp b/source/engine.cpp index 663a533..5f75df1 100644 --- a/source/engine.cpp +++ b/source/engine.cpp @@ -564,7 +564,21 @@ void Engine::toggleDepthZoom() { } // Boids (comportamiento de enjambre) +bool Engine::isScenarioAllowedForBoids(int scenario_id) const { + int ball_count = (scenario_id == CUSTOM_SCENARIO_IDX) + ? custom_scenario_balls_ + : BALL_COUNT_SCENARIOS[scenario_id]; + return ball_count <= BOIDS_MAX_BALLS; +} + void Engine::toggleBoidsMode(bool force_gravity_on) { + if (current_mode_ != SimulationMode::BOIDS) { + // Intentando activar BOIDS — verificar escenario actual + if (!isScenarioAllowedForBoids(scene_manager_->getCurrentScenario())) { + showNotificationForAction("Boids: máximo 1.000 pelotas"); + return; + } + } if (current_mode_ == SimulationMode::BOIDS) { // Salir del modo boids current_mode_ = SimulationMode::PHYSICS; @@ -654,6 +668,12 @@ void Engine::setCustomScenario(int balls) { // Escenarios (número de pelotas) void Engine::changeScenario(int scenario_id, const char* notification_text) { + if (current_mode_ == SimulationMode::BOIDS) { + if (!isScenarioAllowedForBoids(scenario_id)) { + showNotificationForAction("Boids: máximo 1.000 pelotas"); + return; + } + } // Pasar el modo actual al SceneManager para inicialización correcta scene_manager_->changeScenario(scenario_id, current_mode_); diff --git a/source/engine.hpp b/source/engine.hpp index 8b90e45..7a2d89c 100644 --- a/source/engine.hpp +++ b/source/engine.hpp @@ -269,6 +269,9 @@ class Engine { // PostFX helper void applyPostFXPreset(int mode); + // Boids: comprueba si un escenario tiene ≤ BOIDS_MAX_BALLS bolas + 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