From 5775916f8aed7a9a3c9b0181c2bc4ee73713975e Mon Sep 17 00:00:00 2001 From: Kieran Coppins Date: Mon, 11 Nov 2024 17:06:07 +0000 Subject: [PATCH 1/7] Use a soft object reference for cartographic polygons --- Source/CesiumRuntime/Private/CesiumPolygonRasterOverlay.cpp | 2 +- Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumPolygonRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumPolygonRasterOverlay.cpp index 66a465a45..3f8a7ba6d 100644 --- a/Source/CesiumRuntime/Private/CesiumPolygonRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumPolygonRasterOverlay.cpp @@ -28,7 +28,7 @@ UCesiumPolygonRasterOverlay::CreateOverlay( std::vector polygons; polygons.reserve(this->Polygons.Num()); - for (ACesiumCartographicPolygon* pPolygon : this->Polygons) { + for (auto& pPolygon : this->Polygons) { if (!pPolygon) { continue; } diff --git a/Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h index abf154bb8..728ecc231 100644 --- a/Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumPolygonRasterOverlay.h @@ -29,7 +29,7 @@ class CESIUMRUNTIME_API UCesiumPolygonRasterOverlay * The polygons to rasterize for this overlay. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - TArray Polygons; + TArray> Polygons; /** * Whether to invert the selection specified by the polygons. From dc4e994eade5778185a4f74f5f4987c1e492d711 Mon Sep 17 00:00:00 2001 From: Janine Liu Date: Tue, 19 Nov 2024 17:14:26 -0500 Subject: [PATCH 2/7] Call Resolve in SampleHeightMostDetailed --- Source/CesiumRuntime/Private/Cesium3DTileset.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index 26b8b2d14..0da873522 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -131,6 +131,12 @@ void ACesium3DTileset::SetMobility(EComponentMobility::Type NewMobility) { void ACesium3DTileset::SampleHeightMostDetailed( const TArray& LongitudeLatitudeHeightArray, FCesiumSampleHeightMostDetailedCallback OnHeightsSampled) { + // It's possible to call this function before a Tick happens, so make sure + // that the necessary variables are resolved. + this->ResolveGeoreference(); + this->ResolveCameraManager(); + this->ResolveCreditSystem(); + if (this->_pTileset == nullptr) { this->LoadTileset(); } From e9aea1785f42b73d82cc8902e6380ef7e0d9bad1 Mon Sep 17 00:00:00 2001 From: Janine Liu Date: Tue, 19 Nov 2024 17:16:40 -0500 Subject: [PATCH 3/7] Update changelog --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2ee999333..6adde6a3d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +### ? - 2024-12-02 + +##### Fixes :wrench: + +- Fixed a crash that could occur when using `SampleHeightMostDetailed` on a `Cesium3DTileset` with a raster overlay. + ### v2.10.0 - 2024-11-01 ##### Additions :tada: From 3d806bb4deb858f700faa5ba7c075adbd9e9e349 Mon Sep 17 00:00:00 2001 From: Julien QUENTIN Date: Wed, 20 Nov 2024 19:27:18 +0100 Subject: [PATCH 4/7] expose ellipsoid tileset creation to unreal --- .../CesiumRuntime/Private/Cesium3DTileset.cpp | 25 +++++++++++++++++++ Source/CesiumRuntime/Public/Cesium3DTileset.h | 7 +++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index 26b8b2d14..f3803a4a4 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -9,6 +9,7 @@ #include "Cesium3DTilesSelection/TilesetLoadFailureDetails.h" #include "Cesium3DTilesSelection/TilesetOptions.h" #include "Cesium3DTilesSelection/TilesetSharedAssetSystem.h" +#include "Cesium3DTilesSelection/EllipsoidTilesetLoader.h" #include "Cesium3DTilesetLoadFailureDetails.h" #include "Cesium3DTilesetRoot.h" #include "CesiumActors.h" @@ -1278,6 +1279,12 @@ void ACesium3DTileset::LoadTileset() { options.contentOptions.applyTextureTransform = false; switch (this->TilesetSource) { + case ETilesetSource::FromEllipsoid: + UE_LOG(LogCesium, Log, TEXT("Loading tileset from ellipsoid")); + this->_pTileset = TUniquePtr( + Cesium3DTilesSelection::EllipsoidTilesetLoader::createTileset( + externals, options).release()); + break; case ETilesetSource::FromUrl: UE_LOG(LogCesium, Log, TEXT("Loading tileset from URL %s"), *this->Url); this->_pTileset = MakeUnique( @@ -1330,6 +1337,12 @@ void ACesium3DTileset::LoadTileset() { } switch (this->TilesetSource) { + case ETilesetSource::FromEllipsoid: + UE_LOG( + LogCesium, + Log, + TEXT("Loading tileset from ellipsoid done")); + break; case ETilesetSource::FromUrl: UE_LOG( LogCesium, @@ -1368,6 +1381,12 @@ void ACesium3DTileset::DestroyTileset() { } switch (this->TilesetSource) { + case ETilesetSource::FromEllipsoid: + UE_LOG( + LogCesium, + Verbose, + TEXT("Destroying tileset from ellipsoid")); + break; case ETilesetSource::FromUrl: UE_LOG( LogCesium, @@ -1418,6 +1437,12 @@ void ACesium3DTileset::DestroyTileset() { this->_pTileset.Reset(); switch (this->TilesetSource) { + case ETilesetSource::FromEllipsoid: + UE_LOG( + LogCesium, + Verbose, + TEXT("Destroying tileset from ellipsoid done")); + break; case ETilesetSource::FromUrl: UE_LOG( LogCesium, diff --git a/Source/CesiumRuntime/Public/Cesium3DTileset.h b/Source/CesiumRuntime/Public/Cesium3DTileset.h index 8fa0b4c6c..7600f631d 100644 --- a/Source/CesiumRuntime/Public/Cesium3DTileset.h +++ b/Source/CesiumRuntime/Public/Cesium3DTileset.h @@ -74,7 +74,12 @@ enum class ETilesetSource : uint8 { /** * The tileset will be loaded from the specified Url. */ - FromUrl UMETA(DisplayName = "From Url") + FromUrl UMETA(DisplayName = "From Url"), + + /** + * The tileset will be loaded from the georeference ellipsoid. + */ + FromEllipsoid UMETA(DisplayName = "From Ellipsoid") }; UENUM(BlueprintType) From 02b9299921464c0803c32250c8797a4c9345e627 Mon Sep 17 00:00:00 2001 From: Julien QUENTIN Date: Wed, 20 Nov 2024 20:32:14 +0100 Subject: [PATCH 5/7] clang format --- .../CesiumRuntime/Private/Cesium3DTileset.cpp | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index f3803a4a4..87b125a04 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -4,12 +4,12 @@ #include "Async/Async.h" #include "Camera/CameraTypes.h" #include "Camera/PlayerCameraManager.h" +#include "Cesium3DTilesSelection/EllipsoidTilesetLoader.h" #include "Cesium3DTilesSelection/IPrepareRendererResources.h" #include "Cesium3DTilesSelection/Tile.h" #include "Cesium3DTilesSelection/TilesetLoadFailureDetails.h" #include "Cesium3DTilesSelection/TilesetOptions.h" #include "Cesium3DTilesSelection/TilesetSharedAssetSystem.h" -#include "Cesium3DTilesSelection/EllipsoidTilesetLoader.h" #include "Cesium3DTilesetLoadFailureDetails.h" #include "Cesium3DTilesetRoot.h" #include "CesiumActors.h" @@ -94,7 +94,6 @@ ACesium3DTileset::ACesium3DTileset() _beforeMovieUseLodTransitions{true}, _tilesetsBeingDestroyed(0) { - PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.TickGroup = ETickingGroup::TG_PostUpdateWork; @@ -548,7 +547,6 @@ void ACesium3DTileset::PauseMovieSequencer() { this->StopMovieSequencer(); } #if WITH_EDITOR void ACesium3DTileset::OnFocusEditorViewportOnThis() { - UE_LOG( LogCesium, Verbose, @@ -669,7 +667,6 @@ ACesium3DTileset::GetCesiumTilesetToUnrealRelativeWorldTransform() const { } void ACesium3DTileset::UpdateTransformFromCesium() { - const glm::dmat4& CesiumToUnreal = this->GetCesiumTilesetToUnrealRelativeWorldTransform(); TArray gltfComponents; @@ -923,7 +920,6 @@ class UnrealResourcePreparer virtual void* prepareRasterInMainThread( CesiumRasterOverlays::RasterOverlayTile& rasterTile, void* pLoadThreadResult) override { - TUniquePtr pLoadedTexture{ static_cast( pLoadThreadResult)}; @@ -1062,7 +1058,6 @@ void ACesium3DTileset::UpdateLoadStatus() { } namespace { - const TSharedRef& getCesiumViewExtension() { static TSharedRef @@ -1070,7 +1065,6 @@ getCesiumViewExtension() { GEngine->ViewExtensions->NewExtension(); return cesiumViewExtension; } - } // namespace void ACesium3DTileset::LoadTileset() { @@ -1282,8 +1276,10 @@ void ACesium3DTileset::LoadTileset() { case ETilesetSource::FromEllipsoid: UE_LOG(LogCesium, Log, TEXT("Loading tileset from ellipsoid")); this->_pTileset = TUniquePtr( - Cesium3DTilesSelection::EllipsoidTilesetLoader::createTileset( - externals, options).release()); + Cesium3DTilesSelection::EllipsoidTilesetLoader::createTileset( + externals, + options) + .release()); break; case ETilesetSource::FromUrl: UE_LOG(LogCesium, Log, TEXT("Loading tileset from URL %s"), *this->Url); @@ -1338,10 +1334,7 @@ void ACesium3DTileset::LoadTileset() { switch (this->TilesetSource) { case ETilesetSource::FromEllipsoid: - UE_LOG( - LogCesium, - Log, - TEXT("Loading tileset from ellipsoid done")); + UE_LOG(LogCesium, Log, TEXT("Loading tileset from ellipsoid done")); break; case ETilesetSource::FromUrl: UE_LOG( @@ -1382,10 +1375,7 @@ void ACesium3DTileset::DestroyTileset() { switch (this->TilesetSource) { case ETilesetSource::FromEllipsoid: - UE_LOG( - LogCesium, - Verbose, - TEXT("Destroying tileset from ellipsoid")); + UE_LOG(LogCesium, Verbose, TEXT("Destroying tileset from ellipsoid")); break; case ETilesetSource::FromUrl: UE_LOG( @@ -1438,10 +1428,7 @@ void ACesium3DTileset::DestroyTileset() { switch (this->TilesetSource) { case ETilesetSource::FromEllipsoid: - UE_LOG( - LogCesium, - Verbose, - TEXT("Destroying tileset from ellipsoid done")); + UE_LOG(LogCesium, Verbose, TEXT("Destroying tileset from ellipsoid done")); break; case ETilesetSource::FromUrl: UE_LOG( @@ -1519,7 +1506,6 @@ std::vector ACesium3DTileset::GetPlayerCameras() const { for (auto playerControllerIt = pWorld->GetPlayerControllerIterator(); playerControllerIt; playerControllerIt++) { - const TWeakObjectPtr pPlayerController = *playerControllerIt; if (pPlayerController == nullptr) { @@ -1699,7 +1685,6 @@ ACesium3DTileset::CreateViewStateFromViewParameters( const FCesiumCamera& camera, const glm::dmat4& unrealWorldToTileset, UCesiumEllipsoid* ellipsoid) { - double horizontalFieldOfView = FMath::DegreesToRadians(camera.FieldOfViewDegrees); @@ -1995,7 +1980,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState( check(Georeference); for (Cesium3DTilesSelection::Tile* tile : result.tilesToRenderThisFrame) { - CesiumGeometry::OrientedBoundingBox obb = Cesium3DTilesSelection::getOrientedBoundingBoxFromBoundingVolume( tile->getBoundingVolume(), @@ -2033,7 +2017,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState( result.tilesWaitingForOcclusionResults != this->_lastTilesWaitingForOcclusionResults || result.maxDepthVisited != this->_lastMaxDepthVisited) { - this->_lastTilesRendered = result.tilesToRenderThisFrame.size(); this->_lastWorkerThreadTileLoadQueueLength = result.workerThreadTileLoadQueueLength; From debc24c55d61b6869fd4d3810461e510788f32c1 Mon Sep 17 00:00:00 2001 From: Julien QUENTIN Date: Wed, 20 Nov 2024 20:36:00 +0100 Subject: [PATCH 6/7] update CHANGES.md --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2ee999333..9acd88c8e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +## Not Released Yet + +##### Additions :tada: + +- Added a "From Ellipsoid" option to `Cesium3DTileset` to generate a tileset by tesselating the surface of the ellipsoid, producing a simple globe tileset without terrain features. + ### v2.10.0 - 2024-11-01 ##### Additions :tada: From 99b62d17af69d885e4a1af10ab1b43534c82f493 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 21 Nov 2024 20:43:30 +1100 Subject: [PATCH 7/7] Update CHANGES.md. --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2ee999333..92999a7ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +### Not Released Yet + +##### Fixes :wrench: + +- `CesiumPolygonRasterOverlay` now references `CesiumCartographicPolygon` instances using `TSoftObjectPtr`, which allows, for example, a raster overlay in the persistent level to use a polygon in a sub-level. + ### v2.10.0 - 2024-11-01 ##### Additions :tada: