Minor simplification of animation rate adjustment
This commit is contained in:
parent
7f50df6a2f
commit
f9115751b4
|
@ -25,11 +25,9 @@ function View:move_towards(t, k, dest, rate)
|
||||||
t[k] = dest
|
t[k] = dest
|
||||||
else
|
else
|
||||||
rate = rate or 0.5
|
rate = rate or 0.5
|
||||||
if config.fps ~= 60 then
|
if config.fps ~= 60 or config.animation_rate ~= 1 then
|
||||||
local xrate = common.clamp(rate, 1e-8, 1 - 1e-8)
|
|
||||||
local alpha = math.log(1 - xrate) * config.animation_rate
|
|
||||||
local dt = 60 / config.fps
|
local dt = 60 / config.fps
|
||||||
rate = 1 - math.exp(alpha * dt)
|
rate = 1 - common.clamp(1 - rate, 1e-8, 1 - 1e-8)^(config.animation_rate * dt)
|
||||||
end
|
end
|
||||||
t[k] = common.lerp(val, dest, rate)
|
t[k] = common.lerp(val, dest, rate)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue