Files
UnrealEngineUWP/Engine/Source/Editor/Persona/Private/PersonaEditorModeManager.cpp
zach rammell 99738c0f68 Refactor persona editor modes/mode manager to use ITF context objects for persona-only interfaces instead of static casting
#rb brooke.hubert Thomas.Sarkanen
#jira UE-143249
#preflight 628549709e72602f6ab62b3b

[CL 20282438 by zach rammell in ue5-main branch]
2022-05-19 12:34:51 -04:00

59 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "PersonaEditorModeManager.h"
#include "IPersonaEditMode.h"
#include "IPersonaPreviewScene.h"
#include "Selection.h"
#include "Animation/DebugSkelMeshComponent.h"
#include "EdModeInteractiveToolsContext.h"
#include "ContextObjectStore.h"
bool FPersonaEditorModeManager::GetCameraTarget(FSphere& OutTarget) const
{
for (const UEdMode* Mode : ActiveScriptableModes)
{
if (const UEditorInteractiveToolsContext* ModeInteractiveToolsContext = Mode->GetInteractiveToolsContext())
{
if (const IAnimationEditContext* PersonaContext = ModeInteractiveToolsContext->ContextObjectStore->FindContext<UAnimationEditModeContext>())
{
if (PersonaContext->GetCameraTarget(OutTarget))
{
return true;
}
}
}
}
return false;
}
void FPersonaEditorModeManager::GetOnScreenDebugInfo(TArray<FText>& OutDebugText) const
{
for (const UEdMode* Mode : ActiveScriptableModes)
{
if (const UEditorInteractiveToolsContext* ModeInteractiveToolsContext = Mode->GetInteractiveToolsContext())
{
if (const IAnimationEditContext* PersonaContext = ModeInteractiveToolsContext->ContextObjectStore->FindContext<UAnimationEditModeContext>())
{
PersonaContext->GetOnScreenDebugInfo(OutDebugText);
}
}
}
}
void FPersonaEditorModeManager::SetPreviewScene(FPreviewScene* NewPreviewScene)
{
const IPersonaPreviewScene *PersonaPreviewScene = static_cast<const IPersonaPreviewScene *>(NewPreviewScene);
if (PersonaPreviewScene && PersonaPreviewScene->GetPreviewMeshComponent())
{
ComponentSet->BeginBatchSelectOperation();
ComponentSet->DeselectAll();
ComponentSet->Select(PersonaPreviewScene->GetPreviewMeshComponent(), true);
ComponentSet->EndBatchSelectOperation();
}
FAssetEditorModeManager::SetPreviewScene(NewPreviewScene);
}