mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
implement actual animation blending in core:animator
This commit is contained in:
parent
c3ca6be056
commit
0151fdfbf7
3 changed files with 10 additions and 5 deletions
|
|
@ -97,6 +97,9 @@ local PlayingTrack = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function this.play(name, target)
|
function this.play(name, target)
|
||||||
|
if target and target.reset_pose then
|
||||||
|
target:reset_pose()
|
||||||
|
end
|
||||||
local track = setmetatable({
|
local track = setmetatable({
|
||||||
name = name,
|
name = name,
|
||||||
target = target,
|
target = target,
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,6 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
||||||
return code
|
return code
|
||||||
end
|
end
|
||||||
|
|
||||||
code = code .. "\n mat4.idt(dst)"
|
|
||||||
if translation[1] or translation[2] or translation[3] then
|
if translation[1] or translation[2] or translation[3] then
|
||||||
code = code .. "\n mat4.translate(dst, {" ..
|
code = code .. "\n mat4.translate(dst, {" ..
|
||||||
(translation[1] and ("l" .. translation[1]) or '0').. ", " ..
|
(translation[1] and ("l" .. translation[1]) or '0').. ", " ..
|
||||||
|
|
@ -226,7 +225,6 @@ end
|
||||||
|
|
||||||
local function codegen_rig_target(raw_track, context)
|
local function codegen_rig_target(raw_track, context)
|
||||||
local code = "\n if target.set_matrix and target.index then\n"
|
local code = "\n if target.set_matrix and target.index then\n"
|
||||||
code = code .. " local dst = DST\n"
|
|
||||||
for bone, lineset in pairs(raw_track.linesets) do
|
for bone, lineset in pairs(raw_track.linesets) do
|
||||||
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
|
||||||
|
|
@ -234,10 +232,13 @@ local function codegen_rig_target(raw_track, context)
|
||||||
local lineset_code = codegen_track(
|
local lineset_code = codegen_track(
|
||||||
raw_track, lineset, context.memoised, context.keysets, true)
|
raw_track, lineset, context.memoised, context.keysets, true)
|
||||||
|
|
||||||
code = code .. "\n do" .. lineset_code .. "\n end\n"
|
code = code
|
||||||
|
.. string.format("\n local bone_index = target:index(%s)"
|
||||||
|
.. "\n local dst = target:get_matrix(bone_index)", string.escape(bone))
|
||||||
|
.. "\n do" .. lineset_code .. "\n end\n"
|
||||||
if lineset.target_type == "bone" then
|
if lineset.target_type == "bone" then
|
||||||
code = code ..
|
code = code ..
|
||||||
" target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n"
|
" target:set_matrix(bone_index, dst)\n"
|
||||||
end
|
end
|
||||||
::continue::
|
::continue::
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ function set_state(name, fade_time)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function update(delta)
|
local function update(delta)
|
||||||
|
rig:reset_pose()
|
||||||
for _, state in pairs(states) do
|
for _, state in pairs(states) do
|
||||||
state.timer = state.timer + delta
|
state.timer = state.timer + delta
|
||||||
|
|
||||||
|
|
@ -51,7 +52,7 @@ local function update(delta)
|
||||||
end
|
end
|
||||||
|
|
||||||
state.track = state.track or animation.get_track(state.track_id)
|
state.track = state.track or animation.get_track(state.track_id)
|
||||||
if state.track and intensity > 0.0 then
|
if state.track then
|
||||||
state.track.func(
|
state.track.func(
|
||||||
rig,
|
rig,
|
||||||
state.timer % math.min(MAX_DURATION, state.track.duration),
|
state.timer % math.min(MAX_DURATION, state.track.duration),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue