mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-23 19:09:45 +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
|
||||||
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 function parse_track(root)
|
||||||
local raw_track = {
|
local raw_track = {
|
||||||
duration = math.huge,
|
duration = math.huge,
|
||||||
|
|
@ -69,56 +117,10 @@ local function parse_track(root)
|
||||||
linesets = {},
|
linesets = {},
|
||||||
curves = {},
|
curves = {},
|
||||||
}
|
}
|
||||||
local linesets = raw_track.linesets
|
|
||||||
for i, node in ipairs(root) do
|
for i, node in ipairs(root) do
|
||||||
if type(node) == "string" then
|
if type(node) == 'table' then
|
||||||
goto continue
|
parse_directive(node, raw_track)
|
||||||
end
|
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
|
end
|
||||||
return raw_track
|
return raw_track
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue