mirror of
https://github.com/Winded/StopMotionHelper.git
synced 2025-03-04 03:13:33 -05:00
Further playback performance optimization - now playback doesn't call load functions every frame, which helps with performance on maps that are more resource intensive than gm_construct
This commit is contained in:
parent
97d8c95a2e
commit
7218a561e2
@ -104,6 +104,7 @@ function MGR.StartPlayback(player, startFrame, endFrame, playbackRate, settings)
|
||||
EndFrame = endFrame,
|
||||
PlaybackRate = playbackRate,
|
||||
CurrentFrame = startFrame,
|
||||
PrevFrame = startFrame - 1,
|
||||
Timer = 0,
|
||||
Settings = settings,
|
||||
}
|
||||
@ -117,16 +118,24 @@ end
|
||||
hook.Add("Think", "SMHPlaybackManagerThink", function()
|
||||
for player, playback in pairs(ActivePlaybacks) do
|
||||
if not playback.Settings.SmoothPlayback or playback.Settings.TweenDisable then
|
||||
|
||||
playback.Timer = playback.Timer + FrameTime()
|
||||
local timePerFrame = 1 / playback.PlaybackRate
|
||||
|
||||
if playback.Timer >= timePerFrame then
|
||||
|
||||
playback.CurrentFrame = math.floor(playback.Timer / timePerFrame) + playback.StartFrame
|
||||
if playback.CurrentFrame > playback.EndFrame then
|
||||
playback.CurrentFrame = 0
|
||||
playback.StartFrame = 0
|
||||
playback.Timer = 0
|
||||
end
|
||||
MGR.SetFrame(player, playback.CurrentFrame, playback.Settings)
|
||||
|
||||
if playback.CurrentFrame ~= playback.PrevFrame then
|
||||
playback.PrevFrame = playback.CurrentFrame
|
||||
MGR.SetFrame(player, playback.CurrentFrame, playback.Settings)
|
||||
end
|
||||
|
||||
end
|
||||
else
|
||||
PlaybackSmooth(player, playback, playback.Settings)
|
||||
|
Loading…
Reference in New Issue
Block a user