From 6b36992119898d770c18b02dd431f074562d2525 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 23:09:40 +0300 Subject: [PATCH 1/3] make VCA animation line intensity multiplier implicit --- res/modules/internal/animation_codegen.lua | 17 ++++++++++++++--- src/engine/Time.hpp | 3 ++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index dc6a29f0e..97deab9df 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -15,7 +15,13 @@ local exclude_patters = { } -- TODO: replace with actual expression -> lua translator -local function process_expression(src, memoised) +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) + end + for i, pattern in ipairs(exclude_patters) do if src:find(pattern) then debug.print(exclude_patters) @@ -127,6 +133,11 @@ for _, name in ipairs(math_funcs) do env[name] = math[name] end +is_multiplier = { + [animation.CH_SCALE] = true, + [animation.CH_ZOOM] = true, +} + local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) local lines = lineset.lines local code = "" @@ -137,7 +148,7 @@ 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) .. ")" + process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")" elseif line.keys then local target_keysets = keysets[lineset.target_name] if not target_keysets then @@ -290,7 +301,7 @@ function internals.compile_animation_track(raw_track, track_name) code = memoised_code .. "\n" .. code end - local src = "return function(target, t, m)\n" + local src = "return function(target, t, intensity, m)\n m = m or 1\n" .. code .. "\nend" if animation.TRACE_CODEGEN then diff --git a/src/engine/Time.hpp b/src/engine/Time.hpp index 9f914b1fc..b335db313 100644 --- a/src/engine/Time.hpp +++ b/src/engine/Time.hpp @@ -6,12 +6,13 @@ class Time { uint64_t frame = 0; double lastTime = 0.0; double delta = 0.0; + double timeMultiplier = 1.0; public: Time() {} void update(double currentTime) { frame++; - delta = currentTime - lastTime; + delta = (currentTime - lastTime) * timeMultiplier; lastTime = currentTime; } From c3ca6be0565204a4b1d4d4b05d05adea2c2b97b3 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sat, 26 Sep 2026 23:13:54 +0300 Subject: [PATCH 2/3] add missing local --- res/modules/internal/animation_codegen.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 97deab9df..50ae8a5a0 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -133,7 +133,7 @@ for _, name in ipairs(math_funcs) do env[name] = math[name] end -is_multiplier = { +local is_multiplier = { [animation.CH_SCALE] = true, [animation.CH_ZOOM] = true, } From 0151fdfbf7922bf8040f5d42fef32d8dde6a35f5 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 27 Sep 2026 02:14:36 +0300 Subject: [PATCH 3/3] implement actual animation blending in core:animator --- res/modules/animation.lua | 3 +++ res/modules/internal/animation_codegen.lua | 9 +++++---- res/scripts/components/animator.lua | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index 411623364..1e19822a4 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -97,6 +97,9 @@ local PlayingTrack = { } function this.play(name, target) + if target and target.reset_pose then + target:reset_pose() + end local track = setmetatable({ name = name, target = target, diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 50ae8a5a0..a8fabab8e 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -194,7 +194,6 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) return code end - code = code .. "\n mat4.idt(dst)" if translation[1] or translation[2] or translation[3] then code = code .. "\n mat4.translate(dst, {" .. (translation[1] and ("l" .. translation[1]) or '0').. ", " .. @@ -226,7 +225,6 @@ end local function codegen_rig_target(raw_track, context) local code = "\n if target.set_matrix and target.index then\n" - code = code .. " local dst = DST\n" for bone, lineset in pairs(raw_track.linesets) do if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue @@ -234,10 +232,13 @@ local function codegen_rig_target(raw_track, context) local lineset_code = codegen_track( raw_track, lineset, context.memoised, context.keysets, true) - code = code .. "\n do" .. lineset_code .. "\n end\n" + code = code + .. string.format("\n local bone_index = target:index(%s)" + .. "\n local dst = target:get_matrix(bone_index)", string.escape(bone)) + .. "\n do" .. lineset_code .. "\n end\n" if lineset.target_type == "bone" then code = code .. - " target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n" + " target:set_matrix(bone_index, dst)\n" end ::continue:: end diff --git a/res/scripts/components/animator.lua b/res/scripts/components/animator.lua index 611ffa6f8..341f7cf11 100644 --- a/res/scripts/components/animator.lua +++ b/res/scripts/components/animator.lua @@ -38,6 +38,7 @@ function set_state(name, fade_time) end local function update(delta) + rig:reset_pose() for _, state in pairs(states) do state.timer = state.timer + delta @@ -51,7 +52,7 @@ local function update(delta) end state.track = state.track or animation.get_track(state.track_id) - if state.track and intensity > 0.0 then + if state.track then state.track.func( rig, state.timer % math.min(MAX_DURATION, state.track.duration),