UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Landscape.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
8#include "LandscapeProxy.h"
10#include "LandscapeEditTypes.h"
11
12#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_6
14#endif // UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_6
15
18#include "Algo/Transform.h"
20
21#include "Landscape.generated.h"
22
23
24// ----------------------------------------------------------------------------------
25// Forward declarations
26
28class ULandscapeComponent;
43
45{
46 struct FMergeInfo;
47}
48
50{
51 struct FMergeInfo;
52}
53
55{
56 struct FMergeRenderParams;
57}
58
59#if WITH_EDITOR
61#endif
62
63UENUM()
72
73UENUM()
91
92UENUM()
112
113#if WITH_EDITOR
115#endif
116
117USTRUCT()
119#if CPP && WITH_EDITOR // UHT doesn't support inheriting from namespaced class
120 : public UE::Landscape::EditLayers::IEditLayerRendererProvider
121#endif // CPP && WITH_EDITOR
122{
124
126
128#if WITH_EDITORONLY_DATA
130#endif // WITH_EDITORONLY_DATA
131 {}
132
133 virtual ~FLandscapeLayerBrush() = default;
134
135#if WITH_EDITOR
137 bool AffectsHeightmap() const;
139 bool AffectsVisibilityLayer() const;
140 void SetOwner(ALandscape* InOwner);
141
142 //~ Begin UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
143 LANDSCAPE_API virtual TArray<UE::Landscape::EditLayers::FEditLayerRendererState> GetEditLayerRendererStates(const UE::Landscape::EditLayers::FMergeContext* InMergeContext) override;
144 //~ End UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
145#endif // WITH_EDITOR
146
147private:
148
149#if WITH_EDITORONLY_DATA
150 UPROPERTY()
152#endif // WITH_EDITORONLY_DATA
153};
154
155// TODO [jonathan.bard] : deprecate this
156UENUM()
163
164USTRUCT()
166#if CPP && WITH_EDITOR // UHT doesn't support inheriting from namespaced class
167 : public UE::Landscape::EditLayers::IEditLayerRendererProvider
168#endif // CPP && WITH_EDITOR
169{
171
174
175 virtual ~FLandscapeLayer() = default;
176
177#if WITH_EDITOR
178 //~ Begin UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
179 LANDSCAPE_API virtual TArray<UE::Landscape::EditLayers::FEditLayerRendererState> GetEditLayerRendererStates(const UE::Landscape::EditLayers::FMergeContext* InMergeContext) override;
180 //~ End UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
181#endif // WITH_EDITOR
182public:
183 UPROPERTY(meta = (IgnoreForMemberInitializationTest))
184 FGuid Guid_DEPRECATED = FGuid::NewGuid();
185
186 UPROPERTY()
187 FName Name_DEPRECATED = NAME_None;
188
190 bool bVisible_DEPRECATED = true;
191
192 UPROPERTY()
193 bool bLocked_DEPRECATED = false;
194
195 UPROPERTY()
196 float HeightmapAlpha_DEPRECATED = 1.0f;
197
198 UPROPERTY()
199 float WeightmapAlpha_DEPRECATED = 1.0f;
200
201 UPROPERTY()
203
204 UPROPERTY()
206
207 UPROPERTY()
208 TMap<TObjectPtr<ULandscapeLayerInfoObject>, bool> WeightmapLayerAllocationBlend_DEPRECATED; // True -> Substractive, False -> Additive
209
210 UPROPERTY(Instanced)
212};
213
214
215enum class UE_DEPRECATED(5.7, "Edit layers are now fully processed via BatchedMerge") ELandscapeEditLayersMergeMode : uint8
216{
217 GlobalMerge = 0,
218 LocalMerge,
220 Invalid
221};
222
223// TODO [jonathan.bard] : When global merge is a thing of the past, we should pass FOnRenderBatchTargetGroupDoneParams here, or extract some of its higher-level information, because there
224// is a lot more useful information accessible in there (components being rendered, target layers, validity render targets, etc.)
245
247{
248 // Region to render, in Landscape coordinates
250
251 // Which edit layers to include. Order matches ALandscape::GetEditLayers().
253
254 bool bRenderBrushes = true;
255};
256
257// Parameters to describe a subset of a landscape heightmap to render. Can select a subset of edit layers and a subregion of the landscape coordinates.
259{
260 // Provide either a cpu buffer or render target to receive the data. Buffer should be allocated large enough to receive the samples in Bounds.
263};
264
265// Parameters to describe a subset of a landscape weightmaps to render. Can select a subset of edit layers and a subregion of the landscape coordinates, for a list of weightmaps.
267{
269
270 // Provide either a cpu buffer or render target to receive the data. Buffer should be allocated large enough to receive the samples in Bounds.
273};
274
275UCLASS(MinimalAPI, showcategories=(Display, Movement, Collision, Lighting, LOD, Input), hidecategories=(Mobility))
276class ALandscape : public ALandscapeProxy
277#if CPP && WITH_EDITOR // UHT doesn't support inheriting from namespaced class
278 , public UE::Landscape::EditLayers::IEditLayerRendererProvider
279#endif // CPP && WITH_EDITOR
280{
282
283 friend class FLandscapeConfigHelper; // For copying/manipulating internal data
284
285public:
287
288 //~ Begin ALandscapeProxy Interface
289 LANDSCAPE_API virtual ALandscape* GetLandscapeActor() override;
290 LANDSCAPE_API virtual const ALandscape* GetLandscapeActor() const override;
291 //~ End ALandscapeProxy Interface
292
293#if WITH_EDITOR
295
296 LANDSCAPE_API bool HasAllComponent(); // determine all component is in this actor
297
298 // Include Components with overlapped vertices
299 // X2/Y2 Coordinates are "inclusive" max values
300 LANDSCAPE_API static void CalcComponentIndicesOverlap(const int32 X1, const int32 Y1, const int32 X2, const int32 Y2, const int32 ComponentSizeQuads,
302
303 // Exclude Components with overlapped vertices
304 // X2/Y2 Coordinates are "inclusive" max values
305 LANDSCAPE_API static void CalcComponentIndicesNoOverlap(const int32 X1, const int32 Y1, const int32 X2, const int32 Y2, const int32 ComponentSizeQuads,
307
309
310 //~ Begin APartitionActor Interface
311 virtual bool IsPartitionActorNameAffectedByDataLayers() const { return false; }
312 //~ End APartitionActor Interface
313
314 //~ Begin UObject Interface.
315 virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
316 virtual void PostEditMove(bool bFinished) override;
317 virtual void PostEditUndo() override;
318 virtual void PostRegisterAllComponents() override;
319 virtual void PostActorCreated() override;
320 virtual bool ShouldImport(FStringView ActorPropString, bool IsMovingLevel) override;
321 virtual void PostEditImport() override;
322 virtual void PostDuplicate(bool bDuplicateForPIE) override;
323 virtual bool CanDeleteSelectedActor(FText& OutReason) const override;
324 virtual bool CanChangeIsSpatiallyLoadedFlag() const override { return false; }
325#endif // WITH_EDITOR
326
327 virtual void PostLoad() override;
328 //~ End UObject Interface
329
331 LANDSCAPE_API FBox GetLoadedBounds() const;
332
333 LANDSCAPE_API bool IsUpToDate() const;
334 LANDSCAPE_API void TickLayers(float DeltaTime);
335
338
347 UFUNCTION(BlueprintCallable, Category = "Landscape|Runtime")
349
359 UFUNCTION(BlueprintCallable, Category = "Landscape|Runtime")
361
373 UFUNCTION(BlueprintCallable, Category = "Landscape|Runtime")
375
381 UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "Landscape|Editor", meta=(DevelopmentOnly))
383
386
387#if WITH_EDITOR
388
392 void UnregisterLandscapeEdMode() { LandscapeEdMode = nullptr; }
393 bool HasLandscapeEdMode() const { return LandscapeEdMode != nullptr; }
394 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated, all landscapes use the edit layer system now.")
395 LANDSCAPE_API virtual bool HasLayersContent() const override;
396 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated, all landscapes use the edit layer system now.")
400 LANDSCAPE_API void RequestLayersContentUpdateForceAll(ELandscapeLayerUpdateMode InModeMask = ELandscapeLayerUpdateMode::Update_All, bool bInUserTriggered = false);
404
414
416 LANDSCAPE_API void CopyOldDataToDefaultLayer(ALandscapeProxy* InProxy);
417
426
427 LANDSCAPE_API void AddLayersToProxy(ALandscapeProxy* InProxy);
429 LANDSCAPE_API bool IsLayerNameUnique(const FName& InName) const;
430
431 UE_DEPRECATED(5.6, "Use SetName on the ULandscapeEditLayerBase object")
432 LANDSCAPE_API void SetLayerName(int32 InLayerIndex, const FName& InName);
433 UE_DEPRECATED(5.6, "Use SetAlphaForTargetType on the ULandscapeEditLayerBase object")
435 UE_DEPRECATED(5.6, "Use GetAlphaForTargetType on the ULandscapeEditLayerBase object")
437 UE_DEPRECATED(5.6, "Unused : The edit layer class clamps the alpha already")
439 UE_DEPRECATED(5.6, "Use SetVisibility on the ULandscapeEditLayerBase object")
441 UE_DEPRECATED(5.6, "Use SetLocked on the ULandscapeEditLayerBase object")
443 UE_DEPRECATED(5.6, "Unused: Override the GetBlendMode virtual method in ULandscapeEditLayerBase instead")
445
446 // FLandscapeLayer accessors : only the const version is provided because we don't want to let them be mutated freely without the landscape being aware
455
456 // ULandscapeEditLayerBase accessors : both const and non-const versions are provided because the landscape listens to data changes on the edit layer object
457 // and can therefore react to any change
466
471
472 UE_DEPRECATED(5.6, "Use GetLayersConst().Num()")
473 LANDSCAPE_API uint8 GetLayerCount() const;
474 UE_DEPRECATED(5.6, "Use GetLayersConst")
476
487
492
494 UE_DEPRECATED(5.7, "ELandscapeClearMode is deprecated, use ClearEditLayer with ELandscapeToolTargetType instead.")
496 UE_DEPRECATED(5.7, "ELandscapeClearMode is deprecated, use ClearEditLayer with ELandscapeToolTargetType instead.")
497 LANDSCAPE_API void ClearLayer(const FGuid& InLayerGuid, TSet<TObjectPtr<ULandscapeComponent>>* InComponents = nullptr, ELandscapeClearMode InClearMode = ELandscapeClearMode::Clear_All, bool bMarkPackageDirty = true);
499
502
505 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated. Use CollapseAllEditLayers to flatten data to the base edit layer.")
510 LANDSCAPE_API const FGuid& GetEditingLayer() const;
514 UE_DEPRECATED(5.7, "Use UpdateLandscapeSplines without bInUpdateOnlySelected. Edit layer landscapes update all splines regardless of selection state")
519
520 UE_DEPRECATED(5.6, "Use ULandscapeEditLayerSplines GetWeightmapLayerAllocationBlend().Find instead")
522 UE_DEPRECATED(5.6, "Use ULandscapeEditLayerSplines AddOrUpdateWeightmapAllocationLayerBlend instead")
525
537 LANDSCAPE_API void OnPreSave();
538
539 void ClearDirtyData(ULandscapeComponent* InLandscapeComponent);
540
542 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated. Use ConvertNonEditLayerLandscape to convert to non-edit layer landscapes to edit layer based landscapes.")
545 UE_DEPRECATED(5.7, "Intermediate renders are a thing of the past. You should now use SelectiveRenderEditLayersHeightmaps/SelectiveRenderEditLayersWeightmaps to render the landscape edit layers in an \"intermediate\" state")
547
550
552
553 UFUNCTION(BlueprintCallable, Category = "Landscape")
555
557
561
565
567 {
568 Default = 0, // Default operation
569 WaitForStreaming = 1 << 0, // Block until streaming completes
570 BypassRateLimit = 1 << 1 // Bypass rate limit and always call PrepareTextureResources
571 };
573 bool PrepareTextureResourcesLimited(EPrepareTextureResourcesLimitedMode Mode = EPrepareTextureResourcesLimitedMode::Default);
574
575 bool GetVisibilityLayerAllocationIndex() const { return 0; }
576
577 LANDSCAPE_API virtual void DeleteUnusedLayers() override;
578
580
583
585
587
588private:
592
594 bool CanUpdateLayersContent() const;
597
598 //~ Begin UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
599 virtual TArray<UE::Landscape::EditLayers::FEditLayerRendererState> GetEditLayerRendererStates(const UE::Landscape::EditLayers::FMergeContext* InMergeContext) override;
600 //~ End UE::Landscape::EditLayers::IEditLayerRendererProvider implementation
602
603 UE::Landscape::EditLayers::FMergeRenderContext PrepareEditLayersMergeRenderContext(const UE::Landscape::EditLayers::FMergeContext& InMergeContext, const UE::Landscape::EditLayers::FMergeRenderParams& InParams);
604
608
611
616
619
625
630
632
635 void InitializeLayers();
636
639 void UpdateHeightDirtyData(ULandscapeComponent* InLandscapeComponent, UTexture2D const* InHeightmap, FColor const* InOldData, FColor const* InNewData);
641
643
645#endif // WITH_EDITOR
646
647private:
650
651public:
652
653#if WITH_EDITORONLY_DATA
655 UPROPERTY(EditAnywhere, Category = WorldPartition)
657
659 UPROPERTY()
661
662 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated, all landscapes use the edit layer system now.")
663 UPROPERTY()
665
666 /*
667 * If true, WorldPartitionLandscapeSplineMeshesBuilder is responsible of generating partitioned actors of type ALandscapeSplineMeshesActor that will contain all landscape spline/controlpoints static meshes.
668 * Source components will be editor only and hidden in game for PIE.
669 */
670 UPROPERTY()
672
675
678 FOnEditLayersMergedDelegate::RegistrationType& OnEditLayersMerged() const { return OnEditLayersMergedDelegate; }
679
681 UE_DEPRECATED(all, "This has been refactored into the generic ULandscapeEditLayerBase system. Please check for the presence of a ULandscapeEditLayerSplines layer instead")
682 UPROPERTY()
684
686 // TODO this is used as shared global state for the landscape editor mode. FLandscapeToolStrokeBase::SetEditLayer should manage the shared editor state instead
688
690 UPROPERTY(Transient, DuplicateTransient)
692
695
697 bool bEnableEditorLayersTick = true;
698
699 UPROPERTY(Transient, DuplicateTransient, TextExportTransient, NonPIEDuplicateTransient)
701
702 UE_DEPRECATED(all, "This property has moved to private. Use the public accessors instead")
703 UPROPERTY()
705
706 UE_DEPRECATED(5.7, "Edit layers are now fully processed via BatchedMerge")
709
710 UE_DEPRECATED(5.7, "Edit layers are now fully processed via BatchedMerge")
713
715 UPROPERTY(Transient, DuplicateTransient, TextExportTransient)
717
719 UPROPERTY(NonTransactional)
721
723 UPROPERTY(NonTransactional)
725
726private:
727 UPROPERTY()
729
732
736
739
742 {
744
745 int32 ViewMode;
749 };
750
752
753 // TODO [jonathan.bard] : remove : this isn't really used anymore
756
759
762
765
766 bool bWarnedLayerMergeResolution = false;
767
769 {
771 void Reset();
772
774 double WaitingForResourcesStartTime = -1.0;
775
778 };
779
783
788
789 // Counter to detect re-entrance
791#endif
792};
793
794#if WITH_EDITOR
796{
797public:
800
801private:
804 TFunction<void()> CompletionCallback;
805};
806#endif
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
constexpr auto MakeArrayView(OtherRangeType &&Other)
Definition ArrayView.h:873
@ ForceInit
Definition CoreMiscDefines.h:155
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_EVENT(OwningType, EventName)
Definition DelegateCombinations.h:32
#define DECLARE_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
DIRECTLINK_API Display
Definition DirectLinkLog.h:8
#define FRIEND_ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:17
return true
Definition ExternalRpcRegistry.cpp:601
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
ELandscapeToolTargetTypeFlags
Definition LandscapeEditTypes.h:22
ELandscapeToolTargetType
Definition LandscapeEditTypes.h:12
ELandscapeLayerDisplayMode
Definition LandscapeProxy.h:215
EHeightmapRTType
Definition Landscape.h:75
EWeightmapRTType
Definition Landscape.h:94
ELandscapeBlendMode
Definition Landscape.h:158
@ LSBM_AlphaBlend
Definition Landscape.h:160
@ LSBM_AdditiveBlend
Definition Landscape.h:159
@ LSBM_MAX
Definition Landscape.h:161
ERTDrawingType
Definition Landscape.h:65
FInt32Point FIntPoint
Definition MathFwd.h:124
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EPixelFormat
Definition PixelFormat.h:16
EShaderPlatform
Definition RHIShaderPlatform.h:11
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition LandscapeBlueprintBrushBase.h:46
Definition LandscapeEditReadback.h:17
Definition MaterialShared.h:3076
Definition MaterialShared.h:3326
Definition NameTypes.h:617
Definition UObjectGlobals.h:1292
Definition Text.h:385
Definition TextureResource.h:363
Definition Landscape.Build.cs:7
Definition SNotificationList.h:25
Definition ArrayView.h:139
Definition Array.h:670
Definition IConsoleManager.h:1792
Definition EnumAsByte.h:22
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition UnrealString.h.inl:34
Definition SharedPointer.h:692
Definition SubclassOf.h:30
Definition LandscapeEditLayer.h:46
Definition LandscapeLayerInfoObject.h:60
Definition StreamableRenderAsset.h:37
Definition Texture2D.h:26
Definition TextureRenderTarget2D.h:104
Definition TextureRenderTarget.h:22
Definition Landscape.h:55
Definition WorldPartition.cpp:74
@ false
Definition radaudio_common.h:23
Definition Color.h:486
Definition Guid.h:109
Definition Landscape.h:247
TBitArray ActiveEditLayers
Definition Landscape.h:252
bool bRenderBrushes
Definition Landscape.h:254
FIntRect Bounds
Definition Landscape.h:249
Definition Landscape.h:259
TArrayView< uint16 > CpuResult
Definition Landscape.h:261
UTextureRenderTarget2D * RTResult
Definition Landscape.h:262
Definition Landscape.h:267
TArrayView< FName > WeightmapNames
Definition Landscape.h:268
TArrayView< uint8 > CpuResult
Definition Landscape.h:271
UTextureRenderTarget2D * RTResult
Definition Landscape.h:272
Definition Landscape.h:122
virtual ~FLandscapeLayerBrush()=default
Definition Landscape.h:169
virtual ~FLandscapeLayer()=default
Definition LandscapeEditLayer.h:15
Definition Landscape.h:226
UTextureRenderTarget * RenderTarget
Definition Landscape.h:237
FOnLandscapeEditLayersMergedParams(UTextureRenderTarget *InRenderTarget, const FIntPoint &InRenderAreaResolution, bool bInIsHeightmapMerge)
Definition Landscape.h:227
bool bIsHeightmapMerge
Definition Landscape.h:243
FIntPoint RenderAreaResolution
Definition Landscape.h:241
Definition UnrealType.h:6865
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:25
Definition IntPoint.h:25