You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
80 lines
2.1 KiB
C++
80 lines
2.1 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "MeshUtilitiesCommon.h"
|
|
#include "Allocator2D.h"
|
|
|
|
struct FMeshChart
|
|
{
|
|
uint32 FirstTri;
|
|
uint32 LastTri;
|
|
|
|
FVector2f MinUV;
|
|
FVector2f MaxUV;
|
|
|
|
float UVArea;
|
|
FVector2f UVScale;
|
|
FVector2f WorldScale;
|
|
|
|
FVector2f PackingScaleU;
|
|
FVector2f PackingScaleV;
|
|
FVector2f PackingBias;
|
|
|
|
int32 Join[4];
|
|
|
|
int32 Id; // Store a unique id so that we can come back to the initial Charts ordering when necessary
|
|
};
|
|
|
|
struct FOverlappingCorners;
|
|
|
|
class MESHUTILITIESCOMMON_API FLayoutUV
|
|
{
|
|
public:
|
|
|
|
/**
|
|
* Abstract triangle mesh view interface that may be used by any module without introducing
|
|
* a dependency on a concrete mesh type (and thus potentially circular module references).
|
|
* This abstraction results in a performance penalty due to virtual dispatch,
|
|
* however it is expected to be insignificant compared to the rest of work done by FLayoutUV
|
|
* and cache misses due to indexed vertex data access.
|
|
*/
|
|
struct IMeshView
|
|
{
|
|
virtual ~IMeshView() {}
|
|
|
|
virtual uint32 GetNumIndices() const = 0;
|
|
virtual FVector3f GetPosition(uint32 Index) const = 0;
|
|
virtual FVector3f GetNormal(uint32 Index) const = 0;
|
|
virtual FVector2f GetInputTexcoord(uint32 Index) const = 0;
|
|
|
|
virtual void InitOutputTexcoords(uint32 Num) = 0;
|
|
virtual void SetOutputTexcoord(uint32 Index, const FVector2f& Value) = 0;
|
|
};
|
|
|
|
FLayoutUV( IMeshView& InMeshView );
|
|
void SetVersion( ELightmapUVVersion Version ) { LayoutVersion = Version; }
|
|
int32 FindCharts( const FOverlappingCorners& OverlappingCorners );
|
|
bool FindBestPacking( uint32 InTextureResolution );
|
|
void CommitPackedUVs();
|
|
|
|
static void LogStats();
|
|
static void ResetStats();
|
|
private:
|
|
IMeshView& MeshView;
|
|
ELightmapUVVersion LayoutVersion;
|
|
|
|
TArray< FVector2f > MeshTexCoords;
|
|
TArray< uint32 > MeshSortedTris;
|
|
TArray< FMeshChart > MeshCharts;
|
|
uint32 PackedTextureResolution;
|
|
|
|
struct FChartFinder;
|
|
struct FChartPacker;
|
|
|
|
static TAtomic<uint64> FindBestPackingCount;
|
|
static TAtomic<uint64> FindBestPackingCycles;
|
|
static TAtomic<uint64> FindBestPackingEfficiency;
|
|
};
|