add scale to vca

This commit is contained in:
MihailRis 2026-09-03 20:46:59 +03:00
parent 4370eedc0a
commit bbdf31fc19
2 changed files with 19 additions and 9 deletions

View file

@ -3,6 +3,7 @@ local internals = __vc_internals
local this = { local this = {
CH_TRANSLATE = 1, CH_TRANSLATE = 1,
CH_ROTATE = 2, CH_ROTATE = 2,
CH_SCALE = 3,
INT_CONST = 1, INT_CONST = 1,
INT_LINEAR = 2, INT_LINEAR = 2,
@ -13,8 +14,6 @@ local this = {
local INT_CONST = this.INT_CONST local INT_CONST = this.INT_CONST
local INT_BEZIER = this.INT_BEZIER local INT_BEZIER = this.INT_BEZIER
local CH_TRANSLATE = this.CH_TRANSLATE
local CH_ROTATE = this.CH_ROTATE
local function bezier(a, b, c, d, u) local function bezier(a, b, c, d, u)
local s = 1 - u local s = 1 - u
@ -119,6 +118,7 @@ local function codegen_track(raw_track, lines, memoised, keysets)
local code = "" local code = ""
local translation = {false, false, false} local translation = {false, false, false}
local rotation = {false, false, false} local rotation = {false, false, false}
local scale = {false, false, false}
for i, line in ipairs(lines) do for i, line in ipairs(lines) do
if line.expression then if line.expression then
code = code .. "\n local l" .. i .. " = (" .. code = code .. "\n local l" .. i .. " = (" ..
@ -130,10 +130,12 @@ local function codegen_track(raw_track, lines, memoised, keysets)
i, i, raw_track.fps, line.interp) i, i, raw_track.fps, line.interp)
end end
if line.channel == CH_TRANSLATE then if line.channel == this.CH_TRANSLATE then
translation[line.axis] = i translation[line.axis] = i
elseif line.channel == CH_ROTATE then elseif line.channel == this.CH_ROTATE then
rotation[line.axis] = i rotation[line.axis] = i
elseif line.channel == this.CH_SCALE then
scale[line.axis] = i
end end
end end
@ -153,6 +155,13 @@ local function codegen_track(raw_track, lines, memoised, keysets)
end end
end end
if scale[1] or scale[2] or scale[3] then
code = code .. "\n mat4.scale(dst, {" ..
(scale[1] and ("l" .. scale[1]) or '1').. ", " ..
(scale[2] and ("l" .. scale[2]) or '1').. ", " ..
(scale[3] and ("l" .. scale[3]) or '1').. "}, dst)"
end
return code return code
end end

View file

@ -5,7 +5,8 @@ local INT_BEZIER = animation.INT_BEZIER
local action_to_channel = { local action_to_channel = {
move = animation.CH_TRANSLATE, move = animation.CH_TRANSLATE,
rotate = animation.CH_ROTATE rotate = animation.CH_ROTATE,
scale = animation.CH_SCALE,
} }
local curve_to_interp = { local curve_to_interp = {
@ -60,12 +61,11 @@ local function parse_track(root)
goto continue goto continue
end end
local bone = node.bone local target_name = node.bone or ""
local lineset = linesets[target_name]
local lineset = linesets[bone]
if not lineset then if not lineset then
lineset = {lines = {}} lineset = {lines = {}}
linesets[bone] = lineset linesets[target_name] = lineset
end end
local line = { local line = {
@ -83,6 +83,7 @@ local function parse_track(root)
table.insert(lineset.lines, line) table.insert(lineset.lines, line)
::continue:: ::continue::
end end
debug.print(raw_track)
return raw_track return raw_track
end end