Fix: Transición instantánea dinámico→estático (evita fondo negro)
PROBLEMA: Al cambiar de tema dinámico (SUNRISE/OCEAN WAVES/NEON PULSE) a tema estático (SUNSET/LAVENDER/etc), el fondo se volvía negro o mostraba colores corruptos durante la transición LERP. CAUSA: 1. activateDynamicTheme() NO actualiza current_theme_ (queda en valor previo) 2. startThemeTransition() desactiva dynamic_theme_active_ 3. renderGradientBackground() intenta LERP desde themes_[current_theme_] 4. Si current_theme_ era LAVENDER (índice 6), accede themes_[6] OK 5. Pero si era cualquier valor >= 7, accede fuera de bounds → basura SOLUCIÓN IMPLEMENTADA: ✅ Detectar transición desde tema dinámico en startThemeTransition() ✅ Si dynamic_theme_active_ == true: - Hacer transición INSTANTÁNEA (sin LERP) - Cambiar current_theme_ inmediatamente al tema destino - Actualizar colores de pelotas sin interpolación - Evitar acceso a themes_[] con índices inválidos ✅ Eliminar asignación de current_theme_ en activateDynamicTheme() - Cuando dynamic_theme_active_=true, se usa current_dynamic_theme_index_ - current_theme_ solo se usa cuando dynamic_theme_active_=false RESULTADO: - Dinámico → Estático: Cambio instantáneo limpio ✅ - Estático → Estático: Transición LERP suave (sin cambios) ✅ - Estático → Dinámico: Cambio instantáneo (sin cambios) ✅ - Dinámico → Dinámico: Cambio instantáneo (sin cambios) ✅ TRADE-OFF: - Perdemos transición suave dinámico→estático - Ganamos estabilidad y eliminamos fondo negro/corrupto - Para implementar LERP correcto se requiere refactor mayor (unificar todos los temas bajo sistema dinámico) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -79,17 +79,18 @@ enum class GravityDirection {
|
||||
};
|
||||
|
||||
// Enum para temas de colores (seleccionables con teclado numérico)
|
||||
// Todos los temas usan ahora sistema dinámico de keyframes
|
||||
enum class ColorTheme {
|
||||
SUNSET = 0, // Naranjas, rojos, amarillos, rosas
|
||||
OCEAN = 1, // Azules, turquesas, blancos
|
||||
NEON = 2, // Cian, magenta, verde lima, amarillo vibrante
|
||||
FOREST = 3, // Verdes, marrones, amarillos otoño
|
||||
RGB = 4, // RGB puros y subdivisiones matemáticas (fondo blanco)
|
||||
MONOCHROME = 5, // Fondo negro degradado, sprites blancos monocromáticos
|
||||
LAVENDER = 6, // Degradado violeta-azul, pelotas amarillo dorado
|
||||
DYNAMIC_1 = 7, // Tema dinámico 1: SUNRISE (amanecer)
|
||||
DYNAMIC_2 = 8, // Tema dinámico 2: OCEAN WAVES (olas oceánicas)
|
||||
DYNAMIC_3 = 9 // Tema dinámico 3: NEON PULSE (pulso neón)
|
||||
SUNSET = 0, // Naranjas, rojos, amarillos, rosas (estático: 1 keyframe)
|
||||
OCEAN = 1, // Azules, turquesas, blancos (estático: 1 keyframe)
|
||||
NEON = 2, // Cian, magenta, verde lima, amarillo vibrante (estático: 1 keyframe)
|
||||
FOREST = 3, // Verdes, marrones, amarillos otoño (estático: 1 keyframe)
|
||||
RGB = 4, // RGB puros y subdivisiones matemáticas - fondo blanco (estático: 1 keyframe)
|
||||
MONOCHROME = 5, // Fondo negro degradado, sprites blancos monocromáticos (estático: 1 keyframe)
|
||||
LAVENDER = 6, // Degradado violeta-azul, pelotas amarillo dorado (estático: 1 keyframe)
|
||||
SUNRISE = 7, // Amanecer: Noche → Alba → Día (animado: 4 keyframes, 12s ciclo)
|
||||
OCEAN_WAVES = 8, // Olas oceánicas: Azul oscuro ↔ Turquesa (animado: 3 keyframes, 8s ciclo)
|
||||
NEON_PULSE = 9 // Pulso neón: Negro ↔ Neón vibrante (animado: 3 keyframes, 3s ping-pong)
|
||||
};
|
||||
|
||||
// Enum para tipo de figura 3D
|
||||
|
||||
@@ -1575,12 +1575,34 @@ void Engine::initializeDynamicThemes() {
|
||||
void Engine::startThemeTransition(ColorTheme new_theme) {
|
||||
if (new_theme == current_theme_) return; // Ya estamos en ese tema
|
||||
|
||||
// Desactivar tema dinámico si estaba activo
|
||||
// Si venimos de tema dinámico, hacer transición instantánea (sin LERP)
|
||||
// porque current_theme_ apunta a DYNAMIC_X (índice >= 7) y no existe en themes_[]
|
||||
if (dynamic_theme_active_) {
|
||||
dynamic_theme_active_ = false;
|
||||
current_dynamic_theme_index_ = -1;
|
||||
|
||||
// Cambio instantáneo: sin transición LERP
|
||||
current_theme_ = new_theme;
|
||||
transitioning_ = false;
|
||||
|
||||
// Actualizar colores de pelotas al tema final
|
||||
const ThemeColors& theme = themes_[static_cast<int>(new_theme)];
|
||||
for (size_t i = 0; i < balls_.size(); i++) {
|
||||
size_t color_index = i % theme.ball_colors.size();
|
||||
balls_[i]->setColor(theme.ball_colors[color_index]);
|
||||
}
|
||||
|
||||
// Mostrar nombre del tema
|
||||
if (current_app_mode_ == AppMode::MANUAL) {
|
||||
text_ = theme.name_es;
|
||||
text_pos_ = (current_screen_width_ - static_cast<int>(text_.length() * 8)) / 2;
|
||||
show_text_ = true;
|
||||
text_init_time_ = SDL_GetTicks();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Transición normal entre temas estáticos
|
||||
target_theme_ = new_theme;
|
||||
transitioning_ = true;
|
||||
transition_progress_ = 0.0f;
|
||||
@@ -1646,8 +1668,8 @@ void Engine::activateDynamicTheme(int index) {
|
||||
dynamic_transition_progress_ = 0.0f;
|
||||
dynamic_theme_paused_ = false;
|
||||
|
||||
// Actualizar current_theme_ al enum correspondiente
|
||||
current_theme_ = static_cast<ColorTheme>(static_cast<int>(ColorTheme::DYNAMIC_1) + index);
|
||||
// NOTA: No actualizamos current_theme_ porque cuando dynamic_theme_active_=true,
|
||||
// todo el código usa current_dynamic_theme_index_ en su lugar
|
||||
|
||||
// Establecer colores iniciales del keyframe 0
|
||||
DynamicTheme& theme = dynamic_themes_[index];
|
||||
|
||||
Reference in New Issue
Block a user