remove unused feature

This commit is contained in:
MihailRis 2026-10-07 18:20:51 +03:00
parent 0b52369ed9
commit fdd62e2e19

View file

@ -15,7 +15,7 @@ local exclude_patters = {
} }
-- TODO: replace with actual expression -> lua translator -- TODO: replace with actual expression -> lua translator
local function process_expression(src, memoised, mode) local function process_expression(src, mode)
if mode == 'mul' then if mode == 'mul' then
src = string.format("(%s) * intensity + (1.0 - intensity)", src) src = string.format("(%s) * intensity + (1.0 - intensity)", src)
elseif mode == "add" then elseif mode == "add" then
@ -30,7 +30,6 @@ local function process_expression(src, memoised, mode)
for i, pattern in ipairs(patterns) do for i, pattern in ipairs(patterns) do
local pattern_safe = string.pattern_safe(pattern.pattern) local pattern_safe = string.pattern_safe(pattern.pattern)
if src:find(pattern_safe) then if src:find(pattern_safe) then
memoised[pattern.name] = pattern.pattern
src = src:gsub(pattern_safe, pattern.name) src = src:gsub(pattern_safe, pattern.name)
end end
end end
@ -137,7 +136,7 @@ local is_multiplier = {
[animation.CH_ZOOM] = true, [animation.CH_ZOOM] = true,
} }
local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf) local function codegen_track(raw_track, lineset, keysets, use_tsf)
local lines = lineset.lines local lines = lineset.lines
local code = "" local code = ""
local has_tsf = false local has_tsf = false
@ -147,7 +146,7 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
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 .. " = (" ..
process_expression(line.expression, memoised, process_expression(line.expression,
is_multiplier[line.channel] and "mul" or "add") .. ")" is_multiplier[line.channel] and "mul" or "add") .. ")"
elseif line.keys then elseif line.keys then
local target_keysets = keysets[lineset.target_name] local target_keysets = keysets[lineset.target_name]
@ -229,8 +228,7 @@ local function codegen_rig_target(raw_track, context)
if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then
goto continue goto continue
end end
local lineset_code = codegen_track( local lineset_code = codegen_track(raw_track, lineset, context.keysets, true)
raw_track, lineset, context.memoised, context.keysets, true)
code = code code = code
.. string.format("\n local bone_index = target:index(%s)" .. string.format("\n local bone_index = target:index(%s)"
@ -252,8 +250,7 @@ local function codegen_object_target(raw_track, context)
if not lineset then if not lineset then
return "" return ""
end end
local lineset_code = codegen_track( local lineset_code = codegen_track(raw_track, lineset, context.keysets, true)
raw_track, lineset, context.memoised, context.keysets, true)
code = code .. "\n do" .. lineset_code .. "\n end\n" code = code .. "\n do" .. lineset_code .. "\n end\n"
.. " set_matrix(target, dst)\n" .. " set_matrix(target, dst)\n"
return code .. " end" return code .. " end"
@ -266,8 +263,7 @@ local function codegen_camera_target(raw_track, context)
if not lineset then if not lineset then
return "" return ""
end end
local lineset_code = codegen_track( local lineset_code = codegen_track(raw_track, lineset, context.keysets, false)
raw_track, lineset, context.memoised, context.keysets, false)
code = code .. "\n do" .. lineset_code .. "\n end\n" code = code .. "\n do" .. lineset_code .. "\n end\n"
.. " target:set_zoom(zoom)\n" .. " target:set_zoom(zoom)\n"
return code .. " end" return code .. " end"
@ -277,14 +273,13 @@ end
function internals.compile_animation_track(raw_track, track_name) function internals.compile_animation_track(raw_track, track_name)
local code = "" local code = ""
local context = { local context = {
memoised = {},
keysets = {}, keysets = {},
curves = {}, curves = {},
} }
for name, curve in pairs(raw_track.curves) do for name, curve in pairs(raw_track.curves) do
context.curves[name] = load(string.format( context.curves[name] = load(string.format(
"return function(kl, kr, t) return %s end", "return function(kl, kr, t) return %s end",
process_expression(curve.func, context.memoised, "curve") process_expression(curve.func, "curve")
), "<curve>", "t", env)() ), "<curve>", "t", env)()
end end
@ -292,17 +287,8 @@ function internals.compile_animation_track(raw_track, track_name)
code = code .. codegen_object_target(raw_track, context) code = code .. codegen_object_target(raw_track, context)
code = code .. codegen_camera_target(raw_track, context) code = code .. codegen_camera_target(raw_track, context)
local memoised_code = "" local src = "return function(target, t, intensity, m)\n"
for name, expression in pairs(context.memoised) do .. "m = m or 1\n intensity = intensity or 1.0\n"
memoised_code = memoised_code .. "\n local " .. name .. " = "
.. expression
end
if #memoised_code > 0 then
code = memoised_code .. "\n" .. code
end
local src = "return function(target, t, intensity, m)\n m = m or 1\n intensity = intensity or 1.0\n"
.. code .. "\nend" .. code .. "\nend"
if animation.TRACE_CODEGEN then if animation.TRACE_CODEGEN then