PipelineComponent.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #if defined(EMOTIONFXANIMATION_EDITOR)
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <MCore/Source/MCoreSystem.h>
  11. #include <Integration/System/PipelineComponent.h>
  12. #include <EMotionFX/Source/EMotionFXManager.h>
  13. #include <EMotionFX/CommandSystem/Source/CommandManager.h>
  14. #include <Integration/System/SystemCommon.h>
  15. namespace EMotionFX
  16. {
  17. namespace Pipeline
  18. {
  19. PipelineComponent::PipelineComponent()
  20. : m_eMotionFxInited(false)
  21. {
  22. }
  23. void PipelineComponent::Activate()
  24. {
  25. if (!m_eMotionFxInited)
  26. {
  27. MCore::Initializer::InitSettings coreSettings;
  28. if (!MCore::Initializer::Init(&coreSettings))
  29. {
  30. AZ_Error("EMotionFX", false, "Failed to initialize EMotion FX SDK Core");
  31. return;
  32. }
  33. // Initialize EMotion FX runtime.
  34. EMotionFX::Initializer::InitSettings emfxSettings;
  35. emfxSettings.m_unitType = MCore::Distance::UNITTYPE_METERS;
  36. if (!EMotionFX::Initializer::Init(&emfxSettings))
  37. {
  38. AZ_Error("EMotionFX", false, "Failed to initialize EMotion FX SDK Runtime");
  39. return;
  40. }
  41. // Initialize the EMotionFX command system.
  42. m_commandManager = AZStd::make_unique<CommandSystem::CommandManager>();
  43. m_eMotionFxInited = true;
  44. }
  45. }
  46. void PipelineComponent::Deactivate()
  47. {
  48. if (m_eMotionFxInited)
  49. {
  50. m_eMotionFxInited = false;
  51. m_commandManager.reset();
  52. EMotionFX::Initializer::Shutdown();
  53. MCore::Initializer::Shutdown();
  54. }
  55. }
  56. void PipelineComponent::Reflect(AZ::ReflectContext* context)
  57. {
  58. AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
  59. if (serializeContext)
  60. {
  61. serializeContext->Class<PipelineComponent, AZ::SceneAPI::SceneCore::SceneSystemComponent>()->Version(1);
  62. }
  63. }
  64. } // Pipeline
  65. } // EMotionFX
  66. #endif