You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/EMotionFX/Code/Source/Integration/System/PipelineComponent.cpp

88 lines
3.2 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#if defined(EMOTIONFXANIMATION_EDITOR)
#include <AzCore/Serialization/SerializeContext.h>
#include <MCore/Source/MCoreSystem.h>
#include <Integration/System/PipelineComponent.h>
#include <EMotionFX/Source/EMotionFXManager.h>
#include <EMotionFX/CommandSystem/Source/CommandManager.h>
#include <Integration/System/SystemCommon.h>
namespace EMotionFX
{
namespace Pipeline
{
AZ::EnvironmentVariable<EMotionFXAllocatorInitializer> PipelineComponent::s_eMotionFXAllocatorInitializer = nullptr;
PipelineComponent::PipelineComponent()
: m_EMotionFXInited(false)
{
}
void PipelineComponent::Activate()
{
if (!m_EMotionFXInited)
{
// Start EMotionFX allocator or increase the reference counting
s_eMotionFXAllocatorInitializer = AZ::Environment::CreateVariable<EMotionFXAllocatorInitializer>(EMotionFXAllocatorInitializer::EMotionFXAllocatorInitializerTag);
MCore::Initializer::InitSettings coreSettings;
if (!MCore::Initializer::Init(&coreSettings))
{
AZ_Error("EMotionFX", false, "Failed to initialize EMotion FX SDK Core");
return;
}
// Initialize EMotion FX runtime.
EMotionFX::Initializer::InitSettings emfxSettings;
emfxSettings.mUnitType = MCore::Distance::UNITTYPE_METERS;
if (!EMotionFX::Initializer::Init(&emfxSettings))
{
AZ_Error("EMotionFX", false, "Failed to initialize EMotion FX SDK Runtime");
return;
}
// Initialize the EMotionFX command system.
m_commandManager = AZStd::make_unique<CommandSystem::CommandManager>();
m_EMotionFXInited = true;
}
}
void PipelineComponent::Deactivate()
{
if (m_EMotionFXInited)
{
m_EMotionFXInited = false;
m_commandManager.reset();
EMotionFX::Initializer::Shutdown();
MCore::Initializer::Shutdown();
// Remove our reference
s_eMotionFXAllocatorInitializer = nullptr;
}
}
void PipelineComponent::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<PipelineComponent, AZ::SceneAPI::SceneCore::SceneSystemComponent>()->Version(1);
}
}
} // Pipeline
} // EMotionFX
#endif