Added name to AnimationResource.
This commit is contained in:
parent
d32c247cc0
commit
f6f7e92cea
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -109,5 +109,3 @@ void SkinnedMeshResource::createInstance(SkinnedMesh& skinnedMesh) const {
|
||||
skinnedMesh.m_animation_sync_track.back() = m_sync_tracks[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,9 +199,11 @@ TEST_CASE_METHOD(
|
||||
AnimGraphContext graph_context;
|
||||
graph_context.m_skeleton = skeleton.get();
|
||||
graph_context.m_animation_map["trans_x"] = {
|
||||
"trans_x",
|
||||
animation_translate_x.get(),
|
||||
animation_translate_x_sync_track};
|
||||
graph_context.m_animation_map["trans_y"] = {
|
||||
"trans_y",
|
||||
animation_translate_y.get(),
|
||||
animation_translate_y_sync_track};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user