From ea63d29221903a948ed84b2c982e5a99e296037e Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:39:46 +0300 Subject: [PATCH 1/5] fix custom curves --- res/modules/internal/animation_codegen.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index a8fabab8e..004cdc4a3 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,11 +15,13 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised, ismul) - if ismul then - src = string.format("(%s) * intensity + (1.0 - intensity)", src) - else - src = string.format("(%s) * intensity", src) +local function process_expression(src, memoised, ismul, iscurve) + if not iscurve then + if ismul then + src = string.format("(%s) * intensity + (1.0 - intensity)", src) + else + src = string.format("(%s) * intensity", src) + end end for i, pattern in ipairs(exclude_patters) do @@ -284,7 +286,7 @@ function internals.compile_animation_track(raw_track, track_name) for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( "return function(kl, kr, t) return %s end", - process_expression(curve.func, context.memoised) + process_expression(curve.func, context.memoised, false, true) ), "", "t", env)() end From d3de449b7b0f1c777dd5cf714967d9d976461a70 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:41:02 +0300 Subject: [PATCH 2/5] fix absolute bezier keyframes --- res/modules/animation.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 1e19822a4..d08b1bc18 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -21,8 +21,10 @@ local function bezier_interpolation(k0, k1, t) local u = t for i=1,8 do - local x = bezier(k0.frame, k0.rx, k1.lx, k1.frame, u) - local dx = bezier_derivative(k0.frame, k0.rx, k1.lx, k1.frame, u) + local x = bezier( + k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u) + local dx = bezier_derivative( + k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u) if math.abs(dx) < 1e-8 then break From dd577dd08059b2a4fa32bf1d1505916fa47d3ada Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:44:19 +0300 Subject: [PATCH 3/5] cleanup --- res/modules/internal/animation_codegen.lua | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 004cdc4a3..0b96dc15b 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,18 +15,15 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised, ismul, iscurve) - if not iscurve then - if ismul then - src = string.format("(%s) * intensity + (1.0 - intensity)", src) - else - src = string.format("(%s) * intensity", src) - end +local function process_expression(src, memoised, mode) + if mode == 'mul' then + src = string.format("(%s) * intensity + (1.0 - intensity)", src) + elseif mode == "add" then + src = string.format("(%s) * intensity", src) end for i, pattern in ipairs(exclude_patters) do if src:find(pattern) then - debug.print(exclude_patters) error("invalid syntax "..string.escape(src)) end end @@ -150,7 +147,8 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) for i, line in ipairs(lines) do if line.expression then code = code .. "\n local l" .. i .. " = (" .. - process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")" + process_expression(line.expression, memoised, + is_multiplier[line.channel] and "mul" or "add") .. ")" elseif line.keys then local target_keysets = keysets[lineset.target_name] if not target_keysets then @@ -286,7 +284,7 @@ function internals.compile_animation_track(raw_track, track_name) for name, curve in pairs(raw_track.curves) do context.curves[name] = load(string.format( "return function(kl, kr, t) return %s end", - process_expression(curve.func, context.memoised, false, true) + process_expression(curve.func, context.memoised, "curve") ), "", "t", env)() end From e4eae0416e2971be99fb4af2379e070bf50eace0 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 29 Sep 2026 18:59:28 +0300 Subject: [PATCH 4/5] fix the --- res/modules/animation.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index d08b1bc18..817b1611f 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -36,7 +36,7 @@ local function bezier_interpolation(k0, k1, t) if u > 1 then u = 1 end end - return bezier(k0.value, k0.ry, k1.ly, k1.value, u) + return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u) end local this = { From ef4207aed092bee8a0f1a658fadcae84d1324d51 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Fri, 2 Oct 2026 17:44:48 +0300 Subject: [PATCH 5/5] fixes --- res/modules/animation.lua | 3 +++ res/modules/internal/animation_codegen.lua | 4 ++-- res/scripts/components/animator.lua | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 817b1611f..0c7bb7741 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -135,6 +135,9 @@ function internals.on_animation_frame() if track_info.__timer > track.duration then table.remove(playing_tracks, i) else + if track_info.target.reset_pose then + track_info.target:reset_pose() + end track.func(track_info.target, track_info.__timer) end end diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 0b96dc15b..525240f66 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -247,7 +247,7 @@ end local function codegen_object_target(raw_track, context) local code = "\n if target.set_pos then\n" - code = code .. " local dst = DST\n" + code = code .. " local dst = mat4.idt()\n" local lineset = raw_track.linesets[""] if not lineset then return "" @@ -302,7 +302,7 @@ function internals.compile_animation_track(raw_track, track_name) code = memoised_code .. "\n" .. code end - local src = "return function(target, t, intensity, m)\n m = m or 1\n" + local src = "return function(target, t, intensity, m)\n m = m or 1\n intensity = intensity or 1.0\n" .. code .. "\nend" if animation.TRACE_CODEGEN then diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 341f7cf11..e5f959df7 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -12,7 +12,7 @@ function create_state(name, track_id, max_intencity) fade_time = 0.0, fade_timer = 0.0, fade_in = false, - max_intencity = max_intencity, + max_intencity = max_intencity or 1.0, } end @@ -25,14 +25,14 @@ function set_state(name, fade_time) end if current_state then current_state.fade_in = false - current_state.fade_time = fade_time + current_state.fade_time = fade_time or 0.0 current_state.fade_timer = 0.0 end current_state = state if state then state.timer = 0.0 state.fade_in = true - state.fade_time = fade_time + state.fade_time = fade_time or 0.0 state.fade_timer = 0.0 end end