mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
cleanup
This commit is contained in:
parent
d3de449b7b
commit
dd577dd080
1 changed files with 8 additions and 10 deletions
|
|
@ -15,18 +15,15 @@ local exclude_patters = {
|
|||
}
|
||||
|
||||
-- TODO: replace with actual expression -> lua translator
|
||||
local function process_expression(src, memoised, ismul, iscurve)
|
||||
if not iscurve then
|
||||
if ismul then
|
||||
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
||||
else
|
||||
src = string.format("(%s) * intensity", src)
|
||||
end
|
||||
local function process_expression(src, memoised, mode)
|
||||
if mode == 'mul' then
|
||||
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
||||
elseif mode == "add" then
|
||||
src = string.format("(%s) * intensity", src)
|
||||
end
|
||||
|
||||
for i, pattern in ipairs(exclude_patters) do
|
||||
if src:find(pattern) then
|
||||
debug.print(exclude_patters)
|
||||
error("invalid syntax "..string.escape(src))
|
||||
end
|
||||
end
|
||||
|
|
@ -150,7 +147,8 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
for i, line in ipairs(lines) do
|
||||
if line.expression then
|
||||
code = code .. "\n local l" .. i .. " = (" ..
|
||||
process_expression(line.expression, memoised, is_multiplier[line.channel]) .. ")"
|
||||
process_expression(line.expression, memoised,
|
||||
is_multiplier[line.channel] and "mul" or "add") .. ")"
|
||||
elseif line.keys then
|
||||
local target_keysets = keysets[lineset.target_name]
|
||||
if not target_keysets then
|
||||
|
|
@ -286,7 +284,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
|||
for name, curve in pairs(raw_track.curves) do
|
||||
context.curves[name] = load(string.format(
|
||||
"return function(kl, kr, t) return %s end",
|
||||
process_expression(curve.func, context.memoised, false, true)
|
||||
process_expression(curve.func, context.memoised, "curve")
|
||||
), "<curve>", "t", env)()
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue