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
master
Quinten Kock 11 months ago committed by Vlad Zahorodnii
parent 30600a064b
commit 94b74cff96

@ -142,6 +142,16 @@ void SpringMotion::advance(std::chrono::milliseconds delta)
return; 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 // 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. // the next samples will be linearly interpolated to get current position and velocity.
const qreal steps = (delta.count() / 1000.0) / m_timestep; const qreal steps = (delta.count() / 1000.0) / m_timestep;

Loading…
Cancel
Save