Compare commits
5 Commits
7fac103c51
...
boids_deve
| Author | SHA1 | Date | |
|---|---|---|---|
| a929346463 | |||
| c4075f68db | |||
| 399650f8da | |||
| 9b8afa1219 | |||
| 5b674c8ea6 |
@@ -790,6 +790,17 @@ void Engine::toggleRealFullscreen() {
|
|||||||
|
|
||||||
// Actualizar tamaño de pantalla para boids (wrapping boundaries)
|
// Actualizar tamaño de pantalla para boids (wrapping boundaries)
|
||||||
boid_manager_->updateScreenSize(current_screen_width_, current_screen_height_);
|
boid_manager_->updateScreenSize(current_screen_width_, current_screen_height_);
|
||||||
|
|
||||||
|
// Si estamos en modo SHAPE, regenerar la figura con nuevas dimensiones
|
||||||
|
if (current_mode_ == SimulationMode::SHAPE) {
|
||||||
|
generateShape(); // Regenerar figura con nuevas dimensiones de pantalla
|
||||||
|
|
||||||
|
// Activar atracción física en las bolas nuevas (crítico tras changeScenario)
|
||||||
|
auto& balls = scene_manager_->getBallsMutable();
|
||||||
|
for (auto& ball : balls) {
|
||||||
|
ball->enableShapeAttraction(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SDL_free(displays);
|
SDL_free(displays);
|
||||||
}
|
}
|
||||||
@@ -812,6 +823,17 @@ void Engine::toggleRealFullscreen() {
|
|||||||
// Reinicar la escena con resolución original
|
// Reinicar la escena con resolución original
|
||||||
scene_manager_->updateScreenSize(current_screen_width_, current_screen_height_);
|
scene_manager_->updateScreenSize(current_screen_width_, current_screen_height_);
|
||||||
scene_manager_->changeScenario(scene_manager_->getCurrentScenario(), current_mode_);
|
scene_manager_->changeScenario(scene_manager_->getCurrentScenario(), current_mode_);
|
||||||
|
|
||||||
|
// Si estamos en modo SHAPE, regenerar la figura con nuevas dimensiones
|
||||||
|
if (current_mode_ == SimulationMode::SHAPE) {
|
||||||
|
generateShape(); // Regenerar figura con nuevas dimensiones de pantalla
|
||||||
|
|
||||||
|
// Activar atracción física en las bolas nuevas (crítico tras changeScenario)
|
||||||
|
auto& balls = scene_manager_->getBallsMutable();
|
||||||
|
for (auto& ball : balls) {
|
||||||
|
ball->enableShapeAttraction(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,31 @@
|
|||||||
#include "../utils/easing_functions.h"
|
#include "../utils/easing_functions.h"
|
||||||
#include <SDL3/SDL.h>
|
#include <SDL3/SDL.h>
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// HELPER: Obtener viewport en coordenadas físicas (no lógicas)
|
||||||
|
// ============================================================================
|
||||||
|
// SDL_GetRenderViewport() devuelve coordenadas LÓGICAS cuando hay presentación
|
||||||
|
// lógica activa. Para obtener coordenadas FÍSICAS, necesitamos deshabilitar
|
||||||
|
// temporalmente la presentación lógica.
|
||||||
|
static SDL_Rect getPhysicalViewport(SDL_Renderer* renderer) {
|
||||||
|
// Guardar estado actual de presentación lógica
|
||||||
|
int logical_w = 0, logical_h = 0;
|
||||||
|
SDL_RendererLogicalPresentation presentation_mode;
|
||||||
|
SDL_GetRenderLogicalPresentation(renderer, &logical_w, &logical_h, &presentation_mode);
|
||||||
|
|
||||||
|
// Deshabilitar presentación lógica temporalmente
|
||||||
|
SDL_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED);
|
||||||
|
|
||||||
|
// Obtener viewport en coordenadas físicas (píxeles reales)
|
||||||
|
SDL_Rect physical_viewport;
|
||||||
|
SDL_GetRenderViewport(renderer, &physical_viewport);
|
||||||
|
|
||||||
|
// Restaurar presentación lógica
|
||||||
|
SDL_SetRenderLogicalPresentation(renderer, logical_w, logical_h, presentation_mode);
|
||||||
|
|
||||||
|
return physical_viewport;
|
||||||
|
}
|
||||||
|
|
||||||
Notifier::Notifier()
|
Notifier::Notifier()
|
||||||
: renderer_(nullptr)
|
: renderer_(nullptr)
|
||||||
, text_renderer_(nullptr)
|
, text_renderer_(nullptr)
|
||||||
@@ -159,10 +184,14 @@ void Notifier::render() {
|
|||||||
int bg_width = text_width + (NOTIFICATION_PADDING * 2);
|
int bg_width = text_width + (NOTIFICATION_PADDING * 2);
|
||||||
int bg_height = text_height + (NOTIFICATION_PADDING * 2);
|
int bg_height = text_height + (NOTIFICATION_PADDING * 2);
|
||||||
|
|
||||||
// Centrar en la ventana FÍSICA (no usar viewport lógico)
|
// Obtener viewport FÍSICO (píxeles reales, no lógicos)
|
||||||
// CRÍTICO: Como renderizamos en píxeles físicos absolutos (bypass de presentación lógica),
|
// CRÍTICO: En F3, SDL_GetRenderViewport() devuelve coordenadas LÓGICAS,
|
||||||
// debemos centrar usando dimensiones físicas, no el viewport lógico de SDL
|
// pero printAbsolute() trabaja en píxeles FÍSICOS. Usar helper para obtener
|
||||||
int x = (window_width_ / 2) - (bg_width / 2);
|
// viewport en coordenadas físicas.
|
||||||
|
SDL_Rect physical_viewport = getPhysicalViewport(renderer_);
|
||||||
|
|
||||||
|
// Centrar en el viewport físico (coordenadas relativas al viewport)
|
||||||
|
int x = (physical_viewport.w / 2) - (bg_width / 2);
|
||||||
int y = NOTIFICATION_TOP_MARGIN + static_cast<int>(current_notification_->y_offset);
|
int y = NOTIFICATION_TOP_MARGIN + static_cast<int>(current_notification_->y_offset);
|
||||||
|
|
||||||
// Renderizar fondo semitransparente (con bypass de presentación lógica)
|
// Renderizar fondo semitransparente (con bypass de presentación lógica)
|
||||||
|
|||||||
@@ -13,6 +13,31 @@
|
|||||||
#include "notifier.h" // for Notifier
|
#include "notifier.h" // for Notifier
|
||||||
#include "help_overlay.h" // for HelpOverlay
|
#include "help_overlay.h" // for HelpOverlay
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// HELPER: Obtener viewport en coordenadas físicas (no lógicas)
|
||||||
|
// ============================================================================
|
||||||
|
// SDL_GetRenderViewport() devuelve coordenadas LÓGICAS cuando hay presentación
|
||||||
|
// lógica activa. Para obtener coordenadas FÍSICAS, necesitamos deshabilitar
|
||||||
|
// temporalmente la presentación lógica.
|
||||||
|
static SDL_Rect getPhysicalViewport(SDL_Renderer* renderer) {
|
||||||
|
// Guardar estado actual de presentación lógica
|
||||||
|
int logical_w = 0, logical_h = 0;
|
||||||
|
SDL_RendererLogicalPresentation presentation_mode;
|
||||||
|
SDL_GetRenderLogicalPresentation(renderer, &logical_w, &logical_h, &presentation_mode);
|
||||||
|
|
||||||
|
// Deshabilitar presentación lógica temporalmente
|
||||||
|
SDL_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED);
|
||||||
|
|
||||||
|
// Obtener viewport en coordenadas físicas (píxeles reales)
|
||||||
|
SDL_Rect physical_viewport;
|
||||||
|
SDL_GetRenderViewport(renderer, &physical_viewport);
|
||||||
|
|
||||||
|
// Restaurar presentación lógica
|
||||||
|
SDL_SetRenderLogicalPresentation(renderer, logical_w, logical_h, presentation_mode);
|
||||||
|
|
||||||
|
return physical_viewport;
|
||||||
|
}
|
||||||
|
|
||||||
UIManager::UIManager()
|
UIManager::UIManager()
|
||||||
: text_renderer_(nullptr)
|
: text_renderer_(nullptr)
|
||||||
, text_renderer_debug_(nullptr)
|
, text_renderer_debug_(nullptr)
|
||||||
@@ -205,6 +230,12 @@ void UIManager::renderDebugHUD(const Engine* engine,
|
|||||||
int line_height = text_renderer_debug_->getTextHeight();
|
int line_height = text_renderer_debug_->getTextHeight();
|
||||||
int margin = 8; // Margen constante en píxeles físicos
|
int margin = 8; // Margen constante en píxeles físicos
|
||||||
|
|
||||||
|
// Obtener viewport FÍSICO (píxeles reales, no lógicos)
|
||||||
|
// CRÍTICO: En F3, SDL_GetRenderViewport() devuelve coordenadas LÓGICAS,
|
||||||
|
// pero printAbsolute() trabaja en píxeles FÍSICOS. Usar helper para obtener
|
||||||
|
// viewport en coordenadas físicas.
|
||||||
|
SDL_Rect physical_viewport = getPhysicalViewport(renderer_);
|
||||||
|
|
||||||
// ===========================
|
// ===========================
|
||||||
// COLUMNA LEFT (Sistema)
|
// COLUMNA LEFT (Sistema)
|
||||||
// ===========================
|
// ===========================
|
||||||
@@ -307,7 +338,7 @@ void UIManager::renderDebugHUD(const Engine* engine,
|
|||||||
|
|
||||||
// FPS counter (esquina superior derecha)
|
// FPS counter (esquina superior derecha)
|
||||||
int fps_text_width = text_renderer_debug_->getTextWidthPhysical(fps_text_.c_str());
|
int fps_text_width = text_renderer_debug_->getTextWidthPhysical(fps_text_.c_str());
|
||||||
int fps_x = physical_window_width_ - fps_text_width - margin;
|
int fps_x = physical_viewport.w - fps_text_width - margin;
|
||||||
text_renderer_debug_->printAbsolute(fps_x, right_y, fps_text_.c_str(), {255, 255, 0, 255}); // Amarillo
|
text_renderer_debug_->printAbsolute(fps_x, right_y, fps_text_.c_str(), {255, 255, 0, 255}); // Amarillo
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
@@ -318,47 +349,47 @@ void UIManager::renderDebugHUD(const Engine* engine,
|
|||||||
SDL_FRect pos = first_ball->getPosition();
|
SDL_FRect pos = first_ball->getPosition();
|
||||||
std::string pos_text = "Pos: (" + std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) + ")";
|
std::string pos_text = "Pos: (" + std::to_string(static_cast<int>(pos.x)) + ", " + std::to_string(static_cast<int>(pos.y)) + ")";
|
||||||
int pos_width = text_renderer_debug_->getTextWidthPhysical(pos_text.c_str());
|
int pos_width = text_renderer_debug_->getTextWidthPhysical(pos_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - pos_width - margin, right_y, pos_text.c_str(), {255, 128, 128, 255}); // Rojo claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - pos_width - margin, right_y, pos_text.c_str(), {255, 128, 128, 255}); // Rojo claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Velocidad X
|
// Velocidad X
|
||||||
int vx_int = static_cast<int>(first_ball->getVelocityX());
|
int vx_int = static_cast<int>(first_ball->getVelocityX());
|
||||||
std::string vx_text = "VelX: " + std::to_string(vx_int);
|
std::string vx_text = "VelX: " + std::to_string(vx_int);
|
||||||
int vx_width = text_renderer_debug_->getTextWidthPhysical(vx_text.c_str());
|
int vx_width = text_renderer_debug_->getTextWidthPhysical(vx_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - vx_width - margin, right_y, vx_text.c_str(), {128, 255, 128, 255}); // Verde claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - vx_width - margin, right_y, vx_text.c_str(), {128, 255, 128, 255}); // Verde claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Velocidad Y
|
// Velocidad Y
|
||||||
int vy_int = static_cast<int>(first_ball->getVelocityY());
|
int vy_int = static_cast<int>(first_ball->getVelocityY());
|
||||||
std::string vy_text = "VelY: " + std::to_string(vy_int);
|
std::string vy_text = "VelY: " + std::to_string(vy_int);
|
||||||
int vy_width = text_renderer_debug_->getTextWidthPhysical(vy_text.c_str());
|
int vy_width = text_renderer_debug_->getTextWidthPhysical(vy_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - vy_width - margin, right_y, vy_text.c_str(), {128, 255, 128, 255}); // Verde claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - vy_width - margin, right_y, vy_text.c_str(), {128, 255, 128, 255}); // Verde claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Fuerza de gravedad
|
// Fuerza de gravedad
|
||||||
int grav_int = static_cast<int>(first_ball->getGravityForce());
|
int grav_int = static_cast<int>(first_ball->getGravityForce());
|
||||||
std::string grav_text = "Gravity: " + std::to_string(grav_int);
|
std::string grav_text = "Gravity: " + std::to_string(grav_int);
|
||||||
int grav_width = text_renderer_debug_->getTextWidthPhysical(grav_text.c_str());
|
int grav_width = text_renderer_debug_->getTextWidthPhysical(grav_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - grav_width - margin, right_y, grav_text.c_str(), {255, 255, 128, 255}); // Amarillo claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - grav_width - margin, right_y, grav_text.c_str(), {255, 255, 128, 255}); // Amarillo claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Estado superficie
|
// Estado superficie
|
||||||
std::string surface_text = first_ball->isOnSurface() ? "Surface: YES" : "Surface: NO";
|
std::string surface_text = first_ball->isOnSurface() ? "Surface: YES" : "Surface: NO";
|
||||||
int surface_width = text_renderer_debug_->getTextWidthPhysical(surface_text.c_str());
|
int surface_width = text_renderer_debug_->getTextWidthPhysical(surface_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - surface_width - margin, right_y, surface_text.c_str(), {255, 200, 128, 255}); // Naranja claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - surface_width - margin, right_y, surface_text.c_str(), {255, 200, 128, 255}); // Naranja claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Coeficiente de rebote (loss)
|
// Coeficiente de rebote (loss)
|
||||||
float loss_val = first_ball->getLossCoefficient();
|
float loss_val = first_ball->getLossCoefficient();
|
||||||
std::string loss_text = "Loss: " + std::to_string(loss_val).substr(0, 4);
|
std::string loss_text = "Loss: " + std::to_string(loss_val).substr(0, 4);
|
||||||
int loss_width = text_renderer_debug_->getTextWidthPhysical(loss_text.c_str());
|
int loss_width = text_renderer_debug_->getTextWidthPhysical(loss_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - loss_width - margin, right_y, loss_text.c_str(), {255, 128, 255, 255}); // Magenta
|
text_renderer_debug_->printAbsolute(physical_viewport.w - loss_width - margin, right_y, loss_text.c_str(), {255, 128, 255, 255}); // Magenta
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
|
|
||||||
// Dirección de gravedad
|
// Dirección de gravedad
|
||||||
std::string gravity_dir_text = "Dir: " + gravityDirectionToString(static_cast<int>(scene_manager->getCurrentGravity()));
|
std::string gravity_dir_text = "Dir: " + gravityDirectionToString(static_cast<int>(scene_manager->getCurrentGravity()));
|
||||||
int dir_width = text_renderer_debug_->getTextWidthPhysical(gravity_dir_text.c_str());
|
int dir_width = text_renderer_debug_->getTextWidthPhysical(gravity_dir_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - dir_width - margin, right_y, gravity_dir_text.c_str(), {128, 255, 255, 255}); // Cian claro
|
text_renderer_debug_->printAbsolute(physical_viewport.w - dir_width - margin, right_y, gravity_dir_text.c_str(), {128, 255, 255, 255}); // Cian claro
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +398,7 @@ void UIManager::renderDebugHUD(const Engine* engine,
|
|||||||
int convergence_percent = static_cast<int>(shape_convergence * 100.0f);
|
int convergence_percent = static_cast<int>(shape_convergence * 100.0f);
|
||||||
std::string convergence_text = "Convergence: " + std::to_string(convergence_percent) + "%";
|
std::string convergence_text = "Convergence: " + std::to_string(convergence_percent) + "%";
|
||||||
int conv_width = text_renderer_debug_->getTextWidthPhysical(convergence_text.c_str());
|
int conv_width = text_renderer_debug_->getTextWidthPhysical(convergence_text.c_str());
|
||||||
text_renderer_debug_->printAbsolute(physical_window_width_ - conv_width - margin, right_y, convergence_text.c_str(), {255, 128, 0, 255}); // Naranja
|
text_renderer_debug_->printAbsolute(physical_viewport.w - conv_width - margin, right_y, convergence_text.c_str(), {255, 128, 0, 255}); // Naranja
|
||||||
right_y += line_height;
|
right_y += line_height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user