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