mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +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)
|
||||
if target and target.reset_pose then
|
||||
target:reset_pose()
|
||||
end
|
||||
local track = setmetatable({
|
||||
name = name,
|
||||
target = target,
|
||||
|
|
|
|||
|
|
@ -194,7 +194,6 @@ local function codegen_track(raw_track, lineset, memoised, keysets, use_tsf)
|
|||
return code
|
||||
end
|
||||
|
||||
code = code .. "\n mat4.idt(dst)"
|
||||
if translation[1] or translation[2] or translation[3] then
|
||||
code = code .. "\n mat4.translate(dst, {" ..
|
||||
(translation[1] and ("l" .. translation[1]) or '0').. ", " ..
|
||||
|
|
@ -226,7 +225,6 @@ end
|
|||
|
||||
local function codegen_rig_target(raw_track, context)
|
||||
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
|
||||
if lineset.target_type ~= "bone" and lineset.target_type ~= "texture" then
|
||||
goto continue
|
||||
|
|
@ -234,10 +232,13 @@ local function codegen_rig_target(raw_track, context)
|
|||
local lineset_code = codegen_track(
|
||||
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
|
||||
code = code ..
|
||||
" target:set_matrix(target:index(" .. string.escape(bone) .. "), dst)\n"
|
||||
" target:set_matrix(bone_index, dst)\n"
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ function set_state(name, fade_time)
|
|||
end
|
||||
|
||||
local function update(delta)
|
||||
rig:reset_pose()
|
||||
for _, state in pairs(states) do
|
||||
state.timer = state.timer + delta
|
||||
|
||||
|
|
@ -51,7 +52,7 @@ local function update(delta)
|
|||
end
|
||||
|
||||
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(
|
||||
rig,
|
||||
state.timer % math.min(MAX_DURATION, state.track.duration),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue