You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Fixed materials in the BakeRC tool missing UV layer switches or controls for brightness of the Base Color, Subsurface Color or Emissive channels Removed the unused AO Multiplier setting that appeared in the Preview panel of the tool UI Improved performance of BakeRC tool baking step by not recomputing the target mesh spatial index and uv charts Improved the clarity of the analytics code since the sub-classing has enabled us to more easily use custom BakeRC analytics #rb lonnie.li #rnx #preflight 63cfaa1ed83c1837b182104b #jira none [CL 23828120 by matija kecman in ue5-main branch]
77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "BakeToolUtils.h"
|
|
|
|
#include "PreviewMesh.h"
|
|
#include "ToolSetupUtil.h"
|
|
#include "ModelingToolTargetUtil.h"
|
|
#include "DynamicMesh/DynamicMesh3.h"
|
|
#include "Components/DynamicMeshComponent.h"
|
|
#include "TargetInterfaces/DynamicMeshSource.h"
|
|
#include "ToolTargets/ToolTarget.h"
|
|
|
|
namespace UE
|
|
{
|
|
namespace Geometry
|
|
{
|
|
|
|
void UpdateUVLayerNames(FString& UVLayer, TArray<FString>& UVLayerNamesList, const FDynamicMesh3& Mesh)
|
|
{
|
|
UVLayerNamesList.Reset();
|
|
int32 FoundIndex = -1;
|
|
for (int32 k = 0; k < Mesh.Attributes()->NumUVLayers(); ++k)
|
|
{
|
|
UVLayerNamesList.Add(FString::Printf(TEXT("UV %d"), k));
|
|
if (UVLayer == UVLayerNamesList.Last())
|
|
{
|
|
FoundIndex = k;
|
|
}
|
|
}
|
|
if (FoundIndex == -1)
|
|
{
|
|
UVLayer = UVLayerNamesList[0];
|
|
}
|
|
}
|
|
|
|
// TODO Some variation of this function may be able to be reused in other tools
|
|
UPreviewMesh* CreateBakePreviewMesh(
|
|
UObject* Tool,
|
|
UToolTarget* ToolTarget,
|
|
UWorld* World)
|
|
{
|
|
const FDynamicMesh3 InputMesh = UE::ToolTarget::GetDynamicMeshCopy(ToolTarget, true);
|
|
const FTransformSRT3d BaseToWorld = UE::ToolTarget::GetLocalToWorldTransform(ToolTarget);
|
|
const FComponentMaterialSet MaterialSet = UE::ToolTarget::GetMaterialSet(ToolTarget);
|
|
|
|
UPreviewMesh* PreviewMesh = NewObject<UPreviewMesh>(Tool);
|
|
|
|
PreviewMesh->CreateInWorld(World, FTransform::Identity);
|
|
ToolSetupUtil::ApplyRenderingConfigurationToPreview(PreviewMesh, nullptr);
|
|
PreviewMesh->SetTransform(static_cast<FTransform>(BaseToWorld));
|
|
PreviewMesh->SetTangentsMode(EDynamicMeshComponentTangentsMode::ExternallyProvided);
|
|
PreviewMesh->ReplaceMesh(InputMesh);
|
|
PreviewMesh->SetMaterials(MaterialSet.Materials);
|
|
PreviewMesh->SetVisible(true);
|
|
|
|
return PreviewMesh;
|
|
}
|
|
|
|
|
|
// TODO We could probably use UE::ToolTarget::GetTargetActor to implement/replace this function
|
|
AActor* GetTargetActorViaIPersistentDynamicMeshSource(UToolTarget* Target)
|
|
{
|
|
IPersistentDynamicMeshSource* TargetDynamicMeshTarget = Cast<IPersistentDynamicMeshSource>(Target);
|
|
if (TargetDynamicMeshTarget)
|
|
{
|
|
UDynamicMeshComponent* TargetDynamicMeshComponent = TargetDynamicMeshTarget->GetDynamicMeshComponent();
|
|
if (TargetDynamicMeshComponent)
|
|
{
|
|
return TargetDynamicMeshComponent->GetOwner();
|
|
}
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace Geometry
|
|
} // namespace UE
|