feat: custom curves

This commit is contained in:
MihailRis 2026-09-09 19:26:17 +03:00
parent bb6bd27b94
commit 3ed80d0c95
2 changed files with 64 additions and 23 deletions

View file

@ -1,7 +1,6 @@
local internals = __vc_internals
local DEFAULT_FPS = 60
local INT_BEZIER = animation.INT_BEZIER
local action_to_channel = {
move = animation.CH_TRANSLATE,
@ -29,14 +28,19 @@ local function parse_configure(raw_track, node)
end
local function parse_curve(line, node)
line.interp = curve_to_interp[node.curve]
if node.curve:starts_with(".") then
line.interp = animation.INT_CUSTOM
line.curve_func = node.curve:sub(2)
else
line.interp = curve_to_interp[node.curve]
end
line.keys = {}
for j, key_node in ipairs(node) do
local keyframe = {
frame = tonumber(key_node.frame),
value = tonumber(key_node.value),
}
if line.interp == INT_BEZIER then
if line.interp == animation.INT_BEZIER then
keyframe.lx = tonumber(key_node.lx)
keyframe.ly = tonumber(key_node.ly)
keyframe.rx = tonumber(key_node.rx)
@ -51,6 +55,7 @@ local function parse_track(root)
duration = math.huge,
fps = DEFAULT_FPS,
linesets = {},
curves = {},
}
local linesets = raw_track.linesets
for i, node in ipairs(root) do
@ -61,6 +66,9 @@ local function parse_track(root)
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