Added name to AnimationResource.

This commit is contained in:
Martin Felis
2025-04-11 13:05:50 +02:00
parent d32c247cc0
commit f6f7e92cea
4 changed files with 26 additions and 5 deletions
+20 -2
View File
@@ -32,11 +32,29 @@ struct AnimDataRef {
Pose* ptr = nullptr;
};
struct AnimationFileResource {
struct AnimationResource {
std::string m_name;
ozz::animation::Animation* m_animation;
SyncTrack m_sync_track;
};
inline void to_json(
nlohmann::json& j,
const AnimationResource& animation_resource) {
j["type"] = "AnimationResource";
j["synctrack"] = animation_resource.m_sync_track;
j["name"] = animation_resource.m_name;
}
inline void from_json(
const nlohmann::json& j,
AnimationResource& animation_resource) {
assert(j["type"] == "AnimationResource");
animation_resource.m_sync_track = j["synctrack"];
animation_resource.m_name = j["name"];
}
struct AnimDataAllocator {
struct PoseList {
Pose* m_anim_data = nullptr;
@@ -108,7 +126,7 @@ struct AnimGraphContext {
AnimGraph* m_graph = nullptr;
ozz::animation::Skeleton* m_skeleton = nullptr;
typedef std::map<std::string, AnimationFileResource> AnimationFileMap;
typedef std::map<std::string, AnimationResource> AnimationFileMap;
AnimationFileMap m_animation_map;
void freeAnimations() {
+4 -1
View File
@@ -151,7 +151,10 @@ bool AnimSamplerNode::Init(AnimGraphContext& context) {
archive >> *m_animation;
context.m_animation_map[m_filename] = {m_animation, SyncTrack()};
context.m_animation_map[m_filename] = {
m_filename,
m_animation,
SyncTrack()};
}
assert(context.m_skeleton != nullptr);