From 0b52369ed9e6a3e9c7453292d388c12cdfb7778a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Tue, 6 Oct 2026 21:31:02 +0300 Subject: [PATCH] cleanup --- res/modules/internal/formats/vca.lua | 98 ++++++++++++++-------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/res/modules/internal/formats/vca.lua b/res/modules/internal/formats/vca.lua index c44d28904..26f4afa8d 100644 --- a/res/modules/internal/formats/vca.lua +++ b/res/modules/internal/formats/vca.lua @@ -62,6 +62,54 @@ local function parse_simple_frames(line, node) end end +local function parse_directive(node, raw_track) + local linesets = raw_track.linesets + local tag = node['#'] + if tag == "configure" then + parse_configure(raw_track, node) + return + elseif tag == "curve" then + raw_track.curves[node.name] = node + return + end + + local target_type = nil + if node.bone then + target_type = "bone" + elseif tag == "texture" then + target_type = "texture" + end + local target_name = node.bone or node.name or "" + local lineset = linesets[target_name] + if not lineset then + lineset = { + lines = {}, + target_type = target_type, + target_name = target_name + } + linesets[target_name] = lineset + end + + local channel = action_to_channel[tag] + if not channel then + error("unknown directive " .. tag:escape()) + end + local line = { + axis = node.by and ("xyz"):find(node.by) or "", + channel = channel, + period = node.period or animation.MAX_FRAMES + } + if node.func then + line.expression = node.func + elseif node.curve then + parse_curve(line, node) + else + parse_simple_frames(line, node) + end + + table.insert(lineset.lines, line) +end + local function parse_track(root) local raw_track = { duration = math.huge, @@ -69,56 +117,10 @@ local function parse_track(root) linesets = {}, curves = {}, } - local linesets = raw_track.linesets for i, node in ipairs(root) do - if type(node) == "string" then - goto continue + if type(node) == 'table' then + parse_directive(node, raw_track) end - local tag = node['#'] - if tag == "configure" then - parse_configure(raw_track, node) - goto continue - elseif tag == "curve" then - raw_track.curves[node.name] = node - goto continue - end - - local target_type = nil - if node.bone then - target_type = "bone" - elseif tag == "texture" then - target_type = "texture" - end - local target_name = node.bone or node.name or "" - local lineset = linesets[target_name] - if not lineset then - lineset = { - lines = {}, - target_type = target_type, - target_name = target_name - } - linesets[target_name] = lineset - end - - local channel = action_to_channel[tag] - if not channel then - error("unknown directive " .. tag:escape()) - end - local line = { - axis = node.by and ("xyz"):find(node.by) or "", - channel = channel, - period = node.period or animation.MAX_FRAMES - } - if node.func then - line.expression = node.func - elseif node.curve then - parse_curve(line, node) - else - parse_simple_frames(line, node) - end - - table.insert(lineset.lines, line) - ::continue:: end return raw_track end