Refactor fase 10: Implementar BoidManager completo
Cambios realizados: - Creado BoidManager (source/boids_mgr/) con algoritmo de Reynolds (1987) * Separación: Evitar colisiones con vecinos cercanos * Alineación: Seguir dirección promedio del grupo * Cohesión: Moverse hacia centro de masa del grupo * Wrapping boundaries (teletransporte en bordes) * Velocidad y fuerza limitadas (steering behavior) - Añadido BOIDS a enum SimulationMode (defines.h) - Añadidas constantes de configuración boids (defines.h) - Integrado BoidManager en Engine (inicialización, update, toggle) - Añadido binding de tecla J para toggleBoidsMode() (input_handler.cpp) - Añadidos helpers en Ball: getVelocity(), setVelocity(), setPosition() - Actualizado CMakeLists.txt para incluir source/boids_mgr/*.cpp Arquitectura: - BoidManager sigue el patrón establecido (similar a ShapeManager) - Gestión independiente del comportamiento de enjambre - Tres reglas de Reynolds implementadas correctamente - Compatible con sistema de resolución dinámica Estado: Compilación exitosa, BoidManager funcional Próximo paso: Testing y ajuste de parámetros boids 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -249,6 +249,11 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
|
||||
// Actualizar ShapeManager con StateManager (dependencia circular - StateManager debe existir primero)
|
||||
shape_manager_->initialize(this, scene_manager_.get(), ui_manager_.get(), state_manager_.get(),
|
||||
current_screen_width_, current_screen_height_);
|
||||
|
||||
// Inicializar BoidManager (gestión de comportamiento de enjambre)
|
||||
boid_manager_ = std::make_unique<BoidManager>();
|
||||
boid_manager_->initialize(this, scene_manager_.get(), ui_manager_.get(), state_manager_.get(),
|
||||
current_screen_width_, current_screen_height_);
|
||||
}
|
||||
|
||||
return success;
|
||||
@@ -319,6 +324,9 @@ void Engine::update() {
|
||||
} else if (current_mode_ == SimulationMode::SHAPE) {
|
||||
// Modo Figura 3D: actualizar figura polimórfica
|
||||
updateShape();
|
||||
} else if (current_mode_ == SimulationMode::BOIDS) {
|
||||
// Modo Boids: actualizar comportamiento de enjambre (delegado a BoidManager)
|
||||
boid_manager_->update(delta_time_);
|
||||
}
|
||||
|
||||
// Actualizar Modo DEMO/LOGO (delegado a StateManager)
|
||||
@@ -406,6 +414,32 @@ void Engine::toggleDepthZoom() {
|
||||
}
|
||||
}
|
||||
|
||||
// Boids (comportamiento de enjambre)
|
||||
void Engine::toggleBoidsMode() {
|
||||
if (current_mode_ == SimulationMode::BOIDS) {
|
||||
// Salir del modo boids
|
||||
current_mode_ = SimulationMode::PHYSICS;
|
||||
boid_manager_->deactivateBoids();
|
||||
} else {
|
||||
// Entrar al modo boids (desde PHYSICS o SHAPE)
|
||||
if (current_mode_ == SimulationMode::SHAPE) {
|
||||
// Si estamos en modo shape, salir primero sin forzar gravedad
|
||||
current_mode_ = SimulationMode::PHYSICS;
|
||||
|
||||
// Desactivar atracción de figuras
|
||||
auto& balls = scene_manager_->getBallsMutable();
|
||||
for (auto& ball : balls) {
|
||||
ball->enableShapeAttraction(false);
|
||||
ball->setDepthScale(1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Activar modo boids
|
||||
current_mode_ = SimulationMode::BOIDS;
|
||||
boid_manager_->activateBoids();
|
||||
}
|
||||
}
|
||||
|
||||
// Temas de colores
|
||||
void Engine::cycleTheme(bool forward) {
|
||||
if (forward) {
|
||||
|
||||
Reference in New Issue
Block a user