From 2d56411e5f8f4a292b328eeac51b6c3d59fe04f5 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sun, 23 Nov 2025 14:19:37 -0600 Subject: [PATCH] Add slot stop methods without anim param. --- Source/Engine/Level/Actors/AnimatedModel.cpp | 24 ++++++++++++++++++++ Source/Engine/Level/Actors/AnimatedModel.h | 12 ++++++++++ 2 files changed, 36 insertions(+) diff --git a/Source/Engine/Level/Actors/AnimatedModel.cpp b/Source/Engine/Level/Actors/AnimatedModel.cpp index ee66c6c77..a8c091eb9 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.cpp +++ b/Source/Engine/Level/Actors/AnimatedModel.cpp @@ -563,6 +563,20 @@ void AnimatedModel::StopSlotAnimation(const StringView& slotName, Animation* ani } } +void AnimatedModel::StopSlotAnimation(const StringView& slotName) +{ + for (auto& slot : GraphInstance.Slots) + { + if (slot.Name == slotName) + { + //slot.Animation = nullptr; // TODO: make an immediate version of this method and set the animation to nullptr. + if (slot.Animation != nullptr) + slot.Reset = true; + break; + } + } +} + void AnimatedModel::PauseSlotAnimation() { for (auto& slot : GraphInstance.Slots) @@ -601,6 +615,16 @@ bool AnimatedModel::IsPlayingSlotAnimation(const StringView& slotName, Animation return false; } +bool AnimatedModel::IsPlayingSlotAnimation(const StringView& slotName) +{ + for (auto& slot : GraphInstance.Slots) + { + if (slot.Name == slotName && !slot.Pause) + return true; + } + return false; +} + void AnimatedModel::ApplyRootMotion(const Transform& rootMotionDelta) { // Skip if no motion diff --git a/Source/Engine/Level/Actors/AnimatedModel.h b/Source/Engine/Level/Actors/AnimatedModel.h index a011be0d0..dc837c658 100644 --- a/Source/Engine/Level/Actors/AnimatedModel.h +++ b/Source/Engine/Level/Actors/AnimatedModel.h @@ -414,6 +414,12 @@ public: /// The name of the slot. /// The animation to stop. API_FUNCTION() void StopSlotAnimation(const StringView& slotName, Animation* anim); + + /// + /// Stops the animation playback on the slot in Anim Graph. + /// + /// The name of the slot. + API_FUNCTION() void StopSlotAnimation(const StringView& slotName); /// /// Pauses all the animations playback on the all slots in Anim Graph. @@ -439,6 +445,12 @@ public: /// The animation to check. API_FUNCTION() bool IsPlayingSlotAnimation(const StringView& slotName, Animation* anim); + /// + /// Checks if the animation playback is active on the slot in Anim Graph (not paused). + /// + /// The name of the slot. + API_FUNCTION() bool IsPlayingSlotAnimation(const StringView& slotName); + private: void ApplyRootMotion(const Transform& rootMotionDelta); void SyncParameters();