UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LandscapeSubsystem.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"
9#include "LandscapeSubsystem.generated.h"
10
11class ALandscapeProxy;
12class ALandscape;
14class AWorldSettings;
16class ULandscapeInfo;
18class ULandscapeComponent;
22struct FDateTime;
23struct FScopedSlowTask;
25struct FLandscapeGroup;
26enum class EUpdateTransformFlags : int32;
27
28namespace UE::Landscape
29{
30 enum class EOutdatedDataFlags : uint8;
31 enum class EBuildFlags : uint8;
32
33#if WITH_EDITOR
36
39
40 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
43
44 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
47
48 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
51
52 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
55
56 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
59#endif // WITH_EDITOR
60
61 namespace Nanite
62 {
63 struct FAsyncBuildData;
64 }
65} // end of namespace UE::Landscape
66
67#if WITH_EDITOR
69{
70private:
71 const ALandscape* Landscape = nullptr;
72 const FBox2D& UpdateRegion;
74
75public:
76 const ALandscape* GetLandscape() const
77 {
78 return Landscape;
79 }
80
81 const FBox2D& GetUpdateRegion() const
82 {
83 return UpdateRegion;
84 }
85
87 {
89 }
90
93 , UpdateRegion(InUpdateRegion)
95 {}
96};
97
99#endif // WITH_EDITOR
100
101UCLASS(MinimalAPI)
103{
105
106public:
108 virtual ~ULandscapeSubsystem();
109
110 void RegisterActor(ALandscapeProxy* Proxy);
111 void UnregisterActor(ALandscapeProxy* Proxy);
112
113 // Begin FTickableGameObject overrides
114 virtual void Tick(float DeltaTime) override;
115 virtual bool IsTickableInEditor() const override { return true; }
116 virtual ETickableTickType GetTickableTickType() const override;
117 virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override;
118 virtual TStatId GetStatId() const override;
119 // End FTickableGameObject overrides
120
121 static void AddReferencedObjects(UObject* InThis, FReferenceCollector& Collector);
122
123 // setting this to true causes grass instance generation to go wider (multiplies the limits by GGrassCreationPrioritizedMultipler)
125 bool IsGrassCreationPrioritized() const { return bIsGrassCreationPrioritized; }
126 FLandscapeGrassMapsBuilder* GetGrassMapBuilder() { return GrassMapsBuilder; }
128
136
137 // Remove all grass instances from the specified components. If passed null, removes all grass instances from all proxies.
138 void RemoveGrassInstances(const TSet<ULandscapeComponent*>* ComponentsToRemoveGrassInstances = nullptr);
139
140 // called when components are registered to the world
141 void RegisterComponent(ULandscapeComponent* Component);
142 void UnregisterComponent(ULandscapeComponent* Component);
143
144 void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld);
145
146#if WITH_EDITOR
147 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
148 LANDSCAPE_API void BuildAll();
149 LANDSCAPE_API void BuildAll(UE::Landscape::EBuildFlags InBuildFlags);
150
151 // Synchronously build grass maps for all components
152 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
155
156 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
159
160 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
161 LANDSCAPE_API void BuildNanite(TArrayView<ALandscapeProxy*> InProxiesToBuild = TArrayView<ALandscapeProxy*>(), bool bForceRebuild = false);
167 LANDSCAPE_API void BuildNanite(UE::Landscape::EBuildFlags InBuildFlags, TArrayView<ALandscapeProxy*> InProxiesToBuild = TArrayView<ALandscapeProxy*>());
168
169 LANDSCAPE_API TArray<TTuple<ALandscapeProxy*, UE::Landscape::EOutdatedDataFlags>> GetOutdatedProxyDetails(UE::Landscape::EOutdatedDataFlags InMatchingOutdatedDataFlags, bool bInMustMatchAllFlags) const;
170
171 LANDSCAPE_API bool IsGridBased() const;
173 LANDSCAPE_API ALandscapeProxy* FindOrAddLandscapeProxy(ULandscapeInfo* LandscapeInfo, const FIntPoint& SectionBase);
174
176 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
179 UE_DEPRECATED(5.6, "Use the function with the EBuildFlags param")
186
188 {
189 return NotificationManager;
190 }
191
192 UE_DEPRECATED(5.6, "Use OnHeightmapStreamed()")
194 {
196 }
197
198 FOnHeightmapStreamedDelegate::RegistrationType& OnHeightmapStreamed()
199 {
201 }
202
203 FOnLandscapeProxyComponentDataChanged::RegistrationType& OnLandscapeProxyComponentDataChanged() const
204 {
206 }
207
208 FOnLandscapeProxyMaterialChanged::RegistrationType& OnLandscapeProxyMaterialChanged() const
209 {
211 }
212
213 bool AnyViewShowCollisions() const { return bAnyViewShowCollisions; }
215
216 UE_DEPRECATED(5.6, "AddAsyncEvent is now deprecated")
217 LANDSCAPE_API void AddAsyncEvent(FGraphEventRef GraphEventRef);
218
219 TSharedRef<UE::Landscape::Nanite::FAsyncBuildData> CreateTrackedNaniteBuildState(ALandscapeProxy* LandscapeProxy, int32 InLODToExport, const TArray<ULandscapeComponent*>& InComponentsToExport);
220
222 {
223 Default = 0x00,
225 AllowCancel = 0x02,
226 };
227
229
230 // returns true if all nanite builds were completed (false if cancelled, or failed to complete)
232
233 // Returns true if we should build nanite meshes in parallel asynchronously.
235
236 // Returns true if the user has requested Nanite Meshes to be generated on landscape edit. If we return false then the nanite build will happen either on map save or explicit build
238
239 bool AreNaniteBuildsInProgress() const;
240 void IncNaniteBuild();
241 void DecNaniteBuild();
242
243 // Wait unit we're able to continue a landscape export task (Max concurrent nanite mesh builds is defined by landscape.Nanite.MaxSimultaneousMultithreadBuilds and landscape.Nanite.MultithreadBuild CVars)
244 void WaitLaunchNaniteBuild();
245
246 // Helper class reserved for friends that are allowed to fire the subsystem's inner callbacks
247 class FDelegateAccess
248 {
249 friend ULandscapeSubsystem;
250 friend ALandscape;
251 friend ALandscapeProxy;
252
254
258 };
260#endif // WITH_EDITOR
261
262 // runs per-tick edge fixup on ALL landscape groups in the subsystem
263 void TickEdgeFixup();
264
265 FLandscapeGroup* GetLandscapeGroupForProxy(ALandscapeProxy* Proxy);
266 FLandscapeGroup* GetLandscapeGroupForComponent(ULandscapeComponent* Component);
267
268 LANDSCAPE_API void ForEachLandscapeInfo(TFunctionRef<bool(ULandscapeInfo*)> ForEachLandscapeInfoFunc) const;
269
270private:
271
272 // Begin USubsystem
273 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
274 virtual void Deinitialize() override;
275 // End USubsystem
276
277 void OnNaniteWorldSettingsChanged(AWorldSettings* WorldSettings) { RegenerateGrass(true, true); }
278 void OnNaniteEnabledChanged(IConsoleVariable*);
279
280 void HandlePostGarbageCollect();
281
282 TSet<UPackage*> GetDirtyLandscapeProxyPackages() const;
283
284 // When proxies move, we may need to update their position in the landscape group
285 void OnProxyMoved(USceneComponent*, EUpdateTransformFlags, ETeleportType);
286
287#if WITH_EDITOR
289#endif // WITH_EDITOR
290
291private:
292 // LODGroupKey --> Landscape Group
294
295 // list of streaming proxies that need to re-register with their group because they moved, or changed their LODGroupKey
296 UPROPERTY(Transient, DuplicateTransient, NonTransactional)
297 TSet<TObjectPtr<ALandscapeStreamingProxy>> StreamingProxiesNeedingReregister;
298
299 bool bIsGrassCreationPrioritized = false;
300
301 UPROPERTY(Transient, DuplicateTransient, NonTransactional)
302 TArray<TObjectPtr<ALandscape>> LandscapeActors;
303
304 // UPROPERTY ensures these objects are not deleted before being unregistered
305 // (technically not necessary, as actors should always unregister prior to deletion)
306 UPROPERTY(Transient, DuplicateTransient, NonTransactional)
308
309 FDelegateHandle OnNaniteWorldSettingsChangedHandle;
310
311 FLandscapeTextureStreamingManager* TextureStreamingManager = nullptr;
312 FLandscapeGrassMapsBuilder* GrassMapsBuilder = nullptr;
313
314#if WITH_EDITORONLY_DATA
318
321 bool bAnyViewShowCollisions = false;
322 FDateTime AppCurrentDateTime; // Represents FDateTime::Now(), at the beginning of the frame (useful to get a human-readable date/time that is fixed during the frame)
324
325 // A list of graph events that track the status of
329
330 std::atomic<int32> NaniteBuildsInFlight;
331 std::atomic<int32> NaniteStaticMeshesInFlight;
332
333#endif // WITH_EDITORONLY_DATA
334
335 FDelegateHandle OnScalabilityChangedHandle;
336};
OODEFFUNC typedef const int const char * function
Definition oodle2.h:710
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
EUpdateTransformFlags
Definition ActorComponent.h:95
#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_MULTICAST_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:49
ETeleportType
Definition EngineTypes.h:2401
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
ETickableTickType
Definition Tickable.h:20
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition LandscapeStreamingProxy.h:20
Definition IDelegateInstance.h:14
Definition LandscapeGrassMapsBuilder.h:44
Definition LandscapeTextureStreamingManager.h:33
Definition UObjectGlobals.h:2492
Definition SubsystemCollection.h:15
Definition IConsoleManager.h:558
Definition Landscape.Build.cs:7
Definition ArrayView.h:139
Definition Array.h:670
Definition AssetRegistryState.h:50
Definition UnrealString.h.inl:34
Definition SharedPointer.h:153
Definition LandscapeEdgeFixup.h:205
Definition LandscapeInfo.h:109
Definition LandscapeSubsystem.h:103
bool IsGrassCreationPrioritized() const
Definition LandscapeSubsystem.h:125
FLandscapeGrassMapsBuilder * GetGrassMapBuilder()
Definition LandscapeSubsystem.h:126
FLandscapeTextureStreamingManager * GetTextureStreamingManager()
Definition LandscapeSubsystem.h:127
void PrioritizeGrassCreation(bool bPrioritizeGrassCreation)
Definition LandscapeSubsystem.h:124
virtual bool IsTickableInEditor() const override
Definition LandscapeSubsystem.h:115
Definition Level.h:423
Definition Object.h:95
Definition WorldSubsystem.h:76
Definition World.h:918
Type
Definition EngineTypes.h:1264
Definition SkinnedMeshComponent.h:50
Definition Landscape.h:55
EBuildFlags
Definition LandscapeEditTypes.h:70
EOutdatedDataFlags
Definition LandscapeEditTypes.h:44
Definition AdvancedWidgetsModule.cpp:13
@ false
Definition radaudio_common.h:23
Definition DateTime.h:76
Definition LandscapeGroup.h:22
Definition ScopedSlowTask.h:32
Definition Optional.h:131
Definition LightweightStats.h:416
Definition Tuple.h:652
Definition IntPoint.h:25