From 94b74cff960566d42813ecf4847637c2283a6fac Mon Sep 17 00:00:00 2001 From: Quinten Kock Date: Mon, 16 Oct 2023 17:07:11 +0000 Subject: [PATCH] plugins/slide: add special case for instant animations In springmotion.cpp for the slide plugin, there are issues when animations are disabled, namely a black screen flicker. The flicker is caused by float under/overflow (div-by-0 -> infinity). This commit fixes that by special-casing an infinite spring constant, so that the animation immediately jumps to the anchor. BUG: 472901 --- src/plugins/slide/springmotion.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/plugins/slide/springmotion.cpp b/src/plugins/slide/springmotion.cpp index 5007d29ff2..5795484a54 100644 --- a/src/plugins/slide/springmotion.cpp +++ b/src/plugins/slide/springmotion.cpp @@ -142,6 +142,16 @@ void SpringMotion::advance(std::chrono::milliseconds delta) return; } + // If m_springConstant is infinite, we have an animation time factor of zero. + // As such, we should advance to the target immediately. + if (std::isinf(m_springConstant)) { + m_next = State{ + .position = m_anchor, + .velocity = 0.0, + }; + return; + } + // If the delta interval is not multiple of m_timestep precisely, the previous and // the next samples will be linearly interpolated to get current position and velocity. const qreal steps = (delta.count() / 1000.0) / m_timestep;