Cesium for Unreal 2.26.0
Loading...
Searching...
No Matches
Cesium3DTileset.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "Cesium3DTilesSelection/Tileset.h"
6#include "Cesium3DTilesSelection/ViewState.h"
7#include "Cesium3DTilesSelection/ViewUpdateResult.h"
12#include "CesiumGeoreference.h"
13#include "CesiumIonServer.h"
17#include "CoreMinimal.h"
19#include "Engine/EngineTypes.h"
20#include "GameFramework/Actor.h"
21#include "Interfaces/IHttpRequest.h"
22#include "PrimitiveSceneProxy.h"
23#include <PhysicsEngine/BodyInstance.h>
24#include <atomic>
25#include <chrono>
26#include <glm/mat4x4.hpp>
27#include <unordered_map>
28#include <vector>
29
30#ifdef CESIUM_DEBUG_TILE_STATES
31#include <Cesium3DTilesSelection/DebugTileStateDatabase.h>
32#endif
33
34#include "Cesium3DTileset.generated.h"
35
36class UMaterialInterface;
37class ACesiumCartographicSelection;
39class UCesiumBoundingVolumePoolComponent;
41class UCesiumVoxelRendererComponent;
42class CesiumViewExtension;
43struct FCesiumCamera;
45
46namespace Cesium3DTiles {
48}
49
50namespace Cesium3DTilesSelection {
51class GltfModifier;
52class Tileset;
53class TilesetView;
55} // namespace Cesium3DTilesSelection
56
57/**
58 * The delegate for OnCesium3DTilesetLoadFailure, which is triggered when
59 * the tileset encounters a load error.
60 */
62 FCesium3DTilesetLoadFailure,
64
66 FCesiumSampleHeightMostDetailedCallback,
68 const TArray<FCesiumSampleHeightResult>&,
69 const TArray<FString>&);
70
71/**
72 * The delegate for the Acesium3DTileset::OnTilesetLoaded,
73 * which is triggered from UpdateLoadStatus
74 */
76
77CESIUMRUNTIME_API extern FCesium3DTilesetLoadFailure
79
80UENUM(BlueprintType)
81enum class ETilesetSource : uint8 {
82 /**
83 * The tileset will be loaded from Cesium Ion using the provided IonAssetID
84 * and IonAccessToken.
85 */
86 FromCesiumIon UMETA(DisplayName = "From Cesium Ion"),
87
88 /**
89 * The tileset will be loaded from the specified Url.
90 */
91 FromUrl UMETA(DisplayName = "From Url"),
92
93 /**
94 * The tileset will be loaded from the georeference ellipsoid.
95 */
96 FromEllipsoid UMETA(DisplayName = "From Ellipsoid")
97};
98
99UENUM(BlueprintType)
100enum class EApplyDpiScaling : uint8 { Yes, No, UseProjectDefault };
101
102UCLASS()
103class CESIUMRUNTIME_API ACesium3DTileset : public AActor {
104 GENERATED_BODY()
105
106public:
109
110private:
111 UPROPERTY(VisibleAnywhere, Category = "Cesium") USceneComponent* Root;
112
113 UPROPERTY(
114 Meta =
115 (AllowPrivateAccess,
116 DeprecatedProperty,
117 DeprecationMessage =
118 "Use the Mobility property on the RootComponent instead."))
119 TEnumAsByte<EComponentMobility::Type> Mobility_DEPRECATED =
120 EComponentMobility::Static;
121
122public:
123 UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction))
124 EComponentMobility::Type GetMobility() const {
125 return this->RootComponent->Mobility;
126 }
127 UFUNCTION(BlueprintCallable, meta = (DeprecatedFunction))
128 void SetMobility(EComponentMobility::Type NewMobility);
129
130 /**
131 * @brief Initiates an asynchronous query for the height of this tileset at a
132 * list of cartographic positions, where the Longitude (X) and Latitude (Y)
133 * are given in degrees. The most detailed available tiles are used to
134 * determine each height.
135 *
136 * The height of the input positions is ignored, unless height sampling fails
137 * at that location. The output height is expressed in meters above the
138 * ellipsoid (usually WGS84), which should not be confused with a height above
139 * mean sea level.
140 *
141 * @param LongitudeLatitudeHeightArray The cartographic positions for which to
142 * sample heights. The Longitude (X) and Latitude (Y) are expressed in
143 * degrees, while Height (Z) is given in meters.
144 * @param OnHeightsSampled A callback that is invoked in the game thread when
145 * heights have been sampled for all positions.
146 */
148 const TArray<FVector>& LongitudeLatitudeHeightArray,
149 FCesiumSampleHeightMostDetailedCallback OnHeightsSampled);
150
151private:
152 /**
153 * The designated georeference actor controlling how the actor's
154 * coordinate system relates to the coordinate system in this Unreal Engine
155 * level.
156 *
157 * If this is null, the Tileset will find and use the first Georeference
158 * Actor in the level, or create one if necessary. To get the active/effective
159 * Georeference from Blueprints or C++, use ResolvedGeoreference instead.
160 */
161 UPROPERTY(
162 EditAnywhere,
163 BlueprintReadWrite,
164 BlueprintGetter = GetGeoreference,
165 BlueprintSetter = SetGeoreference,
166 Category = "Cesium",
167 Meta = (AllowPrivateAccess))
168 TSoftObjectPtr<ACesiumGeoreference> Georeference;
169
170 /**
171 * The resolved georeference used by this Tileset. This is not serialized
172 * because it may point to a Georeference in the PersistentLevel while this
173 * tileset is in a sublevel. If the Georeference property is specified,
174 * however then this property will have the same value.
175 *
176 * This property will be null before ResolveGeoreference is called.
177 */
178 UPROPERTY(
179 Transient,
180 VisibleAnywhere,
181 BlueprintReadOnly,
182 Category = "Cesium",
183 Meta = (AllowPrivateAccess))
184 ACesiumGeoreference* ResolvedGeoreference = nullptr;
185
186public:
187 /** @copydoc ACesium3DTileset::Georeference */
188 UFUNCTION(BlueprintCallable, Category = "Cesium")
189 TSoftObjectPtr<ACesiumGeoreference> GetGeoreference() const;
190
191 /** @copydoc ACesium3DTileset::Georeference */
192 UFUNCTION(BlueprintCallable, Category = "Cesium")
193 void SetGeoreference(TSoftObjectPtr<ACesiumGeoreference> NewGeoreference);
194
195 /**
196 * Resolves the Cesium Georeference to use with this Actor. Returns
197 * the value of the Georeference property if it is set. Otherwise, finds a
198 * Georeference in the World and returns it, creating it if necessary. The
199 * resolved Georeference is cached so subsequent calls to this function will
200 * return the same instance.
201 */
202 UFUNCTION(BlueprintCallable, Category = "Cesium")
204
205 /**
206 * Invalidates the cached resolved georeference, unsubscribing from it and
207 * setting it to null. The next time ResolveGeoreference is called, the
208 * Georeference will be re-resolved and re-subscribed.
209 */
210 UFUNCTION(BlueprintCallable, Category = "Cesium")
212
213private:
214 /**
215 * The actor managing this tileset's content attributions.
216 *
217 * If this is null, the Tileset will find and use the first Credit System
218 * Actor in the level, or create one if necessary. To get the active/effective
219 * Credit System from Blueprints or C++, use ResolvedCreditSystem instead.
220 */
221 UPROPERTY(
222 EditAnywhere,
223 BlueprintReadWrite,
224 BlueprintGetter = GetCreditSystem,
225 BlueprintSetter = SetCreditSystem,
226 Category = "Cesium",
227 Meta = (AllowPrivateAccess))
228 TSoftObjectPtr<ACesiumCreditSystem> CreditSystem;
229
230 /**
231 * The resolved Credit System used by this Tileset. This is not serialized
232 * because it may point to a Credit System in the PersistentLevel while this
233 * tileset is in a sublevel. If the CreditSystem property is specified,
234 * however then this property will have the same value.
235 *
236 * This property will be null before ResolveCreditSystem is called.
237 */
238 UPROPERTY(
239 Transient,
240 BlueprintReadOnly,
241 Category = "Cesium",
242 Meta = (AllowPrivateAccess))
243 ACesiumCreditSystem* ResolvedCreditSystem = nullptr;
244
245 /**
246 * The actor providing custom cameras for use with this Tileset.
247 *
248 * If this is null, the Tileset will find and use the first
249 * CesiumCameraManager Actor in the level, or create one if necessary. To get
250 * the active/effective Camera Manager from Blueprints or C++, use
251 * ResolvedCameraManager instead.
252 */
253 UPROPERTY(
254 EditAnywhere,
255 BlueprintReadWrite,
256 BlueprintGetter = GetCameraManager,
257 BlueprintSetter = SetCameraManager,
258 Category = "Cesium",
259 Meta = (AllowPrivateAccess))
260 TSoftObjectPtr<ACesiumCameraManager> CameraManager;
261
262 /**
263 * The resolved Camera Manager used by this Tileset. This is not serialized
264 * because it may point to a Camera Manager in the PersistentLevel while this
265 * tileset is in a sublevel. If the CameraManager property is specified,
266 * however then this property will have the same value.
267 *
268 * This property will be null before ResolveCameraManager is called.
269 */
270 UPROPERTY(
271 Transient,
272 BlueprintReadOnly,
273 Category = "Cesium",
274 Meta = (AllowPrivateAccess))
275 ACesiumCameraManager* ResolvedCameraManager = nullptr;
276
277 /**
278 * The bounding volume pool component that manages occlusion bounding volume
279 * proxies.
280 */
281 UPROPERTY(
282 Transient,
283 BlueprintReadOnly,
284 Category = "Cesium",
285 Meta = (AllowPrivateAccess))
286 UCesiumBoundingVolumePoolComponent* BoundingVolumePoolComponent = nullptr;
287
288 /**
289 * The custom view extension this tileset uses to pull renderer view
290 * information.
291 */
292 TSharedPtr<CesiumViewExtension, ESPMode::ThreadSafe> _cesiumViewExtension =
293 nullptr;
294
295public:
296 /** @copydoc ACesium3DTileset::CreditSystem */
297 UFUNCTION(BlueprintCallable, Category = "Cesium")
298 TSoftObjectPtr<ACesiumCreditSystem> GetCreditSystem() const;
299
300 /** @copydoc ACesium3DTileset::CreditSystem */
301 UFUNCTION(BlueprintCallable, Category = "Cesium")
302 void SetCreditSystem(TSoftObjectPtr<ACesiumCreditSystem> NewCreditSystem);
303
304 /**
305 * Resolves the Cesium Credit System to use with this Actor. Returns
306 * the value of the CreditSystem property if it is set. Otherwise, finds a
307 * Credit System in the World and returns it, creating it if necessary. The
308 * resolved Credit System is cached so subsequent calls to this function will
309 * return the same instance.
310 */
311 UFUNCTION(BlueprintCallable, Category = "Cesium")
313
314 /**
315 * Invalidates the cached resolved Credit System, setting it to null. The next
316 * time ResolveCreditSystem is called, the Credit System will be re-resolved.
317 */
318 UFUNCTION(BlueprintCallable, Category = "Cesium")
320
321 /**
322 * Whether or not to show this tileset's credits on screen.
323 */
324 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
326
327 /** @copydoc ACesium3DTileset::CameraManager */
328 UFUNCTION(BlueprintGetter, Category = "Cesium")
329 TSoftObjectPtr<ACesiumCameraManager> GetCameraManager() const;
330
331 /** @copydoc ACesium3DTileset::CameraManager */
332 UFUNCTION(BlueprintSetter, Category = "Cesium")
333 void SetCameraManager(TSoftObjectPtr<ACesiumCameraManager> NewCameraManager);
334
335 /**
336 * Resolves the Cesium Camera Manager to use with this Actor. Returns
337 * the value of the CameraManager property if it is set. Otherwise, finds a
338 * Camera Manager in the World and returns it, creating it if necessary. The
339 * resolved Camera Manager is cached so subsequent calls to this function will
340 * return the same instance.
341 */
342 UFUNCTION(BlueprintCallable, Category = "Cesium")
344
345 /**
346 * Invalidates the cached resolved Camera Manager, setting it to null. The
347 * next time ResolveCameraManager is called, the Camera Manager will be
348 * re-resolved.
349 */
350 UFUNCTION(BlueprintCallable, Category = "Cesium")
352
353 /**
354 * The maximum number of pixels of error when rendering this tileset.
355 *
356 * This is used to select an appropriate level-of-detail: A low value
357 * will cause many tiles with a high level of detail to be loaded,
358 * causing a finer visual representation of the tiles, but with a
359 * higher performance cost for loading and rendering. A higher value will
360 * cause a coarser visual representation, with lower performance
361 * requirements.
362 *
363 * When a tileset uses the older layer.json / quantized-mesh format rather
364 * than 3D Tiles, this value is effectively divided by 8.0. So the default
365 * value of 16.0 corresponds to the standard value for quantized-mesh terrain
366 * of 2.0.
367 */
368 UPROPERTY(
369 EditAnywhere,
370 BlueprintGetter = GetMaximumScreenSpaceError,
371 BlueprintSetter = SetMaximumScreenSpaceError,
372 Category = "Cesium|Level of Detail",
373 meta = (ClampMin = 0.0))
375
376 /**
377 * Scale Level-of-Detail by Display DPI. This increases the performance for
378 * mobile devices and high DPI screens.
379 */
380 UPROPERTY(
381 EditAnywhere,
382 BlueprintReadWrite,
383 Category = "Cesium|Level of Detail")
385
386 /**
387 * Whether to preload ancestor tiles.
388 *
389 * Setting this to true optimizes the zoom-out experience and provides more
390 * detail in newly-exposed areas when panning. The down side is that it
391 * requires loading more tiles.
392 */
393 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
394 bool PreloadAncestors = true;
395
396 /**
397 * Whether to preload sibling tiles.
398 *
399 * Setting this to true causes tiles with the same parent as a rendered tile
400 * to be loaded, even if they are culled. Setting this to true may provide a
401 * better panning experience at the cost of loading more tiles.
402 */
403 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
404 bool PreloadSiblings = true;
405
406 /**
407 * Whether to unrefine back to a parent tile when a child isn't done loading.
408 *
409 * When this is set to true, the tileset will guarantee that the tileset will
410 * never be rendered with holes in place of tiles that are not yet loaded,
411 * even though the tile that is rendered instead may have low resolution. When
412 * false, overall loading will be faster, but newly-visible parts of the
413 * tileset may initially be blank.
414 */
415 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
416 bool ForbidHoles = false;
417
418 /**
419 * The maximum number of tiles that may be loaded at once.
420 *
421 * When new parts of the tileset become visible, the tasks to load the
422 * corresponding tiles are put into a queue. This value determines how
423 * many of these tasks are processed at the same time. A higher value
424 * may cause the tiles to be loaded and rendered more quickly, at the
425 * cost of a higher network- and processing load.
426 */
427 UPROPERTY(
428 EditAnywhere,
429 BlueprintReadWrite,
430 Category = "Cesium|Tile Loading",
431 meta = (ClampMin = 0))
433
434 /**
435 * @brief The maximum number of bytes that may be cached.
436 *
437 * Note that this value, even if 0, will never
438 * cause tiles that are needed for rendering to be unloaded. However, if the
439 * total number of loaded bytes is greater than this value, tiles will be
440 * unloaded until the total is under this number or until only required tiles
441 * remain, whichever comes first.
442 */
443 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Loading")
444 int64 MaximumCachedBytes = 256 * 1024 * 1024;
445
446 /**
447 * The number of loading descendents a tile should allow before deciding to
448 * render itself instead of waiting.
449 *
450 * Setting this to 0 will cause each level of detail to be loaded
451 * successively. This will increase the overall loading time, but cause
452 * additional detail to appear more gradually. Setting this to a high value
453 * like 1000 will decrease the overall time until the desired level of detail
454 * is achieved, but this high-detail representation will appear at once, as
455 * soon as it is loaded completely.
456 */
457 UPROPERTY(
458 EditAnywhere,
459 BlueprintReadWrite,
460 Category = "Cesium|Tile Loading",
461 meta = (ClampMin = 0))
463
464 /**
465 * Whether to cull tiles that are outside the frustum.
466 *
467 * By default this is true, meaning that tiles that are not visible with the
468 * current camera configuration will be ignored. It can be set to false, so
469 * that these tiles are still considered for loading, refinement and
470 * rendering.
471 *
472 * This will cause more tiles to be loaded, but helps to avoid holes and
473 * provides a more consistent mesh, which may be helpful for physics.
474 *
475 * Note that this will always be disabled if UseLodTransitions is set to true.
476 */
477 UPROPERTY(
478 EditAnywhere,
479 BlueprintReadWrite,
480 Category = "Cesium|Tile Culling",
481 Meta = (EditCondition = "!UseLodTransitions", EditConditionHides))
483
484 /**
485 * Whether to cull tiles that are occluded by fog.
486 *
487 * This does not refer to the atmospheric fog of the Unreal Engine,
488 * but to an internal representation of fog: Depending on the height
489 * of the camera above the ground, tiles that are far away (close to
490 * the horizon) will be culled when this flag is enabled.
491 *
492 * Note that this will always be disabled if UseLodTransitions is set to true.
493 */
494 UPROPERTY(
495 EditAnywhere,
496 BlueprintReadWrite,
497 Category = "Cesium|Tile Culling",
498 Meta = (EditCondition = "!UseLodTransitions", EditConditionHides))
499 bool EnableFogCulling = true;
500
501 /**
502 * Whether a specified screen-space error should be enforced for tiles that
503 * are outside the frustum or hidden in fog.
504 *
505 * When "Enable Frustum Culling" and "Enable Fog Culling" are both true, tiles
506 * outside the view frustum or hidden in fog are effectively ignored, and so
507 * their level-of-detail doesn't matter. And in this scenario, this property
508 * is ignored.
509 *
510 * However, when either of those flags are false, these "would-be-culled"
511 * tiles continue to be processed, and the question arises of how to handle
512 * their level-of-detail. When this property is false, refinement terminates
513 * at these tiles, no matter what their current screen-space error. The tiles
514 * are available for physics, shadows, etc., but their level-of-detail may
515 * be very low.
516 *
517 * When set to true, these tiles are refined until they achieve the specified
518 * "Culled Screen Space Error". This allows control over the minimum quality
519 * of these would-be-culled tiles.
520 */
521 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Tile Culling")
523
524 /**
525 * The screen-space error to be enforced for tiles that are outside the view
526 * frustum or hidden in fog.
527 *
528 * When "Enable Frustum Culling" and "Enable Fog Culling" are both true, tiles
529 * outside the view frustum or hidden in fog are effectively ignored, and so
530 * their level-of-detail doesn't matter. And in this scenario, this property
531 * is ignored.
532 *
533 * However, when either of those flags are false, these "would-be-culled"
534 * tiles continue to be processed, and the question arises of how to handle
535 * their level-of-detail. When "Enforce Culled Screen Space Error" is false,
536 * this property is ignored and refinement terminates at these tiles, no
537 * matter what their current screen-space error. The tiles are available for
538 * physics, shadows, etc., but their level-of-detail may be very low.
539 *
540 * When set to true, these tiles are refined until they achieve the
541 * screen-space error specified by this property.
542 */
543 UPROPERTY(
544 EditAnywhere,
545 BlueprintReadWrite,
546 Category = "Cesium|Tile Culling",
547 meta = (EditCondition = "EnforceCulledScreenSpaceError", ClampMin = 0.0))
549
550 // This mirrors
551 // UCesiumRuntimeSettings::EnableExperimentalOcclusionCullingFeature so that
552 // it can be used as an EditCondition.
553 UPROPERTY(Transient, VisibleDefaultsOnly, Category = "Cesium|Tile Occlusion")
555
556 /**
557 * Whether to cull tiles that are occluded.
558 *
559 * If this option is disabled, check that "Enable Experimental Occlusion
560 * Culling Feature" is enabled in the Plugins -> Cesium section of the Project
561 * Settings.
562 *
563 * When enabled, this feature will use Unreal's occlusion system to determine
564 * if tiles are actually visible on the screen. For tiles found to be
565 * occluded, the tile will not refine to show descendants, but it will still
566 * be rendered to avoid holes. This results in less tile loads and less GPU
567 * resource usage for dense, high-occlusion scenes like ground-level views in
568 * cities.
569 *
570 * This will not work for tilesets with poorly fit bounding volumes and cause
571 * more draw calls with very few extra culled tiles. When there is minimal
572 * occlusion in a scene, such as with terrain tilesets and applications
573 * focused on top-down views, this feature will yield minimal benefit and
574 * potentially cause needless overhead.
575 */
576 UPROPERTY(
577 EditAnywhere,
578 BlueprintGetter = GetEnableOcclusionCulling,
579 BlueprintSetter = SetEnableOcclusionCulling,
580 Category = "Cesium|Tile Occlusion",
581 meta = (EditCondition = "CanEnableOcclusionCulling"))
583
584 /**
585 * The number of CesiumBoundingVolumeComponents to use for querying the
586 * occlusion state of traversed tiles.
587 *
588 * Only applicable when EnableOcclusionCulling is enabled.
589 */
590 UPROPERTY(
591 EditAnywhere,
592 BlueprintGetter = GetOcclusionPoolSize,
593 BlueprintSetter = SetOcclusionPoolSize,
594 Category = "Cesium|Tile Occlusion",
595 meta =
596 (EditCondition =
597 "EnableOcclusionCulling && CanEnableOcclusionCulling",
598 ClampMin = "0",
599 ClampMax = "1000"))
600 int32 OcclusionPoolSize = 500;
601
602 /**
603 * Whether to wait for valid occlusion results before refining tiles.
604 *
605 * Only applicable when EnableOcclusionCulling is enabled. When this option
606 * is enabled, there may be small delays before tiles are refined, but there
607 * may be an overall performance advantage by avoiding loads of descendants
608 * that will be found to be occluded.
609 */
610 UPROPERTY(
611 EditAnywhere,
612 BlueprintGetter = GetDelayRefinementForOcclusion,
613 BlueprintSetter = SetDelayRefinementForOcclusion,
614 Category = "Cesium|Tile Occlusion",
615 meta =
616 (EditCondition =
617 "EnableOcclusionCulling && CanEnableOcclusionCulling"))
619
620 /**
621 * Refreshes this tileset, ensuring that all materials and other settings are
622 * applied. It is not usually necessary to invoke this, but when
623 * behind-the-scenes changes are made and not reflected in the tileset, this
624 * function can help.
625 */
626 UFUNCTION(CallInEditor, BlueprintCallable, Category = "Cesium")
628
629 /**
630 * Pauses level-of-detail and culling updates of this tileset.
631 */
632 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium|Debug")
634
635 /**
636 * If true, this tileset is ticked/updated in the editor. If false, it is only
637 * ticked while playing (including Play-in-Editor).
638 */
639 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
640 bool UpdateInEditor = true;
641
642 /**
643 * Play-in-Editor creates copies of objects in the level, including tileset
644 * actors. This means that two copies of the same tileset may be loaded into
645 * memory during Play-in-Editor mode.
646 *
647 * When this setting is true, the Editor instance of the tileset will unload
648 * its tiles as Play-in-Editor begins. This can prevent the Editor from
649 * duplicating resources and potentially consuming too much memory. However,
650 * tiles will need to be reloaded for the Editor instance after Play-in-Editor
651 * ends.
652 */
653 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
655
656 /**
657 * If true, stats about tile selection are printed to the Output Log.
658 */
659 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
660 bool LogSelectionStats = false;
661
662 /**
663 * If true, logs stats on the assets in this tileset's shared asset system to
664 * the Output Log.
665 */
666 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
668
669 /**
670 * If true, draws debug text above each tile being rendered with information
671 * about that tile.
672 */
673 UPROPERTY(EditAnywhere, Category = "Cesium|Debug")
674 bool DrawTileInfo = false;
675
676 /**
677 * Define the collision profile for all the 3D tiles created inside this
678 * actor.
679 */
680 UPROPERTY(
681 EditAnywhere,
682 BlueprintReadOnly,
683 Category = "Collision",
684 meta = (ShowOnlyInnerProperties, SkipUCSModifiedProperties))
685 FBodyInstance BodyInstance;
686
687 /**
688 * A delegate that will be called whenever the tileset is fully loaded.
689 */
690 UPROPERTY(BlueprintAssignable, Category = "Cesium");
691 FCompletedLoadTrigger OnTilesetLoaded;
692
693 /**
694 * Use a dithering effect when transitioning between tiles of different LODs.
695 *
696 * When this is set to true, Frustrum Culling and Fog Culling are always
697 * disabled.
698 */
699 UPROPERTY(
700 EditAnywhere,
701 BlueprintGetter = GetUseLodTransitions,
702 BlueprintSetter = SetUseLodTransitions,
703 Category = "Cesium|Rendering")
704 bool UseLodTransitions = false;
705
706 /**
707 * How long dithered LOD transitions between different tiles should take, in
708 * seconds.
709 *
710 * Only relevant if UseLodTransitions is true.
711 */
712 UPROPERTY(
713 EditAnywhere,
714 BlueprintReadWrite,
715 Category = "Cesium|Rendering",
716 meta = (EditCondition = "UseLodTransitions", EditConditionHides))
718
719private:
720 UPROPERTY(BlueprintGetter = GetLoadProgress, Category = "Cesium")
721 float LoadProgress = 0.0f;
722
723 /**
724 * The type of source from which to load this tileset.
725 */
726 UPROPERTY(
727 EditAnywhere,
728 BlueprintGetter = GetTilesetSource,
729 BlueprintSetter = SetTilesetSource,
730 Category = "Cesium",
731 meta = (DisplayName = "Source"))
733
734 /**
735 * The URL of this tileset's "tileset.json" file.
736 *
737 * If this property is specified, the ion asset ID and token are ignored.
738 */
739 UPROPERTY(
740 EditAnywhere,
741 BlueprintGetter = GetUrl,
742 BlueprintSetter = SetUrl,
743 Category = "Cesium",
744 meta = (EditCondition = "TilesetSource==ETilesetSource::FromUrl"))
745 FString Url = "";
746
747 /**
748 * The ID of the Cesium ion asset to use.
749 *
750 * This property is ignored if the Url is specified.
751 */
752 UPROPERTY(
753 EditAnywhere,
754 BlueprintGetter = GetIonAssetID,
755 BlueprintSetter = SetIonAssetID,
756 Category = "Cesium",
757 meta =
758 (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon",
759 ClampMin = 0))
760 int64 IonAssetID;
761
762 /**
763 * The access token to use to access the Cesium ion resource.
764 */
765 UPROPERTY(
766 EditAnywhere,
767 BlueprintGetter = GetIonAccessToken,
768 BlueprintSetter = SetIonAccessToken,
769 Category = "Cesium",
770 meta = (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon"))
771 FString IonAccessToken;
772
773 UPROPERTY(
774 meta =
775 (DeprecatedProperty,
776 DeprecationMessage = "Use CesiumIonServer instead."))
777 FString IonAssetEndpointUrl_DEPRECATED;
778
779 /**
780 * The Cesium ion Server from which this tileset is loaded.
781 */
782 UPROPERTY(
783 EditAnywhere,
784 BlueprintGetter = GetCesiumIonServer,
785 BlueprintSetter = SetCesiumIonServer,
786 Category = "Cesium",
787 AdvancedDisplay,
788 meta = (EditCondition = "TilesetSource==ETilesetSource::FromCesiumIon"))
789 UCesiumIonServer* CesiumIonServer;
790
791 /**
792 * Headers to be attached to each request made for this tileset.
793 */
794 UPROPERTY(
795 EditAnywhere,
796 BlueprintGetter = GetRequestHeaders,
797 BlueprintSetter = SetRequestHeaders,
798 Category = "Cesium")
799 TMap<FString, FString> RequestHeaders;
800
801 /**
802 * Check if the Cesium ion token used to access this tileset is working
803 * correctly, and fix it if necessary.
804 */
805 UFUNCTION(CallInEditor, Category = "Cesium")
806 void TroubleshootToken();
807
808 /**
809 * Whether to generate physics meshes for this tileset.
810 *
811 * Disabling this option will improve the performance of tile loading, but it
812 * will no longer be possible to collide with the tileset since the physics
813 * meshes will not be created.
814 *
815 * Physics meshes cannot be generated for primitives containing points.
816 */
817 UPROPERTY(
818 EditAnywhere,
819 BlueprintGetter = GetCreatePhysicsMeshes,
820 BlueprintSetter = SetCreatePhysicsMeshes,
821 Category = "Cesium|Physics")
822 bool CreatePhysicsMeshes = true;
823
824 /**
825 * Whether to enable doubled-sided collisions (both front-facing and
826 * back-facing) on created physics meshes.
827 *
828 * Only relevant when CreatePhysicsMeshes is true.
829 */
830 UPROPERTY(
831 EditAnywhere,
832 BlueprintGetter = GetEnableDoubleSidedCollisions,
833 BlueprintSetter = SetEnableDoubleSidedCollisions,
834 Category = "Cesium|Physics",
835 meta = (EditCondition = "CreatePhysicsMeshes"))
836 bool EnableDoubleSidedCollisions = false;
837
838 /**
839 * Whether to generate navigation collisions for this tileset.
840 *
841 * Enabling this option creates collisions for navigation when a 3D Tiles
842 * tileset is loaded. It is recommended to set "Runtime Generation" to
843 * "Static" in the navigation mesh settings in the project settings, as
844 * collision calculations become very slow.
845 */
846 UPROPERTY(
847 EditAnywhere,
848 BlueprintGetter = GetCreateNavCollision,
849 BlueprintSetter = SetCreateNavCollision,
850 Category = "Cesium|Navigation")
851 bool CreateNavCollision = false;
852
853 /**
854 * Whether to always generate a correct tangent space basis for tiles that
855 * don't have them.
856 *
857 * Normally, a per-vertex tangent space basis is only required for glTF models
858 * with a normal map. However, a custom, user-supplied material may need a
859 * tangent space basis for other purposes. When this property is set to true,
860 * tiles lacking an explicit tangent vector will have one computed
861 * automatically using the MikkTSpace algorithm. When this property is false,
862 * load time will be improved by skipping the generation of the tangent
863 * vector, but the tangent space basis will be unreliable.
864 *
865 * Note that a tileset with "Enable Water Mask" set will include tangents
866 * for tiles containing water, regardless of the value of this property.
867 */
868 UPROPERTY(
869 EditAnywhere,
870 BlueprintGetter = GetAlwaysIncludeTangents,
871 BlueprintSetter = SetAlwaysIncludeTangents,
872 Category = "Cesium|Rendering")
873 bool AlwaysIncludeTangents = false;
874
875 /**
876 * Whether to generate smooth normals when normals are missing in the glTF.
877 *
878 * According to the Gltf spec: "When normals are not specified, client
879 * implementations should calculate flat normals." However, calculating flat
880 * normals requires duplicating vertices. This option allows the gltfs to be
881 * sent with explicit smooth normals when the original gltf was missing
882 * normals.
883 */
884 UPROPERTY(
885 EditAnywhere,
886 BlueprintGetter = GetGenerateSmoothNormals,
887 BlueprintSetter = SetGenerateSmoothNormals,
888 Category = "Cesium|Rendering")
889 bool GenerateSmoothNormals = false;
890
891 /**
892 * Whether to request and render the water mask.
893 *
894 * Currently only applicable for quantized-mesh tilesets that support the
895 * water mask extension.
896 */
897 UPROPERTY(
898 EditAnywhere,
899 BlueprintGetter = GetEnableWaterMask,
900 BlueprintSetter = SetEnableWaterMask,
901 Category = "Cesium|Rendering")
902 bool EnableWaterMask = false;
903
904 /**
905 * Whether to ignore the KHR_materials_unlit extension on the glTF tiles in
906 * this tileset, if it exists, and instead render with standard lighting and
907 * shadows. This property will have no effect if the tileset does not have any
908 * tiles that use this extension.
909 *
910 * The KHR_materials_unlit extension is often applied to photogrammetry
911 * tilesets because lighting and shadows are already baked into their
912 * textures.
913 */
914 UPROPERTY(
915 EditAnywhere,
916 BlueprintGetter = GetIgnoreKhrMaterialsUnlit,
917 BlueprintSetter = SetIgnoreKhrMaterialsUnlit,
918 Category = "Cesium|Rendering",
919 meta = (DisplayName = "Ignore KHR_materials_unlit"))
920 bool IgnoreKhrMaterialsUnlit = false;
921
922 /**
923 * Whether this tileset should receive decals.
924 */
925 UPROPERTY(
926 EditAnywhere,
927 BlueprintGetter = GetReceiveDecals,
928 BlueprintSetter = SetReceiveDecals,
929 Category = "Cesium|Rendering")
930 bool ReceiveDecals = true;
931
932 /**
933 * A custom Material to use to render opaque elements in this tileset, in
934 * order to implement custom visual effects.
935 *
936 * The custom material should generally be created by copying the Material
937 * Instance "MI_CesiumThreeOverlaysAndClipping" and customizing the copy as
938 * desired.
939 */
940 UPROPERTY(
941 EditAnywhere,
942 BlueprintGetter = GetMaterial,
943 BlueprintSetter = SetMaterial,
944 Category = "Cesium|Rendering")
945 UMaterialInterface* Material = nullptr;
946
947 /**
948 * A custom Material to use to render translucent elements of the tileset, in
949 * order to implement custom visual effects.
950 *
951 * The custom material should generally be created by copying the Material
952 * Instance "MI_CesiumThreeOverlaysAndClippingTranslucent" and customizing the
953 * copy as desired. Make sure that its Material Property Overrides -> Blend
954 * Mode is set to "Translucent".
955 */
956 UPROPERTY(
957 EditAnywhere,
958 BlueprintGetter = GetTranslucentMaterial,
959 BlueprintSetter = SetTranslucentMaterial,
960 Category = "Cesium|Rendering")
961 UMaterialInterface* TranslucentMaterial = nullptr;
962
963 /**
964 * A custom Material to use to render this tileset in areas where the
965 * watermask is, in order to implement custom visual effects.
966 * Currently only applicable for quantized-mesh tilesets that support the
967 * water mask extension.
968 *
969 * The custom material should generally be created by copying the Material
970 * Instance "MI_CesiumThreeOverlaysAndClippingAndWater" and customizing the
971 * copy as desired.
972 */
973 UPROPERTY(
974 EditAnywhere,
975 BlueprintGetter = GetWaterMaterial,
976 BlueprintSetter = SetWaterMaterial,
977 Category = "Cesium|Rendering")
978 UMaterialInterface* WaterMaterial = nullptr;
979
980 UPROPERTY(
981 EditAnywhere,
982 BlueprintGetter = GetCustomDepthParameters,
983 BlueprintSetter = SetCustomDepthParameters,
984 Category = "Rendering",
985 meta = (ShowOnlyInnerProperties))
986 FCustomDepthParameters CustomDepthParameters;
987
988 /**
989 * If this tileset contains points, their appearance can be configured with
990 * these point cloud shading parameters.
991 *
992 * These settings are not supported on mobile platforms.
993 */
994 UPROPERTY(
995 EditAnywhere,
996 BlueprintGetter = GetPointCloudShading,
997 BlueprintSetter = SetPointCloudShading,
998 Category = "Cesium|Rendering")
999 FCesiumPointCloudShading PointCloudShading;
1000
1001 /**
1002 * Array of runtime virtual textures into which we draw the mesh for this
1003 * actor. The material also needs to be set up to output to a virtual texture.
1004 */
1005 UPROPERTY(
1006 EditAnywhere,
1007 BlueprintGetter = GetRuntimeVirtualTextures,
1008 BlueprintSetter = SetRuntimeVirtualTextures,
1009 Category = "VirtualTexture",
1010 meta = (DisplayName = "Draw in Virtual Textures"))
1011 TArray<TObjectPtr<URuntimeVirtualTexture>> RuntimeVirtualTextures;
1012
1013 /** Controls if this component draws in the main pass as well as in the
1014 * virtual texture. You must refresh the Tileset after changing this value! */
1015 UPROPERTY(
1016 EditAnywhere,
1017 BlueprintGetter = GetVirtualTextureRenderPassType,
1018 Category = VirtualTexture,
1019 meta = (DisplayName = "Draw in Main Pass"))
1020 ERuntimeVirtualTextureMainPassType VirtualTextureRenderPassType =
1021 ERuntimeVirtualTextureMainPassType::Exclusive;
1022
1023 /**
1024 * Translucent objects with a lower sort priority draw behind objects with a
1025 * higher priority. Translucent objects with the same priority are rendered
1026 * from back-to-front based on their bounds origin. This setting is also used
1027 * to sort objects being drawn into a runtime virtual texture.
1028 *
1029 * Ignored if the object is not translucent. The default priority is zero.
1030 * Warning: This should never be set to a non-default value unless you know
1031 * what you are doing, as it will prevent the renderer from sorting correctly.
1032 * It is especially problematic on dynamic gameplay effects.
1033 */
1034 UPROPERTY(
1035 EditAnywhere,
1036 BlueprintGetter = GetTranslucencySortPriority,
1037 BlueprintSetter = SetTranslucencySortPriority,
1038 AdvancedDisplay,
1039 Category = Rendering)
1040 int32 TranslucencySortPriority;
1041
1042protected:
1043 UPROPERTY()
1045
1046public:
1047 UFUNCTION(BlueprintGetter, Category = "Cesium")
1048 float GetLoadProgress() const { return LoadProgress; }
1049
1050 UFUNCTION(BlueprintGetter, Category = "Cesium")
1052
1053 UFUNCTION(BlueprintSetter, Category = "Cesium")
1054 void SetUseLodTransitions(bool InUseLodTransitions);
1055
1056 UFUNCTION(BlueprintGetter, Category = "Cesium")
1057 ETilesetSource GetTilesetSource() const { return TilesetSource; }
1058
1059 UFUNCTION(BlueprintSetter, Category = "Cesium")
1061
1062 UFUNCTION(BlueprintGetter, Category = "Cesium")
1063 FString GetUrl() const { return Url; }
1064
1065 UFUNCTION(BlueprintSetter, Category = "Cesium")
1066 void SetUrl(const FString& InUrl);
1067
1068 UFUNCTION(BlueprintGetter, Category = "Cesium")
1069 TMap<FString, FString> GetRequestHeaders() const { return RequestHeaders; }
1070
1071 UFUNCTION(BlueprintSetter, Category = "Cesium")
1072 void SetRequestHeaders(const TMap<FString, FString>& InRequestHeaders);
1073
1074 UFUNCTION(BlueprintGetter, Category = "Cesium")
1075 int64 GetIonAssetID() const { return IonAssetID; }
1076
1077 UFUNCTION(BlueprintSetter, Category = "Cesium")
1078 void SetIonAssetID(int64 InAssetID);
1079
1080 UFUNCTION(BlueprintGetter, Category = "Cesium")
1081 FString GetIonAccessToken() const { return IonAccessToken; }
1082
1083 UFUNCTION(BlueprintSetter, Category = "Cesium")
1084 void SetIonAccessToken(const FString& InAccessToken);
1085
1086 UFUNCTION(BlueprintGetter, Category = "Cesium")
1087 UCesiumIonServer* GetCesiumIonServer() const { return CesiumIonServer; }
1088
1089 UFUNCTION(BlueprintGetter, Category = "VirtualTexture")
1090 TArray<URuntimeVirtualTexture*> GetRuntimeVirtualTextures() const {
1091 return RuntimeVirtualTextures;
1092 }
1093
1094 UFUNCTION(BlueprintSetter, Category = "VirtualTexture")
1096 TArray<URuntimeVirtualTexture*> InRuntimeVirtualTextures);
1097
1098 UFUNCTION(BlueprintGetter, Category = "VirtualTexture")
1099 ERuntimeVirtualTextureMainPassType GetVirtualTextureRenderPassType() const {
1100 return VirtualTextureRenderPassType;
1101 }
1102
1103 UFUNCTION(BlueprintGetter, Category = Rendering)
1104 int32 GetTranslucencySortPriority() { return TranslucencySortPriority; }
1105
1106 UFUNCTION(BlueprintSetter, Category = Rendering)
1107 void SetTranslucencySortPriority(int32 InTranslucencySortPriority);
1108
1109 UFUNCTION(BlueprintSetter, Category = "Cesium")
1111
1112 UFUNCTION(BlueprintGetter, Category = "Cesium")
1114
1115 UFUNCTION(BlueprintSetter, Category = "Cesium")
1116 void SetMaximumScreenSpaceError(double InMaximumScreenSpaceError);
1117
1118 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1120
1121 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1122 void SetEnableOcclusionCulling(bool bEnableOcclusionCulling);
1123
1124 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1125 int32 GetOcclusionPoolSize() const { return OcclusionPoolSize; }
1126
1127 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1128 void SetOcclusionPoolSize(int32 newOcclusionPoolSize);
1129
1130 UFUNCTION(BlueprintGetter, Category = "Cesium|Tile Culling|Experimental")
1134
1135 UFUNCTION(BlueprintSetter, Category = "Cesium|Tile Culling|Experimental")
1136 void SetDelayRefinementForOcclusion(bool bDelayRefinementForOcclusion);
1137
1138 UFUNCTION(BlueprintGetter, Category = "Cesium|Physics")
1139 bool GetCreatePhysicsMeshes() const { return CreatePhysicsMeshes; }
1140
1141 UFUNCTION(BlueprintSetter, Category = "Cesium|Physics")
1142 void SetCreatePhysicsMeshes(bool bCreatePhysicsMeshes);
1143
1144 UFUNCTION(BlueprintGetter, Category = "Cesium|Physics")
1146 return EnableDoubleSidedCollisions;
1147 }
1148
1149 UFUNCTION(BlueprintSetter, Category = "Cesium|Physics")
1150 void SetEnableDoubleSidedCollisions(bool bEnableDoubleSidedCollisions);
1151
1152 UFUNCTION(BlueprintGetter, Category = "Cesium|Navigation")
1153 bool GetCreateNavCollision() const { return CreateNavCollision; }
1154
1155 UFUNCTION(BlueprintSetter, Category = "Cesium|Navigation")
1156 void SetCreateNavCollision(bool bCreateNavCollision);
1157
1158 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1159 bool GetAlwaysIncludeTangents() const { return AlwaysIncludeTangents; }
1160
1161 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1162 void SetAlwaysIncludeTangents(bool bAlwaysIncludeTangents);
1163
1164 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1165 bool GetGenerateSmoothNormals() const { return GenerateSmoothNormals; }
1166
1167 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1168 void SetGenerateSmoothNormals(bool bGenerateSmoothNormals);
1169
1170 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1171 bool GetEnableWaterMask() const { return EnableWaterMask; }
1172
1173 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1174 void SetEnableWaterMask(bool bEnableMask);
1175
1176 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1177 bool GetIgnoreKhrMaterialsUnlit() const { return IgnoreKhrMaterialsUnlit; }
1178 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1179 void SetIgnoreKhrMaterialsUnlit(bool bIgnoreKhrMaterialsUnlit);
1180
1181 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1182 bool GetReceiveDecals() const { return ReceiveDecals; }
1183 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1184 void SetReceiveDecals(bool bReceiveDecals);
1185
1186 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1187 UMaterialInterface* GetMaterial() const { return Material; }
1188
1189 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1190 void SetMaterial(UMaterialInterface* InMaterial);
1191
1192 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1193 UMaterialInterface* GetTranslucentMaterial() const {
1194 return TranslucentMaterial;
1195 }
1196
1197 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1198 void SetTranslucentMaterial(UMaterialInterface* InMaterial);
1199
1200 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1201 UMaterialInterface* GetWaterMaterial() const { return WaterMaterial; }
1202
1203 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1204 void SetWaterMaterial(UMaterialInterface* InMaterial);
1205
1206 UFUNCTION(BlueprintGetter, Category = "Rendering")
1208 return CustomDepthParameters;
1209 }
1210
1211 UFUNCTION(BlueprintSetter, Category = "Rendering")
1213
1214 UFUNCTION(BlueprintGetter, Category = "Cesium|Rendering")
1216 return PointCloudShading;
1217 }
1218
1219 UFUNCTION(BlueprintSetter, Category = "Cesium|Rendering")
1221
1222 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1224
1225 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1227
1228 UFUNCTION(BlueprintCallable, Category = "Cesium|Rendering")
1230
1231 /**
1232 * This method is not supposed to be called by clients. It is currently
1233 * only required by the UnrealPrepareRendererResources.
1234 *
1235 * @internal
1236 * See {@link
1237 * UCesium3DTilesetRoot::GetCesiumTilesetToUnrealRelativeWorldTransform}.
1238 * @endinternal
1239 */
1241
1243 return this->_pTileset.Get();
1244 }
1246 return this->_pTileset.Get();
1247 }
1248
1249 // AActor overrides (some or most of them should be protected)
1250 virtual bool ShouldTickIfViewportsOnly() const override;
1251 virtual void Tick(float DeltaTime) override;
1252 virtual void BeginDestroy() override;
1253 virtual bool IsReadyForFinishDestroy() override;
1254 virtual void Destroyed() override;
1255 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
1256 virtual void PostLoad() override;
1257 virtual void Serialize(FArchive& Ar) override;
1258
1260
1261 // UObject overrides
1262#if WITH_EDITOR
1263 virtual void
1264 PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
1265 virtual void PostEditChangeChainProperty(
1266 FPropertyChangedChainEvent& PropertyChangedChainEvent) override;
1267 virtual void PostEditUndo() override;
1268 virtual void PostEditImport() override;
1269#endif
1270
1271protected:
1272 // Called when the game starts or when spawned
1273 virtual void BeginPlay() override;
1274 virtual void OnConstruction(const FTransform& Transform) override;
1275
1276 /**
1277 * Called after the C++ constructor and after the properties have
1278 * been initialized, including those loaded from config.
1279 */
1280 void PostInitProperties() override;
1281
1282 virtual void NotifyHit(
1283 class UPrimitiveComponent* MyComp,
1284 AActor* Other,
1285 class UPrimitiveComponent* OtherComp,
1286 bool bSelfMoved,
1287 FVector HitLocation,
1288 FVector HitNormal,
1289 FVector NormalImpulse,
1290 const FHitResult& Hit) override;
1291
1292private:
1293 void LoadTileset();
1294 void DestroyTileset();
1295
1296 static Cesium3DTilesSelection::ViewState CreateViewStateFromViewParameters(
1297 const FCesiumCamera& camera,
1298 const glm::dmat4& unrealWorldToTileset,
1299 UCesiumEllipsoid* ellipsoid);
1300
1301 std::vector<FCesiumCamera> GetCameras() const;
1302 std::vector<FCesiumCamera> GetPlayerCameras() const;
1303 std::vector<FCesiumCamera> GetSceneCaptures() const;
1304
1305public:
1306 /**
1307 * Update the transforms of the glTF components based on the
1308 * the transform of the root component.
1309 *
1310 * This is supposed to be called during Tick, if the transform of
1311 * the root component has changed since the previous Tick.
1312 */
1314
1315 /**
1316 * Gets the glTF modifier, an optional extension class that can edit
1317 * each tile's glTF model after it has been loaded, before it can be
1318 * displayed.
1319 */
1320 const std::shared_ptr<Cesium3DTilesSelection::GltfModifier>&
1322
1323 /**
1324 * Sets the glTF modifier, an optional extension class that can edit
1325 * each tile's glTF model after it has been loaded, before it can be
1326 * displayed.
1327 *
1328 * Setting this property will refresh the tileset.
1329 */
1331 const std::shared_ptr<Cesium3DTilesSelection::GltfModifier>& Modifier);
1332
1333 /**
1334 * Gets the optional receiver of events related to the lifecycle of tiles
1335 * created by this tileset.
1336 */
1338
1339 /**
1340 * Sets a receiver of events related to the lifecycle of tiles
1341 * created by this tileset.
1342 *
1343 * The receiver will be notified of events such as tile load, unload, show,
1344 * and hide. The provided instance _must_ implement @ref
1345 * ICesium3DTilesetLifecycleEventReceiver, otherwise it will be as if nullptr
1346 * were passed.
1347 */
1348 void SetLifecycleEventReceiver(UObject* EventReceiver);
1349
1350private:
1351 /**
1352 * The event handler for ACesiumGeoreference::OnEllipsoidChanged.
1353 */
1354 UFUNCTION(CallInEditor)
1355 void HandleOnGeoreferenceEllipsoidChanged(
1356 UCesiumEllipsoid* OldEllipsoid,
1357 UCesiumEllipsoid* NewEllpisoid);
1358
1359 /**
1360 * Creates and attaches a \ref UCesiumVoxelRendererComponent for rendering
1361 * voxel data.
1362 */
1363 void
1365 VoxelExtension);
1366
1367 /**
1368 * Writes the values of all properties of this actor into the
1369 * TilesetOptions, to take them into account during the next
1370 * traversal.
1371 */
1372 void updateTilesetOptionsFromProperties();
1373
1374 /**
1375 * Update all the "_last..." fields of this instance based
1376 * on the given ViewUpdateResult, printing a log message
1377 * if any value changed.
1378 *
1379 * @param result The ViewUpdateREsult
1380 */
1381 void updateLastViewUpdateResultState(
1383
1384 /**
1385 * Creates the visual representations of the given tiles to
1386 * be rendered in the current frame.
1387 *
1388 * @param tiles The tiles
1389 */
1390 void showTilesToRender(
1391 const std::vector<Cesium3DTilesSelection::Tile::ConstPointer>& tiles);
1392
1393 /**
1394 * Will be called after the tileset is loaded or spawned, to register
1395 * a delegate that calls OnFocusEditorViewportOnThis when this
1396 * tileset is double-clicked
1397 */
1398 void AddFocusViewportDelegate();
1399
1400#if WITH_EDITOR
1401 std::vector<FCesiumCamera> GetEditorCameras() const;
1402
1403 /**
1404 * Will focus all viewports on this tileset.
1405 *
1406 * This is called when double-clicking the tileset in the World Outliner.
1407 * It will move the tileset into the center of the view, *even if* the
1408 * tileset was not visible before, and no geometry has been created yet
1409 * for the tileset: It solely operates on the tile bounding volume that
1410 * was given in the root tile.
1411 */
1412 void OnFocusEditorViewportOnThis();
1413
1414 void RuntimeSettingsChanged(
1415 UObject* pObject,
1416 struct FPropertyChangedEvent& changed);
1417
1418 void OnPreBeginPIE(bool bIsSimulating);
1419#endif
1420
1421private:
1422 TUniquePtr<Cesium3DTilesSelection::Tileset> _pTileset;
1423 TWeakObjectPtr<UCesiumFeaturesMetadataComponent> _pFeaturesMetadataComponent;
1424 TWeakObjectPtr<UCesiumVoxelMetadataComponent> _pVoxelMetadataComponent;
1425
1426 bool _destroyOnNextTick;
1427
1428#ifdef CESIUM_DEBUG_TILE_STATES
1429 TUniquePtr<Cesium3DTilesSelection::DebugTileStateDatabase> _pStateDebug;
1430#endif
1431
1432 PRAGMA_DISABLE_DEPRECATION_WARNINGS
1433 std::optional<FMetadataDescription> _metadataDescription_DEPRECATED;
1434 PRAGMA_ENABLE_DEPRECATION_WARNINGS
1435
1436 /**
1437 * The voxel renderer component used to render voxel data. Only used for voxel
1438 * tilesets.
1439 */
1440 UCesiumVoxelRendererComponent* _pVoxelRendererComponent = nullptr;
1441
1442 // For debug output
1443 uint32_t _lastTilesRendered;
1444 uint32_t _lastWorkerThreadTileLoadQueueLength;
1445 uint32_t _lastMainThreadTileLoadQueueLength;
1446
1447 uint32_t _lastTilesVisited;
1448 uint32_t _lastCulledTilesVisited;
1449 uint32_t _lastTilesCulled;
1450 uint32_t _lastTilesOccluded;
1451 uint32_t _lastTilesWaitingForOcclusionResults;
1452 uint32_t _lastMaxDepthVisited;
1453
1454 std::chrono::high_resolution_clock::time_point _startTime;
1455
1456 bool _captureMovieMode;
1457 bool _beforeMoviePreloadAncestors;
1458 bool _beforeMoviePreloadSiblings;
1459 int32_t _beforeMovieLoadingDescendantLimit;
1460 bool _beforeMovieUseLodTransitions;
1461
1462 bool _scaleUsingDPI;
1463
1464 // This is used as a workaround for cesium-native#186
1465 //
1466 // The tiles that are no longer supposed to be rendered in the current
1467 // frame, according to ViewUpdateResult::tilesToHideThisFrame,
1468 // are kept in this list, and hidden in the NEXT frame, because some
1469 // internal occlusion culling information from Unreal might prevent
1470 // the tiles that are supposed to be rendered instead from appearing
1471 // immediately.
1472 //
1473 // If we find a way to clear the wrong occlusion information in the
1474 // Unreal Engine, then this field may be removed, and the
1475 // tilesToHideThisFrame may be hidden immediately.
1476 std::vector<Cesium3DTilesSelection::Tile::ConstPointer> _tilesToHideNextFrame;
1477
1478 int32 _tilesetsBeingDestroyed;
1479
1480 std::shared_ptr<Cesium3DTilesSelection::GltfModifier> _pGltfModifier;
1481
1482 // Make this visible to the garbage collector, but don't save/load/copy it.
1483 // Use UObject instead of TScriptInterface as suggested by
1484 // https://www.stevestreeting.com/2020/11/02/ue4-c-interfaces-hints-n-tips/,
1485 // even though this cannot be implemented through Blueprints for the moment
1486 // (see comment over UCesium3DTilesetLifecycleEventReceiver for instructions),
1487 // it's best being prepared for the future.
1488 UPROPERTY(Transient, DuplicateTransient, TextExportTransient)
1489 UObject* _pLifecycleEventReceiver;
1490
1493};
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCompletedLoadTrigger)
The delegate for the Acesium3DTileset::OnTilesetLoaded, which is triggered from UpdateLoadStatus.
FCesium3DTilesetLoadFailure OnCesium3DTilesetLoadFailure
DECLARE_DELEGATE_ThreeParams(FCesiumSampleHeightMostDetailedCallback, ACesium3DTileset *, const TArray< FCesiumSampleHeightResult > &, const TArray< FString > &)
DECLARE_MULTICAST_DELEGATE_OneParam(FCesium3DTilesetLoadFailure, const FCesium3DTilesetLoadFailureDetails &)
The delegate for OnCesium3DTilesetLoadFailure, which is triggered when the tileset encounters a load ...
EApplyDpiScaling
ETilesetSource
@ UMETA
The tileset will be loaded from Cesium Ion using the provided IonAssetID and IonAccessToken.
@ FromCesiumIon
The raster overlay will load a GeoJsonDocument from Cesium ion.
@ FromUrl
The raster overlay will load a GeoJsonDocument from a URL.
@ Tileset
Height is interpreted relative to the surface of a 3D tileset.
virtual bool ShouldTickIfViewportsOnly() const override
TSoftObjectPtr< ACesiumCameraManager > GetCameraManager() const
The actor providing custom cameras for use with this Tileset.
bool PreloadAncestors
Whether to preload ancestor tiles.
FCompletedLoadTrigger OnTilesetLoaded
A delegate that will be called whenever the tileset is fully loaded.
void UpdateTransformFromCesium()
Update the transforms of the glTF components based on the the transform of the root component.
ACesiumCreditSystem * ResolveCreditSystem()
Resolves the Cesium Credit System to use with this Actor.
bool GetReceiveDecals() const
bool SuspendUpdate
Pauses level-of-detail and culling updates of this tileset.
int64 GetIonAssetID() const
void SetMaximumScreenSpaceError(double InMaximumScreenSpaceError)
FBodyInstance BodyInstance
Define the collision profile for all the 3D tiles created inside this actor.
bool GetCreateNavCollision() const
void InvalidateResolvedGeoreference()
Invalidates the cached resolved georeference, unsubscribing from it and setting it to null.
FCustomDepthParameters GetCustomDepthParameters() const
void SetReceiveDecals(bool bReceiveDecals)
void SetUrl(const FString &InUrl)
bool GetDelayRefinementForOcclusion() const
void SetEnableOcclusionCulling(bool bEnableOcclusionCulling)
bool EnableFrustumCulling
Whether to cull tiles that are outside the frustum.
bool GetEnableOcclusionCulling() const
bool EnableFogCulling
Whether to cull tiles that are occluded by fog.
bool GetCreatePhysicsMeshes() const
bool GetIgnoreKhrMaterialsUnlit() const
int32 GetTranslucencySortPriority()
void SetWaterMaterial(UMaterialInterface *InMaterial)
bool DrawTileInfo
If true, draws debug text above each tile being rendered with information about that tile.
TMap< FString, FString > GetRequestHeaders() const
int32 MaximumSimultaneousTileLoads
The maximum number of tiles that may be loaded at once.
void SetMaterial(UMaterialInterface *InMaterial)
void PostInitProperties() override
Called after the C++ constructor and after the properties have been initialized, including those load...
Cesium3DTilesSelection::Tileset * GetTileset()
void SetLifecycleEventReceiver(UObject *EventReceiver)
Sets a receiver of events related to the lifecycle of tiles created by this tileset.
ERuntimeVirtualTextureMainPassType GetVirtualTextureRenderPassType() const
EApplyDpiScaling ApplyDpiScaling
Scale Level-of-Detail by Display DPI.
void SetRuntimeVirtualTextures(TArray< URuntimeVirtualTexture * > InRuntimeVirtualTextures)
const glm::dmat4 & GetCesiumTilesetToUnrealRelativeWorldTransform() const
This method is not supposed to be called by clients.
void SetOcclusionPoolSize(int32 newOcclusionPoolSize)
bool ShowCreditsOnScreen
Whether or not to show this tileset's credits on screen.
virtual void BeginPlay() override
TSoftObjectPtr< ACesiumCreditSystem > GetCreditSystem() const
The actor managing this tileset's content attributions.
virtual bool IsReadyForFinishDestroy() override
friend class UCesiumGltfPointsComponent
bool UpdateInEditor
If true, this tileset is ticked/updated in the editor.
const Cesium3DTilesSelection::Tileset * GetTileset() const
void SetEnableWaterMask(bool bEnableMask)
bool EnforceCulledScreenSpaceError
Whether a specified screen-space error should be enforced for tiles that are outside the frustum or h...
void StopMovieSequencer()
void InvalidateResolvedCameraManager()
Invalidates the cached resolved Camera Manager, setting it to null.
ETilesetSource GetTilesetSource() const
virtual ~ACesium3DTileset()
const std::shared_ptr< Cesium3DTilesSelection::GltfModifier > & GetGltfModifier() const
Gets the glTF modifier, an optional extension class that can edit each tile's glTF model after it has...
void SetMobility(EComponentMobility::Type NewMobility)
UCesiumIonServer * GetCesiumIonServer() const
bool GetGenerateSmoothNormals() const
void SetIgnoreKhrMaterialsUnlit(bool bIgnoreKhrMaterialsUnlit)
ACesiumCameraManager * ResolveCameraManager()
Resolves the Cesium Camera Manager to use with this Actor.
virtual void Destroyed() override
bool EnableOcclusionCulling
Whether to cull tiles that are occluded.
void SetRequestHeaders(const TMap< FString, FString > &InRequestHeaders)
int32 OcclusionPoolSize
The number of CesiumBoundingVolumeComponents to use for querying the occlusion state of traversed til...
void SetIonAssetID(int64 InAssetID)
FCesiumPointCloudShading GetPointCloudShading() const
int32 LoadingDescendantLimit
The number of loading descendents a tile should allow before deciding to render itself instead of wai...
void SetGeoreference(TSoftObjectPtr< ACesiumGeoreference > NewGeoreference)
The designated georeference actor controlling how the actor's coordinate system relates to the coordi...
float LodTransitionLength
How long dithered LOD transitions between different tiles should take, in seconds.
void UpdateLoadStatus()
virtual void PostLoad() override
bool ForbidHoles
Whether to unrefine back to a parent tile when a child isn't done loading.
bool LogSharedAssetStats
If true, logs stats on the assets in this tileset's shared asset system to the Output Log.
void SetEnableDoubleSidedCollisions(bool bEnableDoubleSidedCollisions)
double MaximumScreenSpaceError
The maximum number of pixels of error when rendering this tileset.
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override
void SetCreditSystem(TSoftObjectPtr< ACesiumCreditSystem > NewCreditSystem)
The actor managing this tileset's content attributions.
UMaterialInterface * GetMaterial() const
UMaterialInterface * GetWaterMaterial() const
void PlayMovieSequencer()
void SetCreateNavCollision(bool bCreateNavCollision)
void SetGenerateSmoothNormals(bool bGenerateSmoothNormals)
int32 GetOcclusionPoolSize() const
void InvalidateResolvedCreditSystem()
Invalidates the cached resolved Credit System, setting it to null.
void SetCreatePhysicsMeshes(bool bCreatePhysicsMeshes)
int64 MaximumCachedBytes
The maximum number of bytes that may be cached.
void PauseMovieSequencer()
friend class UnrealPrepareRendererResources
void SetPointCloudShading(FCesiumPointCloudShading InPointCloudShading)
virtual void OnConstruction(const FTransform &Transform) override
ACesiumGeoreference * ResolveGeoreference()
Resolves the Cesium Georeference to use with this Actor.
bool DelayRefinementForOcclusion
Whether to wait for valid occlusion results before refining tiles.
UMaterialInterface * GetTranslucentMaterial() const
void SetTranslucencySortPriority(int32 InTranslucencySortPriority)
FString GetIonAccessToken() const
void RefreshTileset()
Refreshes this tileset, ensuring that all materials and other settings are applied.
bool PreloadSiblings
Whether to preload sibling tiles.
void SetTranslucentMaterial(UMaterialInterface *InMaterial)
FString GetUrl() const
EComponentMobility::Type GetMobility() const
void SetIonAccessToken(const FString &InAccessToken)
double GetMaximumScreenSpaceError()
void SetTilesetSource(ETilesetSource InSource)
virtual void BeginDestroy() override
void SetUseLodTransitions(bool InUseLodTransitions)
void SampleHeightMostDetailed(const TArray< FVector > &LongitudeLatitudeHeightArray, FCesiumSampleHeightMostDetailedCallback OnHeightsSampled)
Initiates an asynchronous query for the height of this tileset at a list of cartographic positions,...
bool GetUseLodTransitions() const
virtual void Serialize(FArchive &Ar) override
TSoftObjectPtr< ACesiumGeoreference > GetGeoreference() const
The designated georeference actor controlling how the actor's coordinate system relates to the coordi...
void SetCesiumIonServer(UCesiumIonServer *Server)
ICesium3DTilesetLifecycleEventReceiver * GetLifecycleEventReceiver()
Gets the optional receiver of events related to the lifecycle of tiles created by this tileset.
bool UseLodTransitions
Use a dithering effect when transitioning between tiles of different LODs.
void SetGltfModifier(const std::shared_ptr< Cesium3DTilesSelection::GltfModifier > &Modifier)
Sets the glTF modifier, an optional extension class that can edit each tile's glTF model after it has...
bool LogSelectionStats
If true, stats about tile selection are printed to the Output Log.
void SetCameraManager(TSoftObjectPtr< ACesiumCameraManager > NewCameraManager)
The actor providing custom cameras for use with this Tileset.
double CulledScreenSpaceError
The screen-space error to be enforced for tiles that are outside the view frustum or hidden in fog.
TArray< URuntimeVirtualTexture * > GetRuntimeVirtualTextures() const
void SetAlwaysIncludeTangents(bool bAlwaysIncludeTangents)
bool GetEnableWaterMask() const
virtual void NotifyHit(class UPrimitiveComponent *MyComp, AActor *Other, class UPrimitiveComponent *OtherComp, bool bSelfMoved, FVector HitLocation, FVector HitNormal, FVector NormalImpulse, const FHitResult &Hit) override
bool GetAlwaysIncludeTangents() const
bool UnloadEditorTilesInPlayMode
Play-in-Editor creates copies of objects in the level, including tileset actors.
float GetLoadProgress() const
void SetDelayRefinementForOcclusion(bool bDelayRefinementForOcclusion)
void SetCustomDepthParameters(FCustomDepthParameters InCustomDepthParameters)
virtual void Tick(float DeltaTime) override
bool GetEnableDoubleSidedCollisions() const
Manages custom FCesiumCameras for all ACesium3DTilesets in the world.
Manages credits / atttribution for Cesium data sources.
Controls how global geospatial coordinates are mapped to coordinates in the Unreal Engine level.
An interface that receives events about the lifecycle of tiles in a Cesium3DTileset.
A component that can be added to Cesium3DTileset actors to dictate what feature ID sets or metadata t...
Defines a Cesium ion Server.
A camera description that ACesium3DTilesets can use to decide what tiles need to be loaded to suffici...
Options for adjusting how point clouds are rendered using 3D Tiles.