Bones now still affects skinned mesh when animation is stopped
This commit is contained in:
@@ -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<SkeletalAnimation> animation, float time)
|
||||
void AnimationSystem::UpdateBonePositionTraversal(SkeletonNode& bone, Ref<SkeletalAnimation> 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<TransformComponent>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user