You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira UE-139236 #rnx #rb ryan.schmidt #preflight 61e1f70200246899a950be81 #ROBOMERGE-AUTHOR: tyson.brochu #ROBOMERGE-SOURCE: CL 18624665 in //UE5/Release-5.0/... via CL 18624697 via CL 18624731 #ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v899-18417669) [CL 18624746 by tyson brochu in ue5-main branch]
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "MeshProcessingNodes/MeshRepackUVsNode.h"
|
|
|
|
#include "Parameterization/MeshUVPacking.h"
|
|
|
|
using namespace UE::Geometry;
|
|
using namespace UE::GeometryFlow;
|
|
|
|
|
|
void FMeshRepackUVsNode::RepackUVsForMesh(FDynamicMesh3& EditMesh, const FMeshRepackUVsSettings& Settings)
|
|
{
|
|
if ( !(EditMesh.HasAttributes() && EditMesh.Attributes()->GetUVLayer(Settings.UVLayer)) )
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (EditMesh.TriangleCount() == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
FDynamicMeshUVOverlay* UVLayer = EditMesh.Attributes()->GetUVLayer(Settings.UVLayer);
|
|
|
|
UVLayer->SplitBowties();
|
|
|
|
FDynamicMeshUVPacker Packer(UVLayer);
|
|
Packer.TextureResolution = Settings.TextureResolution;
|
|
Packer.GutterSize = Settings.GutterSize;
|
|
Packer.bAllowFlips = Settings.bAllowFlips;
|
|
|
|
bool bOK = Packer.StandardPack();
|
|
if (!ensure(bOK)) { return; }
|
|
|
|
|
|
if (Settings.UVScale != FVector2f::One() || Settings.UVTranslation != FVector2f::Zero())
|
|
{
|
|
for (int ElementID : UVLayer->ElementIndicesItr())
|
|
{
|
|
FVector2f UV = UVLayer->GetElement(ElementID);
|
|
UV.X *= Settings.UVScale.X;
|
|
UV.Y *= Settings.UVScale.Y;
|
|
UV += Settings.UVTranslation;
|
|
UVLayer->SetElement(ElementID, UV);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|