fix(ship-3d): oscil·lació contínua entre ENTERING i FLOATING (sense salt)
This commit is contained in:
@@ -181,15 +181,32 @@ namespace Title {
|
||||
const float PROGRESS = std::min(1.0F, ELAPSED / ENTRY_DURATION);
|
||||
const float EASED = Easing::easeOutQuad(PROGRESS);
|
||||
|
||||
ship.current_position.x = Easing::lerp(ship.initial_position.x, ship.target_position.x, EASED);
|
||||
ship.current_position.y = Easing::lerp(ship.initial_position.y, ship.target_position.y, EASED);
|
||||
ship.current_position.z = Easing::lerp(ship.initial_position.z, ship.target_position.z, EASED);
|
||||
// Acumula la fase d'oscil·lació també durant ENTERING; sense això,
|
||||
// al passar a FLOATING la posició salta d'amplitud_y de cop perquè
|
||||
// l'offset Y comença a sin(π/2) = 1. Acumulant-la abans, la nau
|
||||
// ja oscil·la mentre s'aproxima i la transició és contínua.
|
||||
ship.oscillation_phase += delta_time;
|
||||
|
||||
const float INTERP_X = Easing::lerp(ship.initial_position.x, ship.target_position.x, EASED);
|
||||
const float INTERP_Y = Easing::lerp(ship.initial_position.y, ship.target_position.y, EASED);
|
||||
const float INTERP_Z = Easing::lerp(ship.initial_position.z, ship.target_position.z, EASED);
|
||||
|
||||
const float TWO_PI = 2.0F * Defaults::Math::PI;
|
||||
const float OFFSET_X = ship.amplitude_x *
|
||||
std::sin(TWO_PI * ship.frequency_x * ship.oscillation_phase);
|
||||
const float OFFSET_Y = ship.amplitude_y *
|
||||
std::sin((TWO_PI * ship.frequency_y * ship.oscillation_phase) + FLOAT_PHASE_OFFSET);
|
||||
|
||||
ship.current_position.x = INTERP_X + OFFSET_X;
|
||||
ship.current_position.y = INTERP_Y + OFFSET_Y;
|
||||
ship.current_position.z = INTERP_Z;
|
||||
ship.current_scale = Easing::lerp(ship.initial_scale, ship.target_scale, EASED);
|
||||
|
||||
if (ELAPSED >= ENTRY_DURATION) {
|
||||
ship.state = ShipState3D::FLOATING;
|
||||
ship.state_time = 0.0F;
|
||||
ship.oscillation_phase = 0.0F;
|
||||
// No resetegem oscillation_phase: així updateFloating continua
|
||||
// l'oscil·lació iniciada durant ENTERING sense salt.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user