You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
44 lines
1.6 KiB
C++
44 lines
1.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "HLODBuilderMeshMerge.h"
|
|
|
|
#include "Algo/ForEach.h"
|
|
#include "Engine/StaticMesh.h"
|
|
#include "Materials/Material.h"
|
|
#include "Components/StaticMeshComponent.h"
|
|
|
|
#include "WorldPartition/HLOD/HLODActor.h"
|
|
#include "WorldPartition/HLOD/HLODLayer.h"
|
|
|
|
#include "IMeshMergeUtilities.h"
|
|
#include "MeshMergeModule.h"
|
|
#include "Modules/ModuleManager.h"
|
|
|
|
|
|
TArray<UPrimitiveComponent*> FHLODBuilder_MeshMerge::CreateComponents(AWorldPartitionHLOD* InHLODActor, const UHLODLayer* InHLODLayer, const TArray<UPrimitiveComponent*>& InSubComponents)
|
|
{
|
|
TRACE_CPUPROFILER_EVENT_SCOPE(FHLODBuilder_MeshMerge::CreateComponents);
|
|
|
|
TArray<UObject*> Assets;
|
|
FVector MergedActorLocation;
|
|
|
|
const IMeshMergeUtilities& MeshMergeUtilities = FModuleManager::Get().LoadModuleChecked<IMeshMergeModule>("MeshMergeUtilities").GetUtilities();
|
|
MeshMergeUtilities.MergeComponentsToStaticMesh(InSubComponents, InHLODActor->GetWorld(), InHLODLayer->GetMeshMergeSettings(), InHLODLayer->GetHLODMaterial().LoadSynchronous(), InHLODActor->GetPackage(), InHLODActor->GetActorLabel(), Assets, MergedActorLocation, 0.25f, false);
|
|
|
|
UStaticMeshComponent* Component = nullptr;
|
|
Algo::ForEach(Assets, [this, InHLODActor, &Component, &MergedActorLocation](UObject* Asset)
|
|
{
|
|
Asset->ClearFlags(RF_Public | RF_Standalone);
|
|
|
|
if (Cast<UStaticMesh>(Asset))
|
|
{
|
|
Component = NewObject<UStaticMeshComponent>(InHLODActor);
|
|
Component->SetStaticMesh(static_cast<UStaticMesh*>(Asset));
|
|
Component->SetWorldLocation(MergedActorLocation);
|
|
DisableCollisions(Component);
|
|
}
|
|
});
|
|
|
|
return TArray<UPrimitiveComponent*>({ Component });
|
|
}
|