Added AnimationFileResource that combine animations with sync tracks.
This commit is contained in:
		
							parent
							
								
									86ea476881
								
							
						
					
					
						commit
						887131af37
					
				| @ -33,6 +33,11 @@ struct AnimDataRef { | |||||||
|   Pose* ptr = nullptr; |   Pose* ptr = nullptr; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
|  | struct AnimationFileResource { | ||||||
|  |   ozz::animation::Animation* m_animation; | ||||||
|  |   SyncTrack m_sync_track; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
| struct AnimDataAllocator { | struct AnimDataAllocator { | ||||||
|   struct PoseList { |   struct PoseList { | ||||||
|     Pose* m_anim_data = nullptr; |     Pose* m_anim_data = nullptr; | ||||||
| @ -102,14 +107,14 @@ struct AnimGraphContext { | |||||||
|   AnimGraph* m_graph = nullptr; |   AnimGraph* m_graph = nullptr; | ||||||
|   ozz::animation::Skeleton* m_skeleton = nullptr; |   ozz::animation::Skeleton* m_skeleton = nullptr; | ||||||
| 
 | 
 | ||||||
|   typedef std::map<std::string, ozz::animation::Animation*> AnimationFileMap; |   typedef std::map<std::string, AnimationFileResource> AnimationFileMap; | ||||||
|   AnimationFileMap m_animation_map; |   AnimationFileMap m_animation_map; | ||||||
| 
 | 
 | ||||||
|   void freeAnimations() { |   void freeAnimations() { | ||||||
|     AnimationFileMap::iterator animation_map_iter = m_animation_map.begin(); |     AnimationFileMap::iterator animation_map_iter = m_animation_map.begin(); | ||||||
| 
 | 
 | ||||||
|     while (animation_map_iter != m_animation_map.end()) { |     while (animation_map_iter != m_animation_map.end()) { | ||||||
|       delete animation_map_iter->second; |       delete animation_map_iter->second.m_animation; | ||||||
|       animation_map_iter++; |       animation_map_iter++; | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -132,7 +132,8 @@ bool AnimSamplerNode::Init(AnimGraphContext& context) { | |||||||
|   AnimGraphContext::AnimationFileMap::const_iterator animation_map_iter; |   AnimGraphContext::AnimationFileMap::const_iterator animation_map_iter; | ||||||
|   animation_map_iter = context.m_animation_map.find(m_filename); |   animation_map_iter = context.m_animation_map.find(m_filename); | ||||||
|   if (animation_map_iter != context.m_animation_map.end()) { |   if (animation_map_iter != context.m_animation_map.end()) { | ||||||
|     m_animation = animation_map_iter->second; |     m_animation = animation_map_iter->second.m_animation; | ||||||
|  |     m_sync_track = animation_map_iter->second.m_sync_track; | ||||||
|   } else { |   } else { | ||||||
|     m_animation = new ozz::animation::Animation(); |     m_animation = new ozz::animation::Animation(); | ||||||
|     ozz::io::File file(m_filename.c_str(), "rb"); |     ozz::io::File file(m_filename.c_str(), "rb"); | ||||||
| @ -150,7 +151,7 @@ bool AnimSamplerNode::Init(AnimGraphContext& context) { | |||||||
| 
 | 
 | ||||||
|     archive >> *m_animation; |     archive >> *m_animation; | ||||||
| 
 | 
 | ||||||
|     context.m_animation_map[m_filename] = m_animation; |     context.m_animation_map[m_filename] = {m_animation, SyncTrack()}; | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   assert(context.m_skeleton != nullptr); |   assert(context.m_skeleton != nullptr); | ||||||
|  | |||||||
| @ -18,10 +18,15 @@ | |||||||
| 
 | 
 | ||||||
| struct SimpleAnimFixture { | struct SimpleAnimFixture { | ||||||
|   ozz::unique_ptr<ozz::animation::Skeleton> skeleton = nullptr; |   ozz::unique_ptr<ozz::animation::Skeleton> skeleton = nullptr; | ||||||
|  | 
 | ||||||
|   ozz::animation::offline::RawAnimation raw_animation_translation_x; |   ozz::animation::offline::RawAnimation raw_animation_translation_x; | ||||||
|   ozz::unique_ptr<ozz::animation::Animation> animation_translate_x = nullptr; |   ozz::unique_ptr<ozz::animation::Animation> animation_translate_x = nullptr; | ||||||
|  |   SyncTrack animation_translate_x_sync_track = {}; | ||||||
|  | 
 | ||||||
|   ozz::animation::offline::RawAnimation raw_animation_translation_y; |   ozz::animation::offline::RawAnimation raw_animation_translation_y; | ||||||
|   ozz::unique_ptr<ozz::animation::Animation> animation_translate_y = nullptr; |   ozz::unique_ptr<ozz::animation::Animation> animation_translate_y = nullptr; | ||||||
|  |   SyncTrack animation_translate_y_sync_track = {}; | ||||||
|  | 
 | ||||||
|   ozz::vector<ozz::math::SoaTransform> animation_output; |   ozz::vector<ozz::math::SoaTransform> animation_output; | ||||||
|   ozz::animation::SamplingJob::Context sampling_context; |   ozz::animation::SamplingJob::Context sampling_context; | ||||||
| 
 | 
 | ||||||
| @ -197,8 +202,12 @@ TEST_CASE_METHOD( | |||||||
|   // Prepare animation maps
 |   // Prepare animation maps
 | ||||||
|   AnimGraphContext graph_context; |   AnimGraphContext graph_context; | ||||||
|   graph_context.m_skeleton = skeleton.get(); |   graph_context.m_skeleton = skeleton.get(); | ||||||
|   graph_context.m_animation_map["trans_x"] = animation_translate_x.get(); |   graph_context.m_animation_map["trans_x"] = { | ||||||
|   graph_context.m_animation_map["trans_y"] = animation_translate_y.get(); |       animation_translate_x.get(), | ||||||
|  |       animation_translate_x_sync_track}; | ||||||
|  |   graph_context.m_animation_map["trans_y"] = { | ||||||
|  |       animation_translate_y.get(), | ||||||
|  |       animation_translate_y_sync_track}; | ||||||
| 
 | 
 | ||||||
|   // Instantiate graph
 |   // Instantiate graph
 | ||||||
|   AnimGraphBlendTree blend_tree; |   AnimGraphBlendTree blend_tree; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Martin Felis
						Martin Felis