From e485aedc8ee41184bf6dd229945601ccae83f4f4 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 25 Sep 2026 23:56:32 +0300 Subject: [PATCH] add 'period' keyframes-based line parameter --- res/modules/animation.lua | 3 ++- res/modules/internal/animation_codegen.lua | 12 ++++++------ res/modules/internal/formats/vca.lua | 4 +++- res/scripts/components/animator.lua | 2 +- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index cbed8a941..35a77b78e 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -48,8 +48,9 @@ local this = { INT_LINEAR = 2, INT_BEZIER = 3, INT_CUSTOM = 4, + ALMOST_HUGE = 1e9, - TRACE_CODEGEN = false, + TRACE_CODEGEN = true, maths = { bezier_interpolation = bezier_interpolation diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 66db0bed4..316dd22b3 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -150,16 +150,16 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) local valueat = string.format("curves[%s]", string.escape(line.curve_func)) code = code .. string.format( - "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s, %s)", - i, lineset.target_name, i, raw_track.fps, valueat) + "\n local l%d = value_at_custom(keysets['%s'][%d], t * %s %% %s, %s)", + i, lineset.target_name, i, raw_track.fps, line.period, valueat) elseif line.channel == animation.CH_TEXTURE then code = code .. string.format( - "\n local l%d = string_at(keysets['%s'][%d], t * %s)", - i, lineset.target_name, i, raw_track.fps) + "\n local l%d = string_at(keysets['%s'][%d], t * %s %% %s)", + i, lineset.target_name, i, raw_track.fps, line.period) else code = code .. string.format( - "\n local l%d = value_at(keysets['%s'][%d], t * %s, %s)", - i, lineset.target_name, i, raw_track.fps, line.interp) + "\n local l%d = value_at(keysets['%s'][%d], t * %s %% %s, %s)", + i, lineset.target_name, i, raw_track.fps, line.period, line.interp) end end diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index e22e220eb..99f03f15b 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -106,8 +106,10 @@ local function parse_track(root) end local line = { axis = node.by and ("xyz"):find(node.by) or "", - channel = channel + channel = channel, + period = node.period or animation.ALMOST_HUGE } + debug.print(animation.ALMOST_HUGE) if node.func then line.expression = node.func elseif node.curve then diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 5bd3ef4fa..9fc5735fe 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -1,4 +1,4 @@ -local ALMOST_HUGE = 1e9 +local ALMOST_HUGE = animation.ALMOST_HUGE local rig = entity.skeleton