Files
UnrealEngineUWP/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Private/PropertySets/OnAcceptProperties.cpp
michael balzer a49c74b915 MeshModelingToolset: Move ModelingOperators and ModelingOperatorsEditorOnly modules out of experimental plugin
#jira UETOOL-3823
#rb lonnie.li
#preflight 617b1aea5794a500014f544a

#ROBOMERGE-AUTHOR: michael.balzer
#ROBOMERGE-SOURCE: CL 17972239 in //UE5/Release-5.0/... via CL 17972248
#ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v885-17909292)
#ROBOMERGE[STARSHIP]: UE5-Main

[CL 17972256 by michael balzer in ue5-release-engine-test branch]
2021-10-28 19:47:45 -04:00

79 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "PropertySets/OnAcceptProperties.h"
#include "GameFramework/Actor.h"
#include "UObject/UObjectGlobals.h"
#include "InteractiveToolManager.h"
#define LOCTEXT_NAMESPACE "UOnAcceptHandleSourcesProperties"
void UOnAcceptHandleSourcesPropertiesBase::ApplyMethod(const TArray<AActor*>& Actors, UInteractiveToolManager* ToolManager, const AActor* MustKeepActor)
{
const EHandleSourcesMethod HandleInputs = GetHandleInputs();
// Hide or destroy the sources
bool bKeepSources = HandleInputs == EHandleSourcesMethod::KeepSources;
if (Actors.Num() == 1 && (HandleInputs == EHandleSourcesMethod::KeepFirstSource || HandleInputs == EHandleSourcesMethod::KeepLastSource))
{
// if there's only one actor, keeping any source == keeping all sources
bKeepSources = true;
}
if (!bKeepSources)
{
bool bDelete = HandleInputs == EHandleSourcesMethod::DeleteSources
|| HandleInputs == EHandleSourcesMethod::KeepFirstSource
|| HandleInputs == EHandleSourcesMethod::KeepLastSource;
if (bDelete)
{
ToolManager->BeginUndoTransaction(LOCTEXT("RemoveSources", "Remove Inputs"));
}
else
{
#if WITH_EDITOR
ToolManager->BeginUndoTransaction(LOCTEXT("HideSources", "Hide Inputs"));
#endif
}
const int32 ActorIdxBegin = HandleInputs == EHandleSourcesMethod::KeepFirstSource ? 1 : 0;
const int32 ActorIdxEnd = HandleInputs == EHandleSourcesMethod::KeepLastSource ? Actors.Num() - 1 : Actors.Num();
for (int32 ActorIdx = ActorIdxBegin; ActorIdx < ActorIdxEnd; ActorIdx++)
{
AActor* Actor = Actors[ActorIdx];
if (Actor == MustKeepActor)
{
continue;
}
if (bDelete)
{
Actor->Destroy();
}
else
{
#if WITH_EDITOR
// Save the actor to the transaction buffer to support undo/redo, but do
// not call Modify, as we do not want to dirty the actor's package and
// we're only editing temporary, transient values
SaveToTransactionBuffer(Actor, false);
Actor->SetIsTemporarilyHiddenInEditor(true);
#endif
}
}
if (bDelete)
{
ToolManager->EndUndoTransaction();
}
else
{
#if WITH_EDITOR
ToolManager->EndUndoTransaction();
#endif
}
}
}
#undef LOCTEXT_NAMESPACE