mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-21 01:49:44 +00:00
cleanup
This commit is contained in:
parent
d4d6235b2b
commit
0b52369ed9
1 changed files with 50 additions and 48 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue