2019-12-26 15:33:43 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2015-07-27 11:47:42 -04:00
|
|
|
|
|
|
|
|
#include "Customizations/TextureDetailsCustomization.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Misc/MessageDialog.h"
|
|
|
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
|
#include "Engine/Texture.h"
|
|
|
|
|
#include "Editor.h"
|
2015-07-27 11:47:42 -04:00
|
|
|
#include "DetailLayoutBuilder.h"
|
|
|
|
|
#include "DetailWidgetRow.h"
|
|
|
|
|
#include "IDetailPropertyRow.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "DetailCategoryBuilder.h"
|
|
|
|
|
#include "Widgets/Input/SNumericEntryBox.h"
|
2023-04-26 22:41:11 -04:00
|
|
|
#include "Widgets/Input/SButton.h"
|
2015-07-27 11:47:42 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "FTextureDetails"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TSharedRef<IDetailCustomization> FTextureDetails::MakeInstance()
|
|
|
|
|
{
|
|
|
|
|
return MakeShareable(new FTextureDetails);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FTextureDetails::CustomizeDetails(IDetailLayoutBuilder& DetailBuilder)
|
|
|
|
|
{
|
2023-06-16 04:10:23 -04:00
|
|
|
DetailBuilder.GetObjectsBeingCustomized(TexturesBeingCustomized);
|
2015-07-27 11:47:42 -04:00
|
|
|
|
2020-10-28 10:59:23 -04:00
|
|
|
DetailBuilder.EditCategory("LevelOfDetail");
|
|
|
|
|
DetailBuilder.EditCategory("Compression");
|
|
|
|
|
DetailBuilder.EditCategory("Texture");
|
|
|
|
|
DetailBuilder.EditCategory("Adjustments");
|
|
|
|
|
DetailBuilder.EditCategory("File Path");
|
|
|
|
|
|
2023-04-26 22:41:11 -04:00
|
|
|
OodleTextureSdkVersionPropertyHandle = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UTexture, OodleTextureSdkVersion));
|
2015-07-27 11:47:42 -04:00
|
|
|
MaxTextureSizePropertyHandle = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UTexture, MaxTextureSize));
|
2020-01-24 18:07:01 -05:00
|
|
|
VirtualTextureStreamingPropertyHandle = DetailBuilder.GetProperty(GET_MEMBER_NAME_CHECKED(UTexture, VirtualTextureStreaming));
|
2023-04-26 22:41:11 -04:00
|
|
|
|
|
|
|
|
if( OodleTextureSdkVersionPropertyHandle->IsValidHandle() )
|
|
|
|
|
{
|
|
|
|
|
IDetailCategoryBuilder& CompressionCategory = DetailBuilder.EditCategory("Compression");
|
|
|
|
|
IDetailPropertyRow& OodleTextureSdkVersionPropertyRow = CompressionCategory.AddProperty(GET_MEMBER_NAME_CHECKED(UTexture, OodleTextureSdkVersion));
|
|
|
|
|
TSharedPtr<SWidget> NameWidget;
|
|
|
|
|
TSharedPtr<SWidget> ValueWidget;
|
|
|
|
|
FDetailWidgetRow Row;
|
|
|
|
|
OodleTextureSdkVersionPropertyRow.GetDefaultWidgets(NameWidget, ValueWidget, Row);
|
2015-07-27 11:47:42 -04:00
|
|
|
|
2023-04-26 22:41:11 -04:00
|
|
|
const bool bShowChildren = true;
|
|
|
|
|
OodleTextureSdkVersionPropertyRow.CustomWidget(bShowChildren)
|
|
|
|
|
.NameContent()
|
|
|
|
|
.MinDesiredWidth(Row.NameWidget.MinWidth)
|
|
|
|
|
.MaxDesiredWidth(Row.NameWidget.MaxWidth)
|
|
|
|
|
[
|
|
|
|
|
NameWidget.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(Row.ValueWidget.MinWidth)
|
|
|
|
|
.MaxDesiredWidth(Row.ValueWidget.MaxWidth)
|
|
|
|
|
.VAlign(VAlign_Fill)
|
|
|
|
|
.HAlign(HAlign_Fill)
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
[
|
|
|
|
|
ValueWidget.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.HAlign(HAlign_Right)
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
|
|
|
|
SNew(SButton)
|
|
|
|
|
.OnClicked(this, &FTextureDetails::OnOodleTextureSdkVersionClicked)
|
|
|
|
|
.ContentPadding(FMargin(2))
|
|
|
|
|
.Content()
|
|
|
|
|
[
|
|
|
|
|
SNew(STextBlock)
|
|
|
|
|
.Justification(ETextJustify::Center)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.Text(LOCTEXT("OodleTextureSdkVersionLatest", "latest"))
|
|
|
|
|
.ToolTipText(LOCTEXT("OodleTextureSdkVersionLatestTooltip", "Update SDK Version to Latest"))
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 11:47:42 -04:00
|
|
|
// Customize MaxTextureSize
|
2023-06-16 04:10:23 -04:00
|
|
|
if( MaxTextureSizePropertyHandle->IsValidHandle() && TexturesBeingCustomized.Num() == 1)
|
2015-07-27 11:47:42 -04:00
|
|
|
{
|
|
|
|
|
IDetailCategoryBuilder& CompressionCategory = DetailBuilder.EditCategory("Compression");
|
|
|
|
|
IDetailPropertyRow& MaxTextureSizePropertyRow = CompressionCategory.AddProperty(GET_MEMBER_NAME_CHECKED(UTexture, MaxTextureSize));
|
|
|
|
|
TSharedPtr<SWidget> NameWidget;
|
|
|
|
|
TSharedPtr<SWidget> ValueWidget;
|
|
|
|
|
FDetailWidgetRow Row;
|
|
|
|
|
MaxTextureSizePropertyRow.GetDefaultWidgets(NameWidget, ValueWidget, Row);
|
|
|
|
|
|
2024-05-01 12:02:52 -04:00
|
|
|
int32 MaxTextureSize = UTexture::GetMaximumDimensionOfNonVT();
|
2019-01-10 17:26:53 -05:00
|
|
|
|
2023-06-16 04:10:23 -04:00
|
|
|
if (UTexture* Texture = Cast<UTexture>(TexturesBeingCustomized[0].Get()))
|
2019-01-10 17:26:53 -05:00
|
|
|
{
|
2022-04-13 19:31:28 -04:00
|
|
|
// GetMaximumDimension is for current RHI and texture type
|
2024-05-01 12:02:52 -04:00
|
|
|
MaxTextureSize = FMath::Min<int32>( Texture->GetMaximumDimension(), MaxTextureSize );
|
2019-01-10 17:26:53 -05:00
|
|
|
}
|
|
|
|
|
|
2024-05-01 12:02:52 -04:00
|
|
|
// @@ this slider is very hard to work with
|
|
|
|
|
// it's almost impossible to set low values
|
|
|
|
|
// instead of being on the linear MaxTextureSize value, it should be on the log2
|
|
|
|
|
// and scaled by *10 or something
|
|
|
|
|
// so the drag experience is slower and log-scaled
|
|
|
|
|
|
2015-07-27 11:47:42 -04:00
|
|
|
const bool bShowChildren = true;
|
|
|
|
|
MaxTextureSizePropertyRow.CustomWidget(bShowChildren)
|
|
|
|
|
.NameContent()
|
|
|
|
|
.MinDesiredWidth(Row.NameWidget.MinWidth)
|
|
|
|
|
.MaxDesiredWidth(Row.NameWidget.MaxWidth)
|
|
|
|
|
[
|
|
|
|
|
NameWidget.ToSharedRef()
|
|
|
|
|
]
|
|
|
|
|
.ValueContent()
|
|
|
|
|
.MinDesiredWidth(Row.ValueWidget.MinWidth)
|
|
|
|
|
.MaxDesiredWidth(Row.ValueWidget.MaxWidth)
|
|
|
|
|
[
|
|
|
|
|
SNew(SNumericEntryBox<int32>)
|
|
|
|
|
.AllowSpin(true)
|
|
|
|
|
.Value(this, &FTextureDetails::OnGetMaxTextureSize)
|
|
|
|
|
.Font(IDetailLayoutBuilder::GetDetailFont())
|
|
|
|
|
.MinValue(0)
|
2019-01-10 17:26:53 -05:00
|
|
|
.MaxValue(MaxTextureSize)
|
2015-07-27 11:47:42 -04:00
|
|
|
.MinSliderValue(0)
|
2019-01-10 17:26:53 -05:00
|
|
|
.MaxSliderValue(MaxTextureSize)
|
2015-07-27 11:47:42 -04:00
|
|
|
.OnValueChanged(this, &FTextureDetails::OnMaxTextureSizeChanged)
|
|
|
|
|
.OnValueCommitted(this, &FTextureDetails::OnMaxTextureSizeCommitted)
|
|
|
|
|
.OnBeginSliderMovement(this, &FTextureDetails::OnBeginSliderMovement)
|
|
|
|
|
.OnEndSliderMovement(this, &FTextureDetails::OnEndSliderMovement)
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-24 18:07:01 -05:00
|
|
|
// Hide the option to enable VT streaming, if VT is disabled for the project
|
|
|
|
|
if (VirtualTextureStreamingPropertyHandle.IsValid())
|
|
|
|
|
{
|
|
|
|
|
static const auto CVarVirtualTexturesEnabled = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.VirtualTextures")); check(CVarVirtualTexturesEnabled);
|
|
|
|
|
const bool bVirtualTextureEnabled = CVarVirtualTexturesEnabled->GetValueOnAnyThread() != 0;
|
|
|
|
|
if (!bVirtualTextureEnabled)
|
|
|
|
|
{
|
|
|
|
|
DetailBuilder.HideProperty(VirtualTextureStreamingPropertyHandle);
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-07-27 11:47:42 -04:00
|
|
|
}
|
|
|
|
|
|
2023-04-26 22:41:11 -04:00
|
|
|
FReply FTextureDetails::OnOodleTextureSdkVersionClicked()
|
|
|
|
|
{
|
2023-06-16 04:10:23 -04:00
|
|
|
for (const TWeakObjectPtr<UObject>& WeakTexture : TexturesBeingCustomized)
|
2023-04-26 22:41:11 -04:00
|
|
|
{
|
2023-06-16 04:10:23 -04:00
|
|
|
if (UTexture* Texture = Cast<UTexture>(WeakTexture.Get()))
|
|
|
|
|
{
|
|
|
|
|
// true = do Pre/PostEditChange
|
|
|
|
|
Texture->UpdateOodleTextureSdkVersionToLatest(true);
|
|
|
|
|
}
|
2023-04-26 22:41:11 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 11:47:42 -04:00
|
|
|
/** @return The value or unset if properties with multiple values are viewed */
|
|
|
|
|
TOptional<int32> FTextureDetails::OnGetMaxTextureSize() const
|
|
|
|
|
{
|
|
|
|
|
int32 NumericVal;
|
|
|
|
|
if (MaxTextureSizePropertyHandle->GetValue(NumericVal) == FPropertyAccess::Success)
|
|
|
|
|
{
|
|
|
|
|
return NumericVal;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return an unset value so it displays the "multiple values" indicator instead
|
|
|
|
|
return TOptional<int32>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FTextureDetails::OnMaxTextureSizeChanged(int32 NewValue)
|
|
|
|
|
{
|
|
|
|
|
if (bIsUsingSlider)
|
|
|
|
|
{
|
|
|
|
|
int32 OrgValue(0);
|
|
|
|
|
if (MaxTextureSizePropertyHandle->GetValue(OrgValue) != FPropertyAccess::Fail)
|
|
|
|
|
{
|
|
|
|
|
// Value hasn't changed, so let's return now
|
|
|
|
|
if (OrgValue == NewValue)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We don't create a transaction for each property change when using the slider. Only once when the slider first is moved
|
2024-05-01 12:02:52 -04:00
|
|
|
// Interactive flag makes it so the texture is not rebuilt in PostEditChange
|
2015-07-27 11:47:42 -04:00
|
|
|
EPropertyValueSetFlags::Type Flags = (EPropertyValueSetFlags::InteractiveChange | EPropertyValueSetFlags::NotTransactable);
|
|
|
|
|
MaxTextureSizePropertyHandle->SetValue(NewValue, Flags);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FTextureDetails::OnMaxTextureSizeCommitted(int32 NewValue, ETextCommit::Type CommitInfo)
|
|
|
|
|
{
|
2024-05-01 12:02:52 -04:00
|
|
|
// this causes the texture to build with the new value (if necessary)
|
2015-07-27 11:47:42 -04:00
|
|
|
MaxTextureSizePropertyHandle->SetValue(NewValue);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when the slider begins to move. We create a transaction here to undo the property
|
|
|
|
|
*/
|
|
|
|
|
void FTextureDetails::OnBeginSliderMovement()
|
|
|
|
|
{
|
|
|
|
|
bIsUsingSlider = true;
|
|
|
|
|
|
2019-12-13 11:07:03 -05:00
|
|
|
GEditor->BeginTransaction(TEXT("TextureDetails"), LOCTEXT("SetMaximumTextureSize", "Edit Maximum Texture Size"), nullptr /* MaxTextureSizePropertyHandle->GetProperty() */ );
|
2015-07-27 11:47:42 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when the slider stops moving. We end the previously created transaction
|
|
|
|
|
*/
|
|
|
|
|
void FTextureDetails::OnEndSliderMovement(int32 NewValue)
|
|
|
|
|
{
|
|
|
|
|
bIsUsingSlider = false;
|
|
|
|
|
|
|
|
|
|
GEditor->EndTransaction();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|