Files
HellionChat/HellionChat/Util/FrameLerp.cs
T
JonKazama-Hellion 0bfe3a62cb feat: add FrameLerp helper and per-tab hover-alpha fields
FrameLerp.Smooth is the framerate-independent smoothing path -- a
Umbra-style v += (target - v) * factor with the factor clamped to 1
so a stalled frame snaps cleanly instead of overshooting. Tab gets
two NonSerialized fields (_hoverAlpha, _cardHoverAlpha) that the
v1.5.4 render loops drive.
2026-05-20 13:26:16 +02:00

18 lines
725 B
C#

namespace HellionChat.Util;
// Framerate-independent smoothing for per-frame hover and motion
// values. Pattern anchor: Umbra Toolbar.Autohide.cs:55
// (`v += (target - v) * deltaTime`). The Math.Min(1f, speed*dt)
// clamp is a deliberate HellionChat addition -- on Wine/DXVK a
// stalled frame can push deltaTime well over 16ms, which would
// otherwise let the raw factor exceed 1.0 and overshoot the target.
// Clamping makes a stalled frame land exactly on target instead.
internal static class FrameLerp
{
public static float Smooth(float current, float target, float speed, float deltaTime)
{
var factor = Math.Min(1f, speed * deltaTime);
return current + (target - current) * factor;
}
}