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