refactor(bloques2-5): auditoria de codi - limpieza i arquitectura

Bloque 2: eliminar codi mort comentat (shape_manager, engine)
Bloque 3: Engine shape methods com thin wrappers a ShapeManager;
          eliminar estat duplicat de shapes en Engine
Bloque 4: encapsular getBallsMutable() amb helpers a SceneManager
          (enableShapeAttractionAll, resetDepthScalesAll)
Bloque 5: StateManager Phase 9 - tota la logica DEMO/LOGO
          implementada directament amb refs a SceneManager,
          ThemeManager i ShapeManager; eliminar callbacks a Engine.
          Acoplament Engine<->StateManager passa a unidireccional.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-19 00:42:03 +01:00
parent 6409b61bd5
commit 821eba3483
8 changed files with 640 additions and 1106 deletions

View File

@@ -74,24 +74,17 @@ void ShapeManager::toggleShapeMode(bool force_gravity_on_exit) {
}
}
// Si estamos en LOGO MODE, generar threshold aleatorio de convergencia (75-100%)
// Si estamos en LOGO MODE, resetear convergencia al entrar
if (state_mgr_ && state_mgr_->getCurrentMode() == AppMode::LOGO) {
/*
float logo_convergence_threshold = LOGO_CONVERGENCE_MIN +
(rand() % 1000) / 1000.0f * (LOGO_CONVERGENCE_MAX - LOGO_CONVERGENCE_MIN);
*/
shape_convergence_ = 0.0f; // Reset convergencia al entrar
shape_convergence_ = 0.0f;
}
} else {
// Volver a modo física normal
current_mode_ = SimulationMode::PHYSICS;
// Desactivar atracción y resetear escala de profundidad
auto& balls = scene_mgr_->getBallsMutable();
for (auto& ball : balls) {
ball->enableShapeAttraction(false);
ball->setDepthScale(1.0f); // Reset escala a 100% (evita "pop" visual)
}
scene_mgr_->enableShapeAttractionAll(false);
scene_mgr_->resetDepthScalesAll(); // Reset escala a 100% (evita "pop" visual)
// Activar gravedad al salir (solo si se especifica)
if (force_gravity_on_exit) {
@@ -280,10 +273,7 @@ void ShapeManager::activateShapeInternal(ShapeType type) {
generateShape();
// Activar atracción física en todas las pelotas
auto& balls = scene_mgr_->getBallsMutable();
for (auto& ball : balls) {
ball->enableShapeAttraction(true);
}
scene_mgr_->enableShapeAttractionAll(true);
// Mostrar notificación con nombre de figura (solo si NO estamos en modo demo o logo)
if (active_shape_ && state_mgr_ && ui_mgr_ && state_mgr_->getCurrentMode() == AppMode::SANDBOX) {
@@ -292,6 +282,11 @@ void ShapeManager::activateShapeInternal(ShapeType type) {
}
}
void ShapeManager::setShapeScaleFactor(float scale) {
shape_scale_factor_ = scale;
clampShapeScale();
}
void ShapeManager::clampShapeScale() {
// Calcular tamaño máximo permitido según resolución actual
// La figura más grande (esfera/cubo) usa ~33% de altura por defecto