diff --git a/Nuake/src/Scene/Systems/AnimationSystem.cpp b/Nuake/src/Scene/Systems/AnimationSystem.cpp index cd7987b3..f384d495 100644 --- a/Nuake/src/Scene/Systems/AnimationSystem.cpp +++ b/Nuake/src/Scene/Systems/AnimationSystem.cpp @@ -36,29 +36,24 @@ namespace Nuake { float newAnimationTime = animation->GetCurrentTime() + (ts * animation->GetTicksPerSecond()); animation->SetCurrentTime(newAnimationTime); - - auto& rootBone = model->GetSkeletonRootNode(); - UpdateBonePositionTraversal(rootBone, animation, animation->GetCurrentTime()); } + + auto& rootBone = model->GetSkeletonRootNode(); + UpdateBonePositionTraversal(rootBone, animation, animation->GetCurrentTime(), model->IsPlaying); } } - void AnimationSystem::UpdateBonePositionTraversal(SkeletonNode& bone, Ref animation, float time) + void AnimationSystem::UpdateBonePositionTraversal(SkeletonNode& bone, Ref animation, float time, bool isPlaying) { - const std::string& boneName = bone.Name; - - auto animationTrack = animation->GetTrack(boneName); + auto& animationTrack = animation->GetTrack(bone.Name); - Entity& boneEntity = m_Scene->GetEntity(boneName); Entity& boneEnt = m_Scene->GetEntityByID(bone.EntityHandle); - ///assert(boneEnt.GetHandle() == boneEntity.GetHandle()); - if (boneEnt.IsValid()) { auto& transformComponent = boneEnt.GetComponent(); bone.FinalTransform = transformComponent.GetGlobalTransform() * bone.Offset; - if (!animationTrack.IsEmpty()) + if (!animationTrack.IsEmpty() && isPlaying) { // Get Update transform animationTrack.Update(time); @@ -77,15 +72,10 @@ namespace Nuake transformComponent.Dirty = false; } } - else - { - // Find bone - - } for (auto& childBone : bone.Children) { - UpdateBonePositionTraversal(childBone, animation, time); + UpdateBonePositionTraversal(childBone, animation, time, isPlaying); } } diff --git a/Nuake/src/Scene/Systems/AnimationSystem.h b/Nuake/src/Scene/Systems/AnimationSystem.h index 57361dad..604a77b5 100644 --- a/Nuake/src/Scene/Systems/AnimationSystem.h +++ b/Nuake/src/Scene/Systems/AnimationSystem.h @@ -19,6 +19,6 @@ namespace Nuake void Exit() override; private: - void UpdateBonePositionTraversal(SkeletonNode& bone, Ref animation, float time); + void UpdateBonePositionTraversal(SkeletonNode& bone, Ref animation, float time, bool isPlaying); }; }