mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
commit
00425c4175
3 changed files with 19 additions and 14 deletions
|
|
@ -21,8 +21,10 @@ local function bezier_interpolation(k0, k1, t)
|
||||||
local u = t
|
local u = t
|
||||||
|
|
||||||
for i=1,8 do
|
for i=1,8 do
|
||||||
local x = bezier(k0.frame, k0.rx, k1.lx, k1.frame, u)
|
local x = bezier(
|
||||||
local dx = bezier_derivative(k0.frame, k0.rx, k1.lx, k1.frame, u)
|
k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u)
|
||||||
|
local dx = bezier_derivative(
|
||||||
|
k0.frame, k0.rx + k0.frame, k1.lx + k1.frame, k1.frame, u)
|
||||||
|
|
||||||
if math.abs(dx) < 1e-8 then
|
if math.abs(dx) < 1e-8 then
|
||||||
break
|
break
|
||||||
|
|
@ -34,7 +36,7 @@ local function bezier_interpolation(k0, k1, t)
|
||||||
if u > 1 then u = 1 end
|
if u > 1 then u = 1 end
|
||||||
end
|
end
|
||||||
|
|
||||||
return bezier(k0.value, k0.ry, k1.ly, k1.value, u)
|
return bezier(k0.value, k0.ry + k0.value, k1.ly + k1.value, k1.value, u)
|
||||||
end
|
end
|
||||||
|
|
||||||
local this = {
|
local this = {
|
||||||
|
|
@ -133,6 +135,9 @@ function internals.on_animation_frame()
|
||||||
if track_info.__timer > track.duration then
|
if track_info.__timer > track.duration then
|
||||||
table.remove(playing_tracks, i)
|
table.remove(playing_tracks, i)
|
||||||
else
|
else
|
||||||
|
if track_info.target.reset_pose then
|
||||||
|
track_info.target:reset_pose()
|
||||||
|
end
|
||||||
track.func(track_info.target, track_info.__timer)
|
track.func(track_info.target, track_info.__timer)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,16 +15,15 @@ local exclude_patters = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- TODO: replace with actual expression -> lua translator
|
-- TODO: replace with actual expression -> lua translator
|
||||||
local function process_expression(src, memoised, ismul)
|
local function process_expression(src, memoised, mode)
|
||||||
if ismul then
|
if mode == 'mul' then
|
||||||
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
src = string.format("(%s) * intensity + (1.0 - intensity)", src)
|
||||||
else
|
elseif mode == "add" then
|
||||||
src = string.format("(%s) * intensity", src)
|
src = string.format("(%s) * intensity", src)
|
||||||
end
|
end
|
||||||
|
|
||||||
for i, pattern in ipairs(exclude_patters) do
|
for i, pattern in ipairs(exclude_patters) do
|
||||||
if src:find(pattern) then
|
if src:find(pattern) then
|
||||||
debug.print(exclude_patters)
|
|
||||||
error("invalid syntax "..string.escape(src))
|
error("invalid syntax "..string.escape(src))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -148,7 +147,8 @@ 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, is_multiplier[line.channel]) .. ")"
|
process_expression(line.expression, memoised,
|
||||||
|
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]
|
||||||
if not target_keysets then
|
if not target_keysets then
|
||||||
|
|
@ -247,7 +247,7 @@ end
|
||||||
|
|
||||||
local function codegen_object_target(raw_track, context)
|
local function codegen_object_target(raw_track, context)
|
||||||
local code = "\n if target.set_pos then\n"
|
local code = "\n if target.set_pos then\n"
|
||||||
code = code .. " local dst = DST\n"
|
code = code .. " local dst = mat4.idt()\n"
|
||||||
local lineset = raw_track.linesets[""]
|
local lineset = raw_track.linesets[""]
|
||||||
if not lineset then
|
if not lineset then
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -284,7 +284,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
||||||
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)
|
process_expression(curve.func, context.memoised, "curve")
|
||||||
), "<curve>", "t", env)()
|
), "<curve>", "t", env)()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ function internals.compile_animation_track(raw_track, track_name)
|
||||||
code = memoised_code .. "\n" .. code
|
code = memoised_code .. "\n" .. code
|
||||||
end
|
end
|
||||||
|
|
||||||
local src = "return function(target, t, intensity, m)\n m = m or 1\n"
|
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
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ function create_state(name, track_id, max_intencity)
|
||||||
fade_time = 0.0,
|
fade_time = 0.0,
|
||||||
fade_timer = 0.0,
|
fade_timer = 0.0,
|
||||||
fade_in = false,
|
fade_in = false,
|
||||||
max_intencity = max_intencity,
|
max_intencity = max_intencity or 1.0,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -25,14 +25,14 @@ function set_state(name, fade_time)
|
||||||
end
|
end
|
||||||
if current_state then
|
if current_state then
|
||||||
current_state.fade_in = false
|
current_state.fade_in = false
|
||||||
current_state.fade_time = fade_time
|
current_state.fade_time = fade_time or 0.0
|
||||||
current_state.fade_timer = 0.0
|
current_state.fade_timer = 0.0
|
||||||
end
|
end
|
||||||
current_state = state
|
current_state = state
|
||||||
if state then
|
if state then
|
||||||
state.timer = 0.0
|
state.timer = 0.0
|
||||||
state.fade_in = true
|
state.fade_in = true
|
||||||
state.fade_time = fade_time
|
state.fade_time = fade_time or 0.0
|
||||||
state.fade_timer = 0.0
|
state.fade_timer = 0.0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue