diff --git a/CHANGES.md b/CHANGES.md index 2ee999333..760195366 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,16 @@ # Change Log +### ? - 2024-12-02 + +##### 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. + +##### Fixes :wrench: + +- Fixed a crash that could occur when using `SampleHeightMostDetailed` on a `Cesium3DTileset` with a raster overlay. +- `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: diff --git a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp index 26b8b2d14..4bf046a1b 100644 --- a/Source/CesiumRuntime/Private/Cesium3DTileset.cpp +++ b/Source/CesiumRuntime/Private/Cesium3DTileset.cpp @@ -4,6 +4,7 @@ #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" @@ -93,7 +94,6 @@ ACesium3DTileset::ACesium3DTileset() _beforeMovieUseLodTransitions{true}, _tilesetsBeingDestroyed(0) { - PrimaryActorTick.bCanEverTick = true; PrimaryActorTick.TickGroup = ETickingGroup::TG_PostUpdateWork; @@ -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(); } @@ -547,7 +553,6 @@ void ACesium3DTileset::PauseMovieSequencer() { this->StopMovieSequencer(); } #if WITH_EDITOR void ACesium3DTileset::OnFocusEditorViewportOnThis() { - UE_LOG( LogCesium, Verbose, @@ -668,7 +673,6 @@ ACesium3DTileset::GetCesiumTilesetToUnrealRelativeWorldTransform() const { } void ACesium3DTileset::UpdateTransformFromCesium() { - const glm::dmat4& CesiumToUnreal = this->GetCesiumTilesetToUnrealRelativeWorldTransform(); TArray gltfComponents; @@ -922,7 +926,6 @@ class UnrealResourcePreparer virtual void* prepareRasterInMainThread( CesiumRasterOverlays::RasterOverlayTile& rasterTile, void* pLoadThreadResult) override { - TUniquePtr pLoadedTexture{ static_cast( pLoadThreadResult)}; @@ -1061,7 +1064,6 @@ void ACesium3DTileset::UpdateLoadStatus() { } namespace { - const TSharedRef& getCesiumViewExtension() { static TSharedRef @@ -1069,7 +1071,6 @@ getCesiumViewExtension() { GEngine->ViewExtensions->NewExtension(); return cesiumViewExtension; } - } // namespace void ACesium3DTileset::LoadTileset() { @@ -1278,6 +1279,14 @@ 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 +1339,9 @@ 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 +1380,9 @@ 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 +1433,9 @@ 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, @@ -1494,7 +1512,6 @@ std::vector ACesium3DTileset::GetPlayerCameras() const { for (auto playerControllerIt = pWorld->GetPlayerControllerIterator(); playerControllerIt; playerControllerIt++) { - const TWeakObjectPtr pPlayerController = *playerControllerIt; if (pPlayerController == nullptr) { @@ -1674,7 +1691,6 @@ ACesium3DTileset::CreateViewStateFromViewParameters( const FCesiumCamera& camera, const glm::dmat4& unrealWorldToTileset, UCesiumEllipsoid* ellipsoid) { - double horizontalFieldOfView = FMath::DegreesToRadians(camera.FieldOfViewDegrees); @@ -1970,7 +1986,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState( check(Georeference); for (Cesium3DTilesSelection::Tile* tile : result.tilesToRenderThisFrame) { - CesiumGeometry::OrientedBoundingBox obb = Cesium3DTilesSelection::getOrientedBoundingBoxFromBoundingVolume( tile->getBoundingVolume(), @@ -2008,7 +2023,6 @@ void ACesium3DTileset::updateLastViewUpdateResultState( result.tilesWaitingForOcclusionResults != this->_lastTilesWaitingForOcclusionResults || result.maxDepthVisited != this->_lastMaxDepthVisited) { - this->_lastTilesRendered = result.tilesToRenderThisFrame.size(); this->_lastWorkerThreadTileLoadQueueLength = result.workerThreadTileLoadQueueLength; 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/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) 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.