feat: Convertir BOIDS a sistema time-based (independiente de framerate)
- Conversión completa de físicas BOIDS de frame-based a time-based - Velocidades: ×60 (px/frame → px/s) - Aceleraciones (Separation, Cohesion): ×3600 (px/frame² → px/s²) - Steering proporcional (Alignment): ×60 - Límites de velocidad: ×60 Constantes actualizadas en defines.h: - BOID_SEPARATION_WEIGHT: 1.5 → 5400.0 (aceleración) - BOID_COHESION_WEIGHT: 0.001 → 3.6 (aceleración) - BOID_ALIGNMENT_WEIGHT: 1.0 → 60.0 (steering) - BOID_MAX_SPEED: 2.5 → 150.0 px/s - BOID_MIN_SPEED: 0.3 → 18.0 px/s - BOID_MAX_FORCE: 0.05 → 3.0 px/s Física ahora consistente en 60Hz, 144Hz, 240Hz screens. Transiciones BOIDS↔PHYSICS preservan velocidad correctamente. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -364,18 +364,19 @@ void Engine::handleGravityToggle() {
|
||||
}
|
||||
|
||||
void Engine::handleGravityDirectionChange(GravityDirection direction, const char* notification_text) {
|
||||
// Si estamos en modo boids, salir a modo física primero
|
||||
// Si estamos en modo boids, salir a modo física primero PRESERVANDO VELOCIDAD
|
||||
if (current_mode_ == SimulationMode::BOIDS) {
|
||||
toggleBoidsMode(); // Esto cambia a PHYSICS y activa gravedad
|
||||
// Continuar para aplicar la dirección de gravedad
|
||||
current_mode_ = SimulationMode::PHYSICS;
|
||||
boid_manager_->deactivateBoids(false); // NO activar gravedad aún (preservar momentum)
|
||||
scene_manager_->forceBallsGravityOn(); // Activar gravedad SIN impulsos (preserva velocidad)
|
||||
}
|
||||
|
||||
// Si estamos en modo figura, salir a modo física CON gravedad
|
||||
if (current_mode_ == SimulationMode::SHAPE) {
|
||||
else if (current_mode_ == SimulationMode::SHAPE) {
|
||||
toggleShapeModeInternal(); // Desactivar figura (activa gravedad automáticamente)
|
||||
} else {
|
||||
scene_manager_->enableBallsGravityIfDisabled(); // Reactivar gravedad si estaba OFF
|
||||
}
|
||||
|
||||
scene_manager_->changeGravityDirection(direction);
|
||||
showNotificationForAction(notification_text);
|
||||
}
|
||||
@@ -437,9 +438,9 @@ void Engine::toggleDepthZoom() {
|
||||
// Boids (comportamiento de enjambre)
|
||||
void Engine::toggleBoidsMode() {
|
||||
if (current_mode_ == SimulationMode::BOIDS) {
|
||||
// Salir del modo boids
|
||||
// Salir del modo boids (velocidades ya son time-based, no requiere conversión)
|
||||
current_mode_ = SimulationMode::PHYSICS;
|
||||
boid_manager_->deactivateBoids();
|
||||
boid_manager_->deactivateBoids(false); // NO activar gravedad (preservar momentum)
|
||||
} else {
|
||||
// Entrar al modo boids (desde PHYSICS o SHAPE)
|
||||
if (current_mode_ == SimulationMode::SHAPE) {
|
||||
@@ -1359,6 +1360,18 @@ void Engine::executeDemoAction(bool is_lite) {
|
||||
int valid_scenarios[] = {1, 2, 3, 4, 5};
|
||||
int new_scenario = valid_scenarios[rand() % 5];
|
||||
scene_manager_->changeScenario(new_scenario, current_mode_);
|
||||
|
||||
// Si estamos en modo SHAPE, regenerar la figura con nuevo número de pelotas
|
||||
if (current_mode_ == SimulationMode::SHAPE) {
|
||||
generateShape();
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1573,6 +1586,15 @@ void Engine::executeExitLogoMode() {
|
||||
clampShapeScale();
|
||||
generateShape();
|
||||
|
||||
// Activar atracción física si estamos en modo SHAPE
|
||||
// (crítico para que las bolas se muevan hacia la figura restaurada)
|
||||
if (current_mode_ == SimulationMode::SHAPE) {
|
||||
auto& balls = scene_manager_->getBallsMutable();
|
||||
for (auto& ball : balls) {
|
||||
ball->enableShapeAttraction(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Desactivar modo LOGO en PNG_SHAPE (volver a flip intervals normales)
|
||||
if (active_shape_) {
|
||||
PNGShape* png_shape = dynamic_cast<PNGShape*>(active_shape_.get());
|
||||
|
||||
Reference in New Issue
Block a user