Refactorizar estilo del proyecto: .h → .hpp, #pragma once, includes desde raíz
Modernizar convenciones de código C++ aplicando las siguientes directivas:
## Cambios principales
**1. Renombrar headers (.h → .hpp)**
- 36 archivos renombrados a extensión .hpp (estándar C++)
- Mantenidos como .h: stb_image.h, stb_image_resize2.h (librerías C externas)
**2. Modernizar include guards (#ifndef → #pragma once)**
- resource_manager.hpp: #ifndef RESOURCE_MANAGER_H → #pragma once
- resource_pack.hpp: #ifndef RESOURCE_PACK_H → #pragma once
- spatial_grid.hpp: #ifndef SPATIAL_GRID_H → #pragma once
**3. Sistema de includes desde raíz del proyecto**
- CMakeLists.txt: añadido include_directories(${CMAKE_SOURCE_DIR}/source)
- Eliminadas rutas relativas (../) en todos los includes
- Includes ahora usan rutas absolutas desde source/
**Antes:**
```cpp
#include "../defines.h"
#include "../text/textrenderer.h"
```
**Ahora:**
```cpp
#include "defines.hpp"
#include "text/textrenderer.hpp"
```
## Archivos afectados
- 1 archivo CMakeLists.txt modificado
- 36 archivos renombrados (.h → .hpp)
- 32 archivos .cpp actualizados (includes)
- 36 archivos .hpp actualizados (includes + guards)
- 1 archivo tools/ actualizado
**Total: 70 archivos modificados**
## Verificación
✅ Proyecto compila sin errores
✅ Todas las rutas de includes correctas
✅ Include guards modernizados
✅ Librerías externas C mantienen extensión .h
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
170
source/shapes_mgr/shape_manager.hpp
Normal file
170
source/shapes_mgr/shape_manager.hpp
Normal file
@@ -0,0 +1,170 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
|
||||
#include "defines.hpp" // for SimulationMode, ShapeType
|
||||
#include "shapes/shape.hpp" // 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();
|
||||
};
|
||||
Reference in New Issue
Block a user