Files
UnrealEngineUWP/Engine/Source/Runtime/Landscape/Private/LandscapeComponent.cpp
chris tchou 7016d85cbc Fix for crashes involving Landscape paint undo/redo (second try)
Also ran CI to verify: https://horde.devtools.epicgames.com/job/635a2d420d3a231123b1c6ef

#rb jonathan.bard
#jira UE-136705, UE-160979, UE-165113, UE-141171
#preflight 635a1d8c8d56375d45d49921

[CL 22875448 by chris tchou in ue5-main branch]
2022-10-31 20:02:05 -04:00

84 lines
2.4 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"
uint32 ULandscapeComponent::UndoRedoModifiedComponentCount;
TArray<ULandscapeComponent*> ULandscapeComponent::UndoRedoModifiedComponents;
#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