You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb jimmy.andrews, semion.piskarev #jira none [CL 15661651 by Ryan Schmidt in ue5-main branch]
42 lines
1.0 KiB
C++
42 lines
1.0 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)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|