From 1f2e938d83712a69da27aede140038fa64d01e4f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 7 Oct 2026 22:32:11 +0300 Subject: [PATCH] feat: control flag visible for whole skeleton support --- res/modules/internal/animation_codegen.lua | 27 +++++++++++++++------- res/modules/internal/formats/vca.lua | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 824070a18..169b08163 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -162,13 +162,18 @@ local function codegen_line(raw_track, lineset, line, index, keysets) end end -local function codegen_track(raw_track, lineset, keysets, use_tsf) +local function codegen_track(raw_track, lineset, keysets, use_tsf, target_type) + if lineset.target_type ~= target_type then + return "" + end + local lines = lineset.lines local code = "" local has_tsf = false local translation = {false, false, false} local rotation = {false, false, false} local scale = {false, false, false} + for i, line in ipairs(lines) do code = code .. string.format("\n local l%d = ", i) .. codegen_line(raw_track, lineset, line, i, keysets) @@ -189,7 +194,11 @@ local function codegen_track(raw_track, lineset, keysets, use_tsf) lineset.target_name:escape(), i) elseif line.channel == animation.CH_CONTROL then if lineset.flag == "visible" then - code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + if target_type == "bone" then + code = code .. string.format("\n target:set_visible(bone_index, l%d)", i) + else + code = code .. string.format("\n target:set_visible(l%d)", i) + end end end end @@ -233,7 +242,7 @@ local function codegen_rig_target(raw_track, context) if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then goto continue end - local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, true, "bone") code = code .. string.format("\n local bone_index = target:index(%s)", string.escape(bone)) if context.has_tsf then @@ -251,16 +260,18 @@ local function codegen_rig_target(raw_track, context) end local function codegen_object_target(raw_track, context) - local code = "\n if target.set_pos then\n" - code = code .. " local dst = mat4.idt()\n" + local code = " local dst = mat4.idt()\n" local lineset = raw_track.linesets[""] if not lineset then return "" end local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) code = code .. "\n do" .. lineset_code .. "\n end\n" - .. " set_matrix(target, dst)\n" - return code .. " end" + + if context.has_tsf then + code = code .. " set_matrix(target, dst)\n" + end + return code end local function codegen_camera_target(raw_track, context) @@ -270,7 +281,7 @@ local function codegen_camera_target(raw_track, context) if not lineset then return "" end - local lineset_code = codegen_track(raw_track, lineset, context.keysets, false) + local lineset_code = codegen_track(raw_track, lineset, context.keysets, false, "camera") code = code .. "\n do" .. lineset_code .. "\n end\n" .. " target:set_zoom(zoom)\n" return code .. " end" diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index d87f5716c..9ce4b6230 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -88,6 +88,8 @@ local function parse_directive(node, raw_track) local target_type = nil if node.bone then target_type = "bone" + elseif node.zoom then + target_type = "camera" elseif tag == "texture" then target_type = "texture" end