From 0f71e1a15262b3daed887c46807e2fa572779282 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 18 Oct 2026 12:45:03 +0300 Subject: [PATCH 1/2] fix animation & disable codegen trace --- res/modules/animation.lua | 2 +- res/modules/internal/animation_codegen.lua | 36 ++++++++++++++++------ 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/res/modules/animation.lua b/res/modules/animation.lua index a4e1f73d9..664c3bd16 100644 --- a/res/modules/animation.lua +++ b/res/modules/animation.lua @@ -56,7 +56,7 @@ local M = { MAX_DURATION = 1e9, MAX_FRAMES = 1e9, - TRACE_CODEGEN = true, + TRACE_CODEGEN = false, maths = { bezier_interpolation = bezier_interpolation diff --git a/res/modules/internal/animation_codegen.lua b/res/modules/internal/animation_codegen.lua index 97df4bc00..dd0094b48 100644 --- a/res/modules/internal/animation_codegen.lua +++ b/res/modules/internal/animation_codegen.lua @@ -259,7 +259,7 @@ end local function codegen_rig_target(raw_track, context) local code = "\n if target.set_matrix and target.index then\n" 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" then goto continue end local lineset_code = codegen_track(raw_track, lineset, context.keysets, true, "bone") @@ -270,7 +270,7 @@ local function codegen_rig_target(raw_track, context) end code = code .. "\n do" .. lineset_code .. "\n end\n" - if lineset.target_type == "bone" and context.has_tsf then + if context.has_tsf then code = code .. " target:set_matrix(bone_index, dst)\n" end @@ -309,14 +309,14 @@ local function codegen_native_rig_target(raw_track, context, track_name) end 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" then goto continue end local lineset_code = codegen_track( - raw_track, lineset, context.memoised, context.keysets, false) + raw_track, lineset, context.keysets, false, "bone") local exported = {} local entry = {name = bone} - if lineset.target_type == "bone" then + do local channels = { [animation.CH_TRANSLATE] = {}, [animation.CH_ROTATE] = {}, @@ -381,14 +381,30 @@ local function codegen_native_rig_target(raw_track, context, track_name) return "\n if target.__native_rig then" .. code end -local function codegen_object_target(raw_track, context) - local code = " local dst = mat4.idt()\n" - local lineset = raw_track.linesets[""] - if not lineset then +local function codegen_texture_target(raw_track, context) + local code = "" + for _, lineset in pairs(raw_track.linesets) do + if lineset.target_type == "texture" then + code = code .. "\n do" + .. codegen_track(raw_track, lineset, context.keysets, false, "texture") + .. "\n end\n" + end + end + if #code == 0 then return "" end + return "\n if target.set_texture then" .. code .. " end\n" +end + +local function codegen_object_target(raw_track, context) + local code = codegen_texture_target(raw_track, context) + local lineset = raw_track.linesets[""] + if not lineset then + return code + end local lineset_code = codegen_track(raw_track, lineset, context.keysets, true) - code = code .. "\n do" .. lineset_code .. "\n end\n" + code = code .. " local dst = mat4.idt()\n" + .. "\n do" .. lineset_code .. "\n end\n" if context.has_tsf then code = code .. " set_matrix(target, dst)\n" From 0954057636cff99da131d7018713c1b3844c8976 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 18 Oct 2026 12:59:45 +0300 Subject: [PATCH 2/2] make 'animations' folder default, 'animation' an alias --- src/assets/AssetsLoader.cpp | 1 + src/assets/assetload_funcs.cpp | 14 +++++++++++++- src/constants.hpp | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/assets/AssetsLoader.cpp b/src/assets/AssetsLoader.cpp index 04bde9a6f..6e20f214a 100644 --- a/src/assets/AssetsLoader.cpp +++ b/src/assets/AssetsLoader.cpp @@ -224,6 +224,7 @@ void AssetsLoader::processPreloadList(AssetType tag, const dv::value& list) { void AssetsLoader::processPreloadConfig(const io::path& file) { auto root = io::read_json(file); + processPreloadList(AssetType::ANIMATION, root["animations"]); processPreloadList(AssetType::ANIMATION, root["animation"]); processPreloadList(AssetType::ATLAS, root["atlases"]); processPreloadList(AssetType::FONT, root["fonts"]); diff --git a/src/assets/assetload_funcs.cpp b/src/assets/assetload_funcs.cpp index f6080cd1c..e76e9fb38 100644 --- a/src/assets/assetload_funcs.cpp +++ b/src/assets/assetload_funcs.cpp @@ -44,6 +44,18 @@ static bool load_animated_texture( Atlas* dstAtlas ); +static io::path find_animation(const ResPaths& paths, const std::string& filename) { + auto path = paths.find(filename + ".vca"); + const auto prefix = ANIMATION_FOLDER + "/"; + if (io::is_regular_file(path) || filename.rfind(prefix, 0) != 0) { + return path; + } + auto alias = paths.find( + ANIMATION_FOLDER_ALIAS + "/" + filename.substr(prefix.length()) + ".vca" + ); + return io::is_regular_file(alias) ? alias : path; +} + assetload::postfunc assetload::animation( AssetsLoader& loader, const ResPaths& paths, @@ -51,7 +63,7 @@ assetload::postfunc assetload::animation( const std::string& name, const std::shared_ptr& ) { - auto path = paths.find(filename + ".vca"); + auto path = find_animation(paths, filename); loader.attachToFile(path, {name, AssetType::ANIMATION}); if (io::is_regular_file(path)) { diff --git a/src/constants.hpp b/src/constants.hpp index 826c2f1a8..4cc29bbdf 100644 --- a/src/constants.hpp +++ b/src/constants.hpp @@ -75,7 +75,8 @@ inline constexpr int DEFAULT_FONT_SIZE = 16; inline constexpr int DEFAULT_PRE_RENDER_FONT_PAGES = 1; // must be at least 1 -inline const std::string ANIMATION_FOLDER = "animation"; +inline const std::string ANIMATION_FOLDER = "animations"; +inline const std::string ANIMATION_FOLDER_ALIAS = "animation"; inline const std::string FONTS_FOLDER = "fonts"; inline const std::string LAYOUTS_FOLDER = "layouts"; inline const std::string MODELS_FOLDER = "models";