2019-12-26 15:32:37 -05:00
// Copyright Epic Games, Inc. All Rights Reserved.
2019-06-11 18:27:07 -04:00
# pragma once
# include "CoreMinimal.h"
2022-05-02 18:06:48 -04:00
# include "AssetRegistry/AssetRegistryModule.h"
2020-05-05 15:05:40 -04:00
# include "UObject/GCObject.h"
2022-11-14 13:18:14 -05:00
# include "AssetRegistry/AssetIdentifier.h"
2019-06-11 18:27:07 -04:00
class UTexture2D ;
class UMaterial ;
class UMaterialFunctionInterface ;
struct FScopedSlowTask ;
2022-11-14 13:18:14 -05:00
class UClass ;
struct FAssetData ;
2019-06-11 18:27:07 -04:00
2022-11-14 13:18:14 -05:00
class FVirtualTextureConversionWorker : public FGCObject
2019-06-11 18:27:07 -04:00
{
public :
2022-11-14 13:18:14 -05:00
FVirtualTextureConversionWorker ( bool bInConvertBackward = false ) : bConvertBackward ( bInConvertBackward ) { }
2019-08-01 18:07:08 -04:00
bool bConvertBackward ;
2019-06-11 18:27:07 -04:00
// Fill this array intially with some textures you want to see converted to vt
2023-05-16 10:52:49 -04:00
TArray < TObjectPtr < UTexture2D > > UserTextures ;
2019-06-11 18:27:07 -04:00
// These will be filled by calling FilterList
2023-05-16 10:52:49 -04:00
TArray < TObjectPtr < UTexture2D > > Textures ;
TArray < TObjectPtr < UMaterial > > Materials ;
TArray < TObjectPtr < UMaterialFunctionInterface > > Functions ;
TArray < TObjectPtr < UTexture2D > > SizeRejectedTextures ; // The original selection of the user filtered by textures that match the threshold size
TSet < TObjectPtr < UTexture2D > > MaterialRejectedTextures ; // Textures that could not be converted due to their usage in materials (connected to unsupported property)
2019-06-11 18:27:07 -04:00
struct FAuditTrail
{
FAuditTrail ( UObject * SetObject , const FString & SetString ) : Destination ( SetObject ) , PathDescription ( SetString ) { }
UObject * Destination ; //Next object in the trail
FString PathDescription ; //Description on how we go there
} ;
2023-05-16 10:52:49 -04:00
TMap < TObjectPtr < UObject > , FAuditTrail > AuditTrail ;
2019-06-11 18:27:07 -04:00
2019-08-01 18:07:08 -04:00
void SetConversionDirection ( bool bInConvertBackward ) { bConvertBackward = bInConvertBackward ; }
2019-06-11 18:27:07 -04:00
void FilterList ( int32 SizeThreshold ) ;
// Based on the filtered lists do the actual VT conversion
2019-08-01 18:07:08 -04:00
void DoConvert ( ) ;
2020-05-05 15:05:40 -04:00
void AddReferencedObjects ( FReferenceCollector & Collector ) override ;
2021-04-29 19:32:06 -04:00
virtual FString GetReferencerName ( ) const override
{
return TEXT ( " FVTConversionWorker " ) ;
}
2020-05-05 15:05:40 -04:00
2019-06-11 18:27:07 -04:00
private :
2023-03-29 13:04:29 -04:00
void FindAllTexturesAndMaterials_Iteration ( TSet < UMaterial * > & InAffectedMaterials ,
TSet < UMaterialFunctionInterface * > & InAffectedFunctions ,
TSet < UTexture2D * > & InAffectedTextures ,
2023-05-16 10:52:49 -04:00
TSet < TObjectPtr < UTexture2D > > & InInvalidTextures ,
2019-06-11 18:27:07 -04:00
FScopedSlowTask & Task ) ;
2023-05-16 10:52:49 -04:00
void FindAllTexturesAndMaterials ( TArray < TObjectPtr < UMaterial > > & OutAffectedMaterials , TArray < TObjectPtr < UMaterialFunctionInterface > > & OutAffectedFunctions , TArray < TObjectPtr < UTexture2D > > & OutAffectedTextures ) ;
2019-06-11 18:27:07 -04:00
} ;