You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#ROBOMERGE-AUTHOR: michael.balzer #ROBOMERGE-SOURCE: CL 18227685 in //UE5/Release-5.0/... via CL 18229350 #ROBOMERGE-BOT: STARSHIP (Release-Engine-Staging -> Release-Engine-Test) (v895-18170469) #ROBOMERGE[STARSHIP]: UE5-Main [CL 18231457 by michael balzer in ue5-release-engine-test branch]
123 lines
2.9 KiB
C++
123 lines
2.9 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Polygroups/PolygroupSet.h"
|
|
#include "Polygroups/PolygroupUtil.h"
|
|
|
|
using namespace UE::Geometry;
|
|
|
|
|
|
bool FPolygroupLayer::CheckExists(const FDynamicMesh3* Mesh)
|
|
{
|
|
if (Mesh)
|
|
{
|
|
if (bIsDefaultLayer)
|
|
{
|
|
if (Mesh->HasTriangleGroups())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (LayerIndex >= 0 && Mesh->HasAttributes() && LayerIndex < Mesh->Attributes()->NumPolygroupLayers())
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
FPolygroupSet::FPolygroupSet(const FPolygroupSet* CopyIn)
|
|
{
|
|
Mesh = CopyIn->Mesh;
|
|
PolygroupAttrib = CopyIn->PolygroupAttrib;
|
|
GroupLayerIndex = CopyIn->GroupLayerIndex;
|
|
MaxGroupID = CopyIn->MaxGroupID;
|
|
}
|
|
|
|
FPolygroupSet::FPolygroupSet(const FDynamicMesh3* MeshIn)
|
|
{
|
|
Mesh = MeshIn;
|
|
GroupLayerIndex = -1;
|
|
RecalculateMaxGroupID();
|
|
}
|
|
|
|
/** Initialize a PolygroupSet for the given Mesh, and standard triangle group layer */
|
|
FPolygroupSet::FPolygroupSet(const FDynamicMesh3* MeshIn, FPolygroupLayer GroupLayer)
|
|
{
|
|
Mesh = MeshIn;
|
|
GroupLayerIndex = -1;
|
|
if (! GroupLayer.bIsDefaultLayer )
|
|
{
|
|
if (ensure(Mesh->Attributes()))
|
|
{
|
|
if (GroupLayer.LayerIndex < Mesh->Attributes()->NumPolygroupLayers())
|
|
{
|
|
PolygroupAttrib = Mesh->Attributes()->GetPolygroupLayer(GroupLayer.LayerIndex);
|
|
GroupLayerIndex = GroupLayer.LayerIndex;
|
|
}
|
|
}
|
|
if (GroupLayerIndex == -1)
|
|
{
|
|
ensureMsgf(false, TEXT("FPolygroupSet: Attribute index missing!"));
|
|
}
|
|
}
|
|
RecalculateMaxGroupID();
|
|
}
|
|
|
|
|
|
FPolygroupSet::FPolygroupSet(const FDynamicMesh3* MeshIn, const FDynamicMeshPolygroupAttribute* PolygroupAttribIn)
|
|
{
|
|
Mesh = MeshIn;
|
|
PolygroupAttrib = PolygroupAttribIn;
|
|
GroupLayerIndex = UE::Geometry::FindPolygroupLayerIndex(*MeshIn, PolygroupAttrib);
|
|
RecalculateMaxGroupID();
|
|
}
|
|
|
|
FPolygroupSet::FPolygroupSet(const FDynamicMesh3* MeshIn, int32 PolygroupLayerIndex)
|
|
{
|
|
Mesh = MeshIn;
|
|
if (ensure(Mesh->Attributes()))
|
|
{
|
|
if (PolygroupLayerIndex < Mesh->Attributes()->NumPolygroupLayers())
|
|
{
|
|
PolygroupAttrib = Mesh->Attributes()->GetPolygroupLayer(PolygroupLayerIndex);
|
|
GroupLayerIndex = PolygroupLayerIndex;
|
|
return;
|
|
}
|
|
}
|
|
RecalculateMaxGroupID();
|
|
ensureMsgf(false, TEXT("FPolygroupSet: Attribute index missing!"));
|
|
}
|
|
|
|
|
|
FPolygroupSet::FPolygroupSet(const FDynamicMesh3* MeshIn, FName AttribName)
|
|
{
|
|
Mesh = MeshIn;
|
|
PolygroupAttrib = UE::Geometry::FindPolygroupLayerByName(*MeshIn, AttribName);
|
|
GroupLayerIndex = UE::Geometry::FindPolygroupLayerIndex(*MeshIn, PolygroupAttrib);
|
|
RecalculateMaxGroupID();
|
|
ensureMsgf(PolygroupAttrib != nullptr, TEXT("FPolygroupSet: Attribute set missing!"));
|
|
}
|
|
|
|
|
|
void FPolygroupSet::RecalculateMaxGroupID()
|
|
{
|
|
MaxGroupID = 0;
|
|
if (PolygroupAttrib)
|
|
{
|
|
for (int32 tid : Mesh->TriangleIndicesItr())
|
|
{
|
|
MaxGroupID = FMath::Max(MaxGroupID, PolygroupAttrib->GetValue(tid) + 1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int32 tid : Mesh->TriangleIndicesItr())
|
|
{
|
|
MaxGroupID = FMath::Max(MaxGroupID, Mesh->GetTriangleGroup(tid) + 1);
|
|
}
|
|
}
|
|
} |