UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LandscapeInfo.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"
7#include "UObject/Object.h"
8#include "Misc/Guid.h"
12
13#if WITH_EDITOR
15#endif
16
17#include "LandscapeInfo.generated.h"
18
19class ALandscape;
20class ALandscapeProxy;
23class ULandscapeComponent;
25class ULevel;
33class FModulateAlpha;
34
36#if WITH_EDITORONLY_DATA
38{
39 FVector Corners[4];
40
42 {
43 Corners[0] = Corners[1] = Corners[2] = Corners[3] = FVector::ZeroVector;
44 }
45};
46#endif // WITH_EDITORONLY_DATA
47
48class ULandscapeInfo;
49
50#if WITH_EDITOR
52{
55 FLandscapeDirtyOnlyInModeScope(ULandscapeInfo* InLandscapeInfo, bool bInOverrideDirtyMode); /* Override the dirtying in Landscape mode behaviour*/
57
58private:
61};
62#endif
63
64USTRUCT()
66{
68
69 UPROPERTY()
71
72 UPROPERTY()
73 FName LayerName;
74
75#if WITH_EDITORONLY_DATA
78
79 UPROPERTY()
80 TWeakObjectPtr<ALandscapeProxy> Owner;
81
84#endif // WITH_EDITORONLY_DATA
85
87 : LayerInfoObj(nullptr)
88 , LayerName(NAME_None)
90 , ThumbnailMIC(nullptr)
91 , Owner(nullptr)
93#endif // WITH_EDITORONLY_DATA
94 {
95 }
96
99
101
102#if WITH_EDITORONLY_DATA
104#endif // WITH_EDITORONLY_DATA
105};
106
109{
111
112 friend class ALandscapeProxy;
113
114 UPROPERTY()
115 TWeakObjectPtr<ALandscape> LandscapeActor;
116
117 UPROPERTY()
118 FGuid LandscapeGuid;
119
120 UPROPERTY()
121 int32 ComponentSizeQuads;
122
123 UPROPERTY()
124 int32 SubsectionSizeQuads;
125
126 UPROPERTY()
127 int32 ComponentNumSubsections;
128
129#if WITH_EDITORONLY_DATA
131 UPROPERTY()
133
134 UPROPERTY()
135 FVector DrawScale = FVector(100.0);
136
137 UPROPERTY()
139
140 UPROPERTY()
142#endif // WITH_EDITORONLY_DATA
143
144public:
149
150#if WITH_EDITORONLY_DATA
154#endif // WITH_EDITORONLY_DATA
155
156 UE_DEPRECATED(5.7, "StreamingProxies rely on a sorted state and should not be modified outside of ULandscapeInfo. Use GetSortedStreamingProxies instead.")
157 UPROPERTY()
158 TArray<TWeakObjectPtr<ALandscapeStreamingProxy>> StreamingProxies_DEPRECATED;
159
160private:
161#if WITH_EDITORONLY_DATA
162 // SORTED list of all actors implementing the spline interface that are registered with this landscape info
163 UPROPERTY()
165
166 // Not properties since these shouldn't be modified through transactions (no undo/redo)
169
170 bool bDirtyOnlyInMode;
171
173#endif // WITH_EDITORONLY_DATA
174
175 TSet<ULandscapeComponent*> SelectedComponents;
176
177 TSet<ULandscapeComponent*> SelectedRegionComponents;
178
179 FIntRect XYComponentBounds;
180
181public:
183
184 //~ Begin UObject Interface.
185 virtual void Serialize(FArchive& Ar) override;
186 //~ End UObject Interface
187
188 LANDSCAPE_API FBox GetLoadedBounds() const;
189
190#if WITH_EDITOR
192#endif
193
194#if WITH_EDITOR
195 // @todo document
196 // all below.
198 // False if landscape editing not supported, in PIE world, or in a Commandlet
200
204 LANDSCAPE_API bool GetLandscapeExtent(ALandscapeProxy* Proxy, FIntRect& ProxyExtent) const;
206 LANDSCAPE_API bool GetLandscapeExtent(int32& MinX, int32& MinY, int32& MaxX, int32& MaxY) const;
209 LANDSCAPE_API void ForAllLandscapeComponents(TFunctionRef<void(ULandscapeComponent*)> Fn) const;
210 LANDSCAPE_API void ExportHeightmap(const FString& Filename);
211 LANDSCAPE_API void ExportHeightmap(const FString& Filename, const FIntRect& ExportRegion);
212 LANDSCAPE_API void ExportLayer(ULandscapeLayerInfoObject* LayerInfo, const FString& Filename);
213 LANDSCAPE_API void ExportLayer(ULandscapeLayerInfoObject* LayerInfo, const FString& Filename, const FIntRect& ExportRegion);
214 UE_DEPRECATED(5.7, "Use ApplySplines without bOnlySelected. Edit layer landscapes update all splines regardless of selection state")
215 LANDSCAPE_API bool ApplySplines(bool bOnlySelected, TSet<TObjectPtr<ULandscapeComponent>>* OutModifiedComponents = nullptr, bool bMarkPackageDirty = true);
216 LANDSCAPE_API bool ApplySplines(TSet<TObjectPtr<ULandscapeComponent>>* OutModifiedComponents = nullptr, bool bMarkPackageDirty = true);
217
218 LANDSCAPE_API bool GetSelectedExtent(int32& MinX, int32& MinY, int32& MaxX, int32& MaxY) const;
221 LANDSCAPE_API void DeleteLayer(ULandscapeLayerInfoObject* LayerInfo, const FName& LayerName);
224
226
227 LANDSCAPE_API TSet<ULandscapeComponent*> GetSelectedComponents() const;
228 LANDSCAPE_API TSet<ULandscapeComponent*> GetSelectedRegionComponents() const;
229 LANDSCAPE_API void UpdateSelectedComponents(TSet<ULandscapeComponent*>& NewComponents, bool bIsComponentwise = true);
231
232 // only for use by the "add component" tool. Todo - move into the tool?
234 LANDSCAPE_API void UpdateAddCollision(FIntPoint LandscapeKey);
235
237
239
240 LANDSCAPE_API ULandscapeLayerInfoObject* GetLayerInfoByName(FName LayerName, ALandscapeProxy* Owner = nullptr) const;
241 LANDSCAPE_API int32 GetLayerInfoIndex(FName LayerName, ALandscapeProxy* Owner = nullptr) const;
242 LANDSCAPE_API int32 GetLayerInfoIndex(ULandscapeLayerInfoObject* LayerInfo, ALandscapeProxy* Owner = nullptr) const;
243 LANDSCAPE_API bool UpdateLayerInfoMap(ALandscapeProxy* Proxy = nullptr, bool bInvalidate = false);
244
246
252 LANDSCAPE_API ALandscapeProxy* GetLandscapeProxyForLevel(ULevel* Level) const;
253
255
259 LANDSCAPE_API bool IsPackageModified(UPackage* InPackage) const;
266
278 LANDSCAPE_API bool ModifyObject(UObject* InObject, bool bAlwaysMarkDirty = true);
287 LANDSCAPE_API bool MarkObjectDirty(UObject* InObject, bool bInForceResave = false, const ALandscape* InLandscapeOverride = nullptr);
288
295
300#endif //WITH_EDITOR
301
307 LANDSCAPE_API ALandscapeProxy* GetCurrentLevelLandscapeProxy(bool bRegistered) const;
308
313 LANDSCAPE_API ALandscapeProxy* GetLandscapeProxy() const;
314
315#if WITH_EDITOR
316
318 LANDSCAPE_API void Reset();
319
324
331 LANDSCAPE_API void FixupProxiesTransform(bool bDirty = false);
332
333 // Update per-component layer allow list to include the currently painted layers
335
337
339
341 UE_DEPRECATED(5.7, "Non-edit layer landscapes are deprecated, all landscapes use the edit layer system now.")
343
346
348 LANDSCAPE_API ALandscapeProxy* MoveComponentsToLevel(const TArray<ULandscapeComponent*>& InComponents, ULevel* TargetLevel, FName NewProxyName = NAME_None);
349
351 LANDSCAPE_API ALandscapeProxy* MoveComponentsToProxy(const TArray<ULandscapeComponent*>& InComponents, ALandscapeProxy* LandscapeProxy, bool bSetPositionAndOffset = false, ULevel* TargetLevel = nullptr);
352
355
358
361
364
367
370
373
376
379#endif
380 LANDSCAPE_API static ULandscapeInfo* Find(UWorld* InWorld, const FGuid& LandscapeGuid);
381 LANDSCAPE_API static ULandscapeInfo* FindOrCreate(UWorld* InWorld, const FGuid& LandscapeGuid);
382 LANDSCAPE_API static int32 RemoveLandscapeInfo(UWorld* InWorld, const FGuid& LandscapeGuid);
383
386
388 LANDSCAPE_API const TArray<TWeakObjectPtr<ALandscapeStreamingProxy>>& GetSortedStreamingProxies() const;
389
398 LANDSCAPE_API void ForEachLandscapeProxy(TFunctionRef<bool(ALandscapeProxy*)> Fn) const;
399
400 void UpdateNanite(const ITargetPlatform* InTargetPlatform);
401
406 LANDSCAPE_API void RegisterActor(ALandscapeProxy* Proxy, bool bMapCheck = false, bool bUpdateAllAddCollisions = true);
407
409 LANDSCAPE_API void UnregisterActor(ALandscapeProxy* Proxy);
410
412 bool IsRegistered(const ALandscapeProxy* Proxy) const;
413
418 LANDSCAPE_API void RegisterActorComponent(ULandscapeComponent* Component, bool bMapCheck = false);
419
421 LANDSCAPE_API void UnregisterActorComponent(ULandscapeComponent* Component);
422
424 LANDSCAPE_API void RegisterCollisionComponent(ULandscapeHeightfieldCollisionComponent* Component);
425 LANDSCAPE_API void UnregisterCollisionComponent(ULandscapeHeightfieldCollisionComponent* Component);
426
437 // TODO [jonathan.bard] : There should be multiple versions of this.
438 // 1. This currently performs AABB to AABB checks and is therefore not optimal (but faster than OOBB to OOBB could ever be, which is why we might need 2 versions) :
439 // 2. Returning a TMap<> is a bit overkill, since the component key can be retrieved trivially from the component
441
442#if WITH_EDITOR
444
447
450
454
457
459
460private:
461 inline static bool bForceNonSpatiallyLoadedByDefault = false;
462
466 bool UpdateLayerInfoMapInternal(ALandscapeProxy* Proxy);
467 bool TryAddToModifiedPackages(UPackage* InPackage, const ALandscape* InLandscapeOverride = nullptr);
469
470 void OnMarkPackageDirty(UPackage* InPackage, bool bIsDirty);
471#endif
472
473private:
474 void RegisterLandscapeActorWithProxyInternal(ALandscapeProxy* Proxy, bool bMapCheck);
475
477 void SortStreamingProxies();
478
479 UPROPERTY()
480 TArray<TWeakObjectPtr<ALandscapeStreamingProxy>> SortedStreamingProxies;
481};
#define WITH_EDITORONLY_DATA
Definition CoreMiscDefines.h:24
#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
return true
Definition ExternalRpcRegistry.cpp:601
#define X(Name, Desc)
Definition FormatStringSan.h:47
const bool
Definition NetworkReplayStreaming.h:178
#define MAX_int32
Definition NumericLimits.h:25
#define MIN_int32
Definition NumericLimits.h:16
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
bool IsRegistered(FRDGBuilder &GraphBuilder, const TRefCountPtr< IPooledRenderTarget > &RenderTarget)
Definition RenderGraphUtils.h:111
if(Failed) console_printf("Failed.\n")
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition LandscapeSplineActor.h:15
Definition LandscapeStreamingProxy.h:20
Definition Archive.h:1208
Definition NameTypes.h:617
Definition Text.h:385
Definition ILandscapeSplineInterface.h:20
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition ScriptInterface.h:139
Definition SharedPointer.h:692
Definition LandscapeHeightfieldCollisionComponent.h:41
Definition LandscapeInfo.h:109
TMap< FIntPoint, ULandscapeComponent * > XYtoComponentMap
Definition LandscapeInfo.h:146
TMap< FIntPoint, float > SelectedRegion
Definition LandscapeInfo.h:182
TMap< FIntPoint, ULandscapeHeightfieldCollisionComponent * > XYtoCollisionComponentMap
Definition LandscapeInfo.h:148
Definition LandscapeLayerInfoObject.h:60
Definition LandscapeSplineControlPoint.h:51
Definition LandscapeSplineSegment.h:195
Definition LandscapeSplinesComponent.h:103
Definition Level.h:423
Definition MaterialInstanceConstant.h:21
Definition Object.h:95
Definition Package.h:216
Definition World.h:918
@ false
Definition radaudio_common.h:23
Definition Guid.h:109
Definition LandscapeInfo.h:66
FLandscapeInfoLayerSettings()
Definition LandscapeInfo.h:86
LANDSCAPE_API FName GetLayerName() const
Definition LandscapeProxy.h:91
Definition ObjectPtr.h:488
Definition WeakObjectPtrTemplates.h:396
Definition WeakObjectPtrTemplates.h:25
Definition IntPoint.h:25
static CORE_API const TVector< double > ZeroVector
Definition Vector.h:79