ENFOQUE PRAGMÁTICO: - ShapeManager creado e implementado completamente - Código DUPLICADO entre Engine y ShapeManager temporalmente - Engine mantiene implementación para DEMO/LOGO (hasta Fase 8) - Compilación exitosa, aplicación funcional ARCHIVOS CREADOS/MODIFICADOS: 1. shape_manager.h: - Interfaz completa de ShapeManager - Métodos públicos para control de figuras 3D - Referencias a Scene/UI/StateManager 2. shape_manager.cpp: - Implementación completa de todos los métodos - toggleShapeMode(), activateShape(), update(), generateShape() - Sistema de atracción física con spring forces - Cálculo de convergencia para LOGO MODE - Includes de todas las Shape classes 3. engine.h: - Variables de figuras 3D MANTENIDAS (duplicadas con ShapeManager) - Comentarios documentando duplicación temporal - TODO markers para Fase 8 4. engine.cpp: - Inicialización de ShapeManager con dependencias - Métodos de figuras restaurados (no eliminados) - Código DEMO/LOGO funciona con variables locales - Sistema de rendering usa current_mode_ local DUPLICACIÓN TEMPORAL DOCUMENTADA: ```cpp // Engine mantiene: - current_mode_, current_shape_type_, last_shape_type_ - active_shape_, shape_scale_factor_, depth_zoom_enabled_ - shape_convergence_ - toggleShapeModeInternal(), activateShapeInternal() - updateShape(), generateShape(), clampShapeScale() ``` JUSTIFICACIÓN: - Migrar ShapeManager sin migrar DEMO/LOGO causaba conflictos masivos - Enfoque incremental: Fase 7 (ShapeManager) → Fase 8 (DEMO/LOGO) - Permite compilación y testing entre fases - ShapeManager está listo para uso futuro en controles manuales RESULTADO: ✅ Compilación exitosa (1 warning menor) ✅ Aplicación funciona correctamente ✅ Todas las características operativas ✅ ShapeManager completamente implementado ✅ Listo para Fase 8 (migración DEMO/LOGO a StateManager) PRÓXIMOS PASOS (Fase 8): 1. Migrar lógica DEMO/LOGO de Engine a StateManager 2. Convertir métodos de Engine en wrappers a StateManager/ShapeManager 3. Eliminar código duplicado 4. Limpieza final 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
171 lines
5.2 KiB
C++
171 lines
5.2 KiB
C++
#pragma once
|
|
|
|
#include <memory> // for unique_ptr
|
|
|
|
#include "../defines.h" // for SimulationMode, ShapeType
|
|
#include "../shapes/shape.h" // for Shape base class
|
|
|
|
// Forward declarations
|
|
class Engine;
|
|
class SceneManager;
|
|
class UIManager;
|
|
class StateManager;
|
|
|
|
/**
|
|
* @class ShapeManager
|
|
* @brief Gestiona el sistema de figuras 3D (esferas, cubos, PNG shapes, etc.)
|
|
*
|
|
* Responsabilidad única: Gestión de figuras 3D polimórficas
|
|
*
|
|
* Características:
|
|
* - Control de modo simulación (PHYSICS/SHAPE)
|
|
* - Gestión de tipos de figura (SPHERE/CUBE/PYRAMID/TORUS/ICOSAHEDRON/PNG_SHAPE)
|
|
* - Sistema de escalado manual (Numpad +/-)
|
|
* - Toggle de depth zoom (Z)
|
|
* - Generación y actualización de puntos de figura
|
|
* - Callbacks al Engine para renderizado
|
|
*/
|
|
class ShapeManager {
|
|
public:
|
|
/**
|
|
* @brief Constructor
|
|
*/
|
|
ShapeManager();
|
|
|
|
/**
|
|
* @brief Destructor
|
|
*/
|
|
~ShapeManager();
|
|
|
|
/**
|
|
* @brief Inicializa el ShapeManager con referencias a otros componentes
|
|
* @param engine Puntero al Engine (para callbacks legacy)
|
|
* @param scene_mgr Puntero a SceneManager (para acceso a bolas)
|
|
* @param ui_mgr Puntero a UIManager (para notificaciones)
|
|
* @param state_mgr Puntero a StateManager (para verificar modo actual)
|
|
* @param screen_width Ancho lógico de pantalla
|
|
* @param screen_height Alto lógico de pantalla
|
|
*/
|
|
void initialize(Engine* engine, SceneManager* scene_mgr, UIManager* ui_mgr,
|
|
StateManager* state_mgr, int screen_width, int screen_height);
|
|
|
|
/**
|
|
* @brief Toggle entre modo PHYSICS y SHAPE
|
|
* @param force_gravity_on_exit Forzar gravedad al salir de SHAPE mode
|
|
*/
|
|
void toggleShapeMode(bool force_gravity_on_exit = true);
|
|
|
|
/**
|
|
* @brief Activa un tipo específico de figura
|
|
* @param type Tipo de figura a activar
|
|
*/
|
|
void activateShape(ShapeType type);
|
|
|
|
/**
|
|
* @brief Cambia la escala de la figura actual
|
|
* @param increase true para aumentar, false para reducir
|
|
*/
|
|
void handleShapeScaleChange(bool increase);
|
|
|
|
/**
|
|
* @brief Resetea la escala de figura a 1.0
|
|
*/
|
|
void resetShapeScale();
|
|
|
|
/**
|
|
* @brief Toggle del zoom por profundidad Z
|
|
*/
|
|
void toggleDepthZoom();
|
|
|
|
/**
|
|
* @brief Actualiza la figura activa (rotación, etc.)
|
|
* @param delta_time Delta time para animaciones
|
|
*/
|
|
void update(float delta_time);
|
|
|
|
/**
|
|
* @brief Genera los puntos de la figura activa
|
|
*/
|
|
void generateShape();
|
|
|
|
// === Getters ===
|
|
|
|
/**
|
|
* @brief Obtiene el modo de simulación actual
|
|
*/
|
|
SimulationMode getCurrentMode() const { return current_mode_; }
|
|
|
|
/**
|
|
* @brief Obtiene el tipo de figura actual
|
|
*/
|
|
ShapeType getCurrentShapeType() const { return current_shape_type_; }
|
|
|
|
/**
|
|
* @brief Obtiene puntero a la figura activa
|
|
*/
|
|
Shape* getActiveShape() { return active_shape_.get(); }
|
|
const Shape* getActiveShape() const { return active_shape_.get(); }
|
|
|
|
/**
|
|
* @brief Obtiene el factor de escala actual
|
|
*/
|
|
float getShapeScaleFactor() const { return shape_scale_factor_; }
|
|
|
|
/**
|
|
* @brief Verifica si depth zoom está activado
|
|
*/
|
|
bool isDepthZoomEnabled() const { return depth_zoom_enabled_; }
|
|
|
|
/**
|
|
* @brief Verifica si modo SHAPE está activo
|
|
*/
|
|
bool isShapeModeActive() const { return current_mode_ == SimulationMode::SHAPE; }
|
|
|
|
/**
|
|
* @brief Actualiza el tamaño de pantalla (para resize/fullscreen)
|
|
* @param width Nuevo ancho lógico
|
|
* @param height Nuevo alto lógico
|
|
*/
|
|
void updateScreenSize(int width, int height);
|
|
|
|
/**
|
|
* @brief Obtiene convergencia actual (para modo LOGO)
|
|
*/
|
|
float getConvergence() const { return shape_convergence_; }
|
|
|
|
private:
|
|
// === Referencias a otros componentes ===
|
|
Engine* engine_; // Callback al Engine (legacy - temporal)
|
|
SceneManager* scene_mgr_; // Acceso a bolas y física
|
|
UIManager* ui_mgr_; // Notificaciones
|
|
StateManager* state_mgr_; // Verificación de modo actual
|
|
|
|
// === Estado de figuras 3D ===
|
|
SimulationMode current_mode_;
|
|
ShapeType current_shape_type_;
|
|
ShapeType last_shape_type_;
|
|
std::unique_ptr<Shape> active_shape_;
|
|
float shape_scale_factor_;
|
|
bool depth_zoom_enabled_;
|
|
|
|
// === Dimensiones de pantalla ===
|
|
int screen_width_;
|
|
int screen_height_;
|
|
|
|
// === Convergencia (para modo LOGO) ===
|
|
float shape_convergence_;
|
|
|
|
// === Métodos privados ===
|
|
|
|
/**
|
|
* @brief Implementación interna de activación de figura
|
|
* @param type Tipo de figura
|
|
*/
|
|
void activateShapeInternal(ShapeType type);
|
|
|
|
/**
|
|
* @brief Limita la escala para evitar clipping
|
|
*/
|
|
void clampShapeScale();
|
|
};
|