From: Steinar H. Gunderson Date: Sat, 14 Mar 2020 23:47:47 +0000 (+0100) Subject: Only bother going into an ease if there is an actual speed change. X-Git-Tag: 1.9.2~10 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=331e427e3d4cfc129b15f183dcfefe7f182a4e06;p=nageru Only bother going into an ease if there is an actual speed change. --- diff --git a/futatabi/player.cpp b/futatabi/player.cpp index 982091d..c5581b4 100644 --- a/futatabi/player.cpp +++ b/futatabi/player.cpp @@ -154,6 +154,10 @@ public: void change_master_speed(double new_master_speed, Instant now); + float in_master_speed(float speed) const { + return (!in_easing && fabs(master_speed - speed) < 1e-6); + } + // Instead of changing the speed instantly, change it over the course of // about 200 ms. This is a simple linear ramp; I tried various forms of // Bézier curves for more elegant/dramatic changing, but it seemed linear @@ -334,7 +338,7 @@ void Player::play_playlist_once() next_frame_start = instant.wallclock_time; float new_master_speed = change_master_speed.exchange(0.0f / 0.0f); - if (!std::isnan(new_master_speed)) { + if (!std::isnan(new_master_speed) && !timeline.in_master_speed(new_master_speed)) { timeline.start_easing(new_master_speed, instant); }