Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/InteractiveToolsFramework/Private/MultiSelectionTool.cpp
lonnie li 328b0c0f0b ModelingTools: Replace MultiSelectionTool PrimitiveComponentTarget with ToolTargets (pt.2)
#rb ryan.schmidt jimmy.andrews semion.piskarev
#jira none
#rnx

[CL 15677067 by lonnie li in ue5-main branch]
2021-03-11 11:40:03 -04:00

40 lines
1.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "MultiSelectionTool.h"
#include "TargetInterfaces/AssetBackedTarget.h"
bool UMultiSelectionTool::GetMapToSharedSourceData(TArray<int32>& MapToFirstOccurrences)
{
bool bSharesSources = false;
MapToFirstOccurrences.SetNumUninitialized(Targets.Num());
for (int32 ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
{
MapToFirstOccurrences[ComponentIdx] = -1;
}
for (int32 ComponentIdx = 0; ComponentIdx < Targets.Num(); ComponentIdx++)
{
if (MapToFirstOccurrences[ComponentIdx] >= 0) // already mapped
{
continue;
}
MapToFirstOccurrences[ComponentIdx] = ComponentIdx;
IAssetBackedTarget* Target = Cast<IAssetBackedTarget>(Targets[ComponentIdx]);
if (!Target)
{
continue;
}
for (int32 VsIdx = ComponentIdx + 1; VsIdx < Targets.Num(); VsIdx++)
{
IAssetBackedTarget* OtherTarget = Cast<IAssetBackedTarget>(Targets[VsIdx]);
if (OtherTarget && OtherTarget->GetSourceData() == Target->GetSourceData())
{
bSharesSources = true;
MapToFirstOccurrences[VsIdx] = ComponentIdx;
}
}
}
return bSharesSources;
}