Skip to content

Commit

Permalink
Added dt adjusted lerp
Browse files Browse the repository at this point in the history
  • Loading branch information
britzl authored Nov 3, 2018
1 parent a913373 commit a066423
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ludobits/m/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,13 @@ function M.clamp(value, min, max)
return value
end

-- http://www.rorydriscoll.com/2016/03/07/frame-rate-independent-damping-using-lerp/
-- return vmath.lerp(1 - math.pow(t, dt), v1, v2)
-- https://www.gamasutra.com/blogs/ScottLembcke/20180404/316046/Improved_Lerp_Smoothing.php
local UPDATE_FREQUENCY = tonumber(sys.get_config("display.update_frequency")) or 60
function M.lerp(t, dt, v1, v2)
local rate = UPDATE_FREQUENCY * math.log10(1 - t)
return vmath.lerp(1 - math.pow(10, rate * dt), v1, v2)
end

return M

0 comments on commit a066423

Please sign in to comment.