Files
UnrealEngineUWP/Engine/Source/Runtime/Landscape/Private/LandscapeComponent.cpp
sebastien lussier 245f347384 #jira UE-132273
WorldPartition - Added Lanscape HLODs

Created a custom HLOD builder for ULandscapeComponent
* Landscape LOD used to generate the HLOD is autocomputed from the expected draw distance, same for the baked texture size

* Expose ALandscapeProxy::GetLODScreenSizeArray()
* Actually reverting changes done in CL 18794652 (moving proxy mesh creation back to ALandscapeProxy)
* ComputeLayerHash() now takes a bool to choose if we want to compute the hash for edition or runtime data
#preflight 620a60a1583261b0a6539c22
#rb Patrick.Enfedaque

#ROBOMERGE-AUTHOR: sebastien.lussier
#ROBOMERGE-SOURCE: CL 18980225 in //UE5/Release-5.0/... via CL 18980661 via CL 18981014
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18981050 by sebastien lussier in ue5-main branch]
2022-02-14 12:02:22 -05:00

81 lines
2.2 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LandscapeComponent.h"
#include "LandscapeLayerInfoObject.h"
#include "Materials/MaterialInstance.h"
#include "LandscapeEdit.h"
#include "LandscapeRender.h"
#if WITH_EDITOR
#include "LandscapeHLODBuilder.h"
#endif
FName FWeightmapLayerAllocationInfo::GetLayerName() const
{
if (LayerInfo)
{
return LayerInfo->LayerName;
}
return NAME_None;
}
uint32 FWeightmapLayerAllocationInfo::GetHash() const
{
uint32 Hash = PointerHash(LayerInfo);
Hash = HashCombine(GetTypeHash(WeightmapTextureIndex), Hash);
Hash = HashCombine(GetTypeHash(WeightmapTextureChannel), Hash);
return Hash;
}
#if WITH_EDITOR
void FLandscapeEditToolRenderData::UpdateDebugColorMaterial(const ULandscapeComponent* const Component)
{
Component->GetLayerDebugColorKey(DebugChannelR, DebugChannelG, DebugChannelB);
}
void FLandscapeEditToolRenderData::UpdateSelectionMaterial(int32 InSelectedType, const ULandscapeComponent* const Component)
{
// Check selection
if (SelectedType != InSelectedType && (SelectedType & ST_REGION) && !(InSelectedType & ST_REGION))
{
// Clear Select textures...
if (DataTexture)
{
FLandscapeEditDataInterface LandscapeEdit(Component->GetLandscapeInfo());
LandscapeEdit.ZeroTexture(DataTexture);
}
}
SelectedType = InSelectedType;
}
void ULandscapeComponent::UpdateEditToolRenderData()
{
FLandscapeComponentSceneProxy* LandscapeSceneProxy = (FLandscapeComponentSceneProxy*)SceneProxy;
if (LandscapeSceneProxy != nullptr)
{
TArray<UMaterialInterface*> UsedMaterialsForVerification;
const bool bGetDebugMaterials = true;
GetUsedMaterials(UsedMaterialsForVerification, bGetDebugMaterials);
FLandscapeEditToolRenderData LandscapeEditToolRenderData = EditToolRenderData;
ENQUEUE_RENDER_COMMAND(UpdateEditToolRenderData)(
[LandscapeEditToolRenderData, LandscapeSceneProxy, UsedMaterialsForVerification](FRHICommandListImmediate& RHICmdList)
{
LandscapeSceneProxy->EditToolRenderData = LandscapeEditToolRenderData;
LandscapeSceneProxy->SetUsedMaterialForVerification(UsedMaterialsForVerification);
});
}
}
TSubclassOf<UHLODBuilder> ULandscapeComponent::GetCustomHLODBuilderClass() const
{
return ULandscapeHLODBuilder::StaticClass();
}
#endif