diff --git a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp index c1c48b3480..7303c8d559 100644 --- a/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp +++ b/Gems/EMotionFX/Code/EMotionFX/Tools/EMotionStudio/EMStudioSDK/Source/MainWindow.cpp @@ -163,9 +163,9 @@ namespace EMStudio {} ~UndoMenuCallback() = default; - void OnRemoveCommand([[maybe_unused]] uint32 historyIndex) override { m_mainWindow->UpdateUndoRedo(); } - void OnSetCurrentCommand([[maybe_unused]] uint32 index) override { m_mainWindow->UpdateUndoRedo(); } - void OnAddCommandToHistory([[maybe_unused]] uint32 historyIndex, [[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override { m_mainWindow->UpdateUndoRedo(); } + void OnRemoveCommand([[maybe_unused]] size_t historyIndex) override { m_mainWindow->UpdateUndoRedo(); } + void OnSetCurrentCommand([[maybe_unused]] size_t index) override { m_mainWindow->UpdateUndoRedo(); } + void OnAddCommandToHistory([[maybe_unused]] size_t historyIndex, [[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override { m_mainWindow->UpdateUndoRedo(); } void OnPreExecuteCommand([[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine) override {} void OnPostExecuteCommand([[maybe_unused]] MCore::CommandGroup* group, [[maybe_unused]] MCore::Command* command, [[maybe_unused]] const MCore::CommandLine& commandLine, [[maybe_unused]] bool wasSuccess, [[maybe_unused]] const AZStd::string& outResult) override {} diff --git a/Gems/EMotionFX/Code/MCore/Source/Command.cpp b/Gems/EMotionFX/Code/MCore/Source/Command.cpp index 39e9fde965..8845e7c278 100644 --- a/Gems/EMotionFX/Code/MCore/Source/Command.cpp +++ b/Gems/EMotionFX/Code/MCore/Source/Command.cpp @@ -8,6 +8,7 @@ // include the required headers #include "Command.h" +#include #include @@ -81,9 +82,9 @@ namespace MCore } - uint32 Command::GetNumCallbacks() const + size_t Command::GetNumCallbacks() const { - return static_cast(mCallbacks.size()); + return mCallbacks.size(); } @@ -123,37 +124,18 @@ namespace MCore // calculate the number of registered pre-execute callbacks - uint32 Command::CalcNumPreCommandCallbacks() const + size_t Command::CalcNumPreCommandCallbacks() const { - uint32 result = 0; - - const size_t numCallbacks = mCallbacks.size(); - for (size_t i = 0; i < numCallbacks; ++i) + return AZStd::accumulate(begin(mCallbacks), end(mCallbacks), size_t{0}, [](size_t total, const Callback* callback) { - if (mCallbacks[i]->GetExecutePreCommand()) - { - result++; - } - } - - return result; + return callback->GetExecutePreCommand() ? total + 1 : total; + }); } // calculate the number of registered post-execute callbacks - uint32 Command::CalcNumPostCommandCallbacks() const + size_t Command::CalcNumPostCommandCallbacks() const { - uint32 result = 0; - - const size_t numCallbacks = mCallbacks.size(); - for (size_t i = 0; i < numCallbacks; ++i) - { - if (mCallbacks[i]->GetExecutePreCommand() == false) - { - result++; - } - } - - return result; + return mCallbacks.size() - CalcNumPreCommandCallbacks(); } } // namespace MCore diff --git a/Gems/EMotionFX/Code/MCore/Source/Command.h b/Gems/EMotionFX/Code/MCore/Source/Command.h index 7309c5dc91..d6bfb3a0d7 100644 --- a/Gems/EMotionFX/Code/MCore/Source/Command.h +++ b/Gems/EMotionFX/Code/MCore/Source/Command.h @@ -279,26 +279,26 @@ namespace MCore * Get the number of registered/added command callbacks. * @result The number of command callbacks that have been added. */ - uint32 GetNumCallbacks() const; + size_t GetNumCallbacks() const; /** * Calculate the number of registered pre-execute callbacks. * @result The number of registered pre-execute callbacks. */ - uint32 CalcNumPreCommandCallbacks() const; + size_t CalcNumPreCommandCallbacks() const; /** * Calculate the number of registered post-execute callbacks. * @result The number of registered post-execute callbacks. */ - uint32 CalcNumPostCommandCallbacks() const; + size_t CalcNumPostCommandCallbacks() const; /** * Get a given command callback. * @param index The callback number, which must be in range of [0..GetNumCallbacks()-1]. * @result A pointer to the command callback object. */ - MCORE_INLINE Command::Callback* GetCallback(uint32 index) { return mCallbacks[index]; } + MCORE_INLINE Command::Callback* GetCallback(size_t index) { return mCallbacks[index]; } /** * Add (register) a command callback.