2020-12-04 19:51:25 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "PropertySets/PolygroupLayersProperties.h"
|
2021-06-13 00:36:02 -04:00
|
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
|
|
|
|
#include "DynamicMesh/DynamicMeshAttributeSet.h"
|
2021-09-15 22:44:16 -04:00
|
|
|
#include "Polygroups/PolygroupUtil.h"
|
2020-12-04 19:51:25 -04:00
|
|
|
|
2021-09-15 22:44:16 -04:00
|
|
|
using namespace UE::Geometry;
|
2020-12-04 19:51:25 -04:00
|
|
|
|
|
|
|
|
void UPolygroupLayersProperties::InitializeGroupLayers(const FDynamicMesh3* Mesh)
|
|
|
|
|
{
|
2021-01-13 16:19:10 -04:00
|
|
|
GroupLayersList.Reset();
|
2020-12-04 19:51:25 -04:00
|
|
|
GroupLayersList.Add(TEXT("Default")); // always have standard group
|
|
|
|
|
if (Mesh->Attributes())
|
|
|
|
|
{
|
|
|
|
|
for (int32 k = 0; k < Mesh->Attributes()->NumPolygroupLayers(); k++)
|
|
|
|
|
{
|
|
|
|
|
FName Name = Mesh->Attributes()->GetPolygroupLayer(k)->GetName();
|
|
|
|
|
GroupLayersList.Add(Name.ToString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GroupLayersList.Contains(ActiveGroupLayer.ToString()) == false) // discard restored value if it doesn't apply
|
|
|
|
|
{
|
|
|
|
|
ActiveGroupLayer = FName(GroupLayersList[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-01-13 16:19:10 -04:00
|
|
|
void UPolygroupLayersProperties::InitializeGroupLayers(const TSet<FName>& LayerNames)
|
|
|
|
|
{
|
|
|
|
|
GroupLayersList.Reset();
|
|
|
|
|
GroupLayersList.Add(TEXT("Default")); // always have standard group
|
|
|
|
|
for (const FName& Name : LayerNames)
|
|
|
|
|
{
|
|
|
|
|
GroupLayersList.Add(Name.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (GroupLayersList.Contains(ActiveGroupLayer.ToString()) == false) // discard restored value if it doesn't apply
|
|
|
|
|
{
|
|
|
|
|
ActiveGroupLayer = FName(GroupLayersList[0]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-04 19:51:25 -04:00
|
|
|
|
|
|
|
|
bool UPolygroupLayersProperties::HasSelectedPolygroup() const
|
|
|
|
|
{
|
|
|
|
|
return ActiveGroupLayer != FName(GroupLayersList[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UPolygroupLayersProperties::SetSelectedFromPolygroupIndex(int32 Index)
|
|
|
|
|
{
|
|
|
|
|
if (Index < 0)
|
|
|
|
|
{
|
|
|
|
|
ActiveGroupLayer = FName(GroupLayersList[0]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActiveGroupLayer = FName(GroupLayersList[Index+1]);
|
|
|
|
|
}
|
2021-09-15 22:44:16 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UE::Geometry::FPolygroupLayer UPolygroupLayersProperties::GetSelectedLayer(const FDynamicMesh3& FromMesh)
|
|
|
|
|
{
|
|
|
|
|
if (HasSelectedPolygroup() == false)
|
|
|
|
|
{
|
|
|
|
|
return FPolygroupLayer::Default();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int32 Index = UE::Geometry::FindPolygroupLayerIndexByName(FromMesh, ActiveGroupLayer);
|
|
|
|
|
return (Index >= 0) ? FPolygroupLayer::Layer(Index) : FPolygroupLayer::Default();
|
|
|
|
|
}
|
2020-12-04 19:51:25 -04:00
|
|
|
}
|