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
This commit is contained in:
parent
30600a064b
commit
94b74cff96
1 changed files with 10 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue