Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Private/SelectionSet.cpp
michael balzer 2b10993563 Move InteractiveToolsFramework and GeometryFramework out of Experimental
#jira UETOOL-3823
#rb brooke.hubert
#preflight 6109d1e9b4288d0001acb7ef

[CL 17055606 by michael balzer in ue5-main branch]
2021-08-04 13:58:55 -04:00

95 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SelectionSet.h"
UMeshSelectionSet::UMeshSelectionSet()
{
//SetFlags(RF_Transactional);
}
TArray<int>& UMeshSelectionSet::GetElements(EMeshSelectionElementType ElementType)
{
switch (ElementType)
{
default:
case EMeshSelectionElementType::Vertex:
return Vertices;
case EMeshSelectionElementType::Edge:
return Edges;
case EMeshSelectionElementType::Face:
return Faces;
case EMeshSelectionElementType::Group:
return Groups;
}
check(false);
}
const TArray<int>& UMeshSelectionSet::GetElements(EMeshSelectionElementType ElementType) const
{
switch (ElementType)
{
default:
case EMeshSelectionElementType::Vertex:
return Vertices;
case EMeshSelectionElementType::Edge:
return Edges;
case EMeshSelectionElementType::Face:
return Faces;
case EMeshSelectionElementType::Group:
return Groups;
}
check(false);
}
void UMeshSelectionSet::AddIndices(EMeshSelectionElementType ElementType, const TArray<int32>& Indices)
{
TArray<int32>& CurElements = GetElements(ElementType);
int N = Indices.Num();
for (int k = 0; k < N; ++k)
{
CurElements.Add(Indices[k]);
}
NotifySelectionSetModified();
}
void UMeshSelectionSet::AddIndices(EMeshSelectionElementType ElementType, const TSet<int32>& Indices)
{
TArray<int>& CurElements = GetElements(ElementType);
for ( int32 Index : Indices )
{
CurElements.Add(Index);
}
NotifySelectionSetModified();
}
void UMeshSelectionSet::RemoveIndices(EMeshSelectionElementType ElementType, const TArray<int32>& Indices)
{
TSet<int32> IndicesSet(Indices);
RemoveIndices(ElementType, IndicesSet);
}
void UMeshSelectionSet::RemoveIndices(EMeshSelectionElementType ElementType, const TSet<int32>& Indices)
{
TArray<int32>& CurElements = GetElements(ElementType);
TArray<int32> NewElements;
NewElements.Reserve(FMath::Max(0, CurElements.Num() - Indices.Num()));
for (int32 Index : CurElements)
{
if (Indices.Contains(Index) == false)
{
NewElements.Add(Index);
}
}
CurElements = MoveTemp(NewElements);
NotifySelectionSetModified();
}