From c799b490a2b47c24e6af3bea0b20747e694e77a8 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 25 Apr 2025 13:37:31 -0400 Subject: [PATCH 01/36] VectorDocumentRasterOverlay --- .../CesiumVectorDocumentRasterOverlay.cpp | 41 ++++++++++++++++ .../Public/CesiumVectorDocument.h | 14 ++++++ .../CesiumVectorDocumentRasterOverlay.h | 48 +++++++++++++++++++ extern/cesium-native | 2 +- 4 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp create mode 100644 Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp new file mode 100644 index 000000000..833f100c4 --- /dev/null +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -0,0 +1,41 @@ +// Copyright 2020-2024 CesiumGS, Inc. and Contributors + +#include "CesiumVectorDocumentRasterOverlay.h" + +#include "CesiumCustomVersion.h" +#include "CesiumGeometry/QuadtreeTilingScheme.h" +#include "CesiumGeospatial/GlobeRectangle.h" +#include "CesiumGeospatial/Projection.h" +#include "CesiumRasterOverlays/VectorDocumentRasterOverlay.h" + +#include "CesiumRuntime.h" + +std::unique_ptr +UCesiumVectorDocumentRasterOverlay::CreateOverlay( + const CesiumRasterOverlays::RasterOverlayOptions& options) { + if (!this->VectorDocument.IsValid()) { + // Don't create an overlay with an invalid document. + return nullptr; + } + + const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid; + + CesiumGeospatial::Projection projection; + if (this->Projection == + ECesiumVectorDocumentRasterOverlayProjection::Geographic) { + projection = CesiumGeospatial::GeographicProjection(ellipsoid); + } else { + projection = CesiumGeospatial::WebMercatorProjection(ellipsoid); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + this->VectorDocument.GetDocument(), + CesiumVectorData::Color{ + std::byte{this->Color.R}, + std::byte{this->Color.G}, + std::byte{this->Color.B}, + std::byte{this->Color.A}}, + projection, + options); +} diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocument.h b/Source/CesiumRuntime/Public/CesiumVectorDocument.h index 8b2aeb5b9..6e0ee8775 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocument.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocument.h @@ -35,6 +35,20 @@ struct FCesiumVectorDocument { document) : _document(std::move(document)) {} + /** + * @brief Checks if this FCesiumVectorDocument is valid (document is not + * nullptr). + */ + bool IsValid() const { return this->_document != nullptr; } + + /** + * @brief Returns the `CesiumVectorData::VectorDocument` this wraps. + */ + const CesiumUtility::IntrusivePointer& + GetDocument() const { + return this->_document; + } + private: CesiumUtility::IntrusivePointer _document; diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h new file mode 100644 index 000000000..ebd59d593 --- /dev/null +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -0,0 +1,48 @@ +// Copyright 2020-2024 CesiumGS, Inc. and Contributors + +#pragma once + +#include "CesiumRasterOverlay.h" +#include "Components/ActorComponent.h" +#include "CoreMinimal.h" +#include "CesiumVectorDocument.h" +#include "CesiumVectorDocumentRasterOverlay.generated.h" + +UENUM(BlueprintType) +enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { + /** + * The raster overlay is projected using Web Mercator. + */ + WebMercator, + + /** + * The raster overlay is projected using a geographic projection. + */ + Geographic +}; + +UCLASS(ClassGroup = Cesium, meta = (BlueprintSpawnableComponent)) +class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay + : public UCesiumRasterOverlay { + GENERATED_BODY() + +public: + /** + * The type of projection used to project the imagery onto the globe. + * For instance, EPSG:4326 uses geographic projection and EPSG:3857 uses Web + * Mercator. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorDocumentRasterOverlayProjection Projection = + ECesiumVectorDocumentRasterOverlayProjection::WebMercator; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumVectorDocument VectorDocument; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(0, 0, 0, 255); + +protected: + virtual std::unique_ptr CreateOverlay( + const CesiumRasterOverlays::RasterOverlayOptions& options = {}) override; +}; diff --git a/extern/cesium-native b/extern/cesium-native index 9ade3c245..56cdf2c2f 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 9ade3c245e4215377ad49b746833bd385a323b31 +Subproject commit 56cdf2c2f96d8c7e66f524fc38011b7ba396da6f From 5981b198265283fdb86008be7cd52985f27c9abd Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 25 Apr 2025 16:51:06 -0400 Subject: [PATCH 02/36] Vector overlay from ion --- .../CesiumVectorDocumentRasterOverlay.cpp | 33 ++++++++++-- .../CesiumVectorDocumentRasterOverlay.h | 51 ++++++++++++++++++- extern/cesium-native | 2 +- 3 files changed, 80 insertions(+), 6 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index 833f100c4..cb2d9c400 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -7,13 +7,15 @@ #include "CesiumGeospatial/GlobeRectangle.h" #include "CesiumGeospatial/Projection.h" #include "CesiumRasterOverlays/VectorDocumentRasterOverlay.h" +#include "CesiumVectorData/VectorRasterizerStyle.h" #include "CesiumRuntime.h" std::unique_ptr UCesiumVectorDocumentRasterOverlay::CreateOverlay( const CesiumRasterOverlays::RasterOverlayOptions& options) { - if (!this->VectorDocument.IsValid()) { + if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument && + !this->VectorDocument.IsValid()) { // Don't create an overlay with an invalid document. return nullptr; } @@ -28,14 +30,37 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( projection = CesiumGeospatial::WebMercatorProjection(ellipsoid); } - return std::make_unique( - TCHAR_TO_UTF8(*this->MaterialLayerKey), - this->VectorDocument.GetDocument(), + CesiumVectorData::VectorRasterizerStyle style{ CesiumVectorData::Color{ std::byte{this->Color.R}, std::byte{this->Color.G}, std::byte{this->Color.B}, std::byte{this->Color.A}}, + this->LineWidth, + (CesiumVectorData::VectorLineWidthMode)this->LineWidthMode}; + + if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon) { + if (!IsValid(this->CesiumIonServer)) { + this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects(); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + CesiumRasterOverlays::IonVectorDocumentRasterOverlaySource{ + this->IonAssetID, + TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), + TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)}, + style, + projection, + ellipsoid, + options); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + this->VectorDocument.GetDocument(), + style, projection, + ellipsoid, options); } diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index ebd59d593..e2e511699 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -2,10 +2,11 @@ #pragma once +#include "CesiumIonServer.h" #include "CesiumRasterOverlay.h" +#include "CesiumVectorDocument.h" #include "Components/ActorComponent.h" #include "CoreMinimal.h" -#include "CesiumVectorDocument.h" #include "CesiumVectorDocumentRasterOverlay.generated.h" UENUM(BlueprintType) @@ -21,6 +22,18 @@ enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { Geographic }; +UENUM(BlueprintType) +enum class ECesiumVectorDocumentRasterOverlaySource : uint8 { + FromDocument = 0, + FromCesiumIon = 1 +}; + +UENUM(BlueprintType) +enum class ECesiumVectorDocumentRasterOverlayLineWidthMode : uint8 { + Pixels = 0, + Meters = 1 +}; + UCLASS(ClassGroup = Cesium, meta = (BlueprintSpawnableComponent)) class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay : public UCesiumRasterOverlay { @@ -37,11 +50,47 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay ECesiumVectorDocumentRasterOverlayProjection::WebMercator; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorDocumentRasterOverlaySource Source = + ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon; + + /** + * The ID of the Cesium ion asset to use. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta=(EditCondition="Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) + int64 IonAssetID; + + /** + * The Cesium ion Server from which this raster overlay is loaded. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + AdvancedDisplay, + meta = + (EditCondition = + "Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) + UCesiumIonServer* CesiumIonServer; + + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = + (EditCondition = + "Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument")) FCesiumVectorDocument VectorDocument; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") FColor Color = FColor(0, 0, 0, 255); + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + double LineWidth = 1.0; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorDocumentRasterOverlayLineWidthMode LineWidthMode = + ECesiumVectorDocumentRasterOverlayLineWidthMode::Pixels; + protected: virtual std::unique_ptr CreateOverlay( const CesiumRasterOverlays::RasterOverlayOptions& options = {}) override; diff --git a/extern/cesium-native b/extern/cesium-native index 56cdf2c2f..b0a06f60d 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 56cdf2c2f96d8c7e66f524fc38011b7ba396da6f +Subproject commit b0a06f60dc022bdb7d4ce3b754aefee4d6499412 From edb69b54dafa47497e7558646dfaff1baf87de09 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Mon, 28 Apr 2025 17:25:18 -0400 Subject: [PATCH 03/36] Update with native changes --- .../Private/CesiumVectorDocumentRasterOverlay.cpp | 2 ++ .../Public/CesiumVectorDocumentRasterOverlay.h | 9 ++++++++- extern/cesium-native | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index cb2d9c400..cc6a0ff4a 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -53,6 +53,7 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( style, projection, ellipsoid, + (uint32_t)this->MipLevels, options); } @@ -62,5 +63,6 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( style, projection, ellipsoid, + (uint32_t)this->MipLevels, options); } diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index e2e511699..e794e6111 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -81,10 +81,17 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay "Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument")) FCesiumVectorDocument VectorDocument; + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = (ClampMin = "0", ClampMax = "8")) + int32 MipLevels = 0; + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") FColor Color = FColor(0, 0, 0, 255); - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta=(ClampMin = "0")) double LineWidth = 1.0; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") diff --git a/extern/cesium-native b/extern/cesium-native index b0a06f60d..bd7ce78e8 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit b0a06f60dc022bdb7d4ce3b754aefee4d6499412 +Subproject commit bd7ce78e84148fad175784f14d6d64b3e0c063b5 From 8f0a56f7bf3a61e7a087df4089b0d07af2259f1f Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 2 May 2025 14:44:52 -0400 Subject: [PATCH 04/36] Support for vector styling callback --- .../CesiumVectorDocumentRasterOverlay.cpp | 72 ++++++--- .../Private/CesiumVectorNode.cpp | 23 +++ .../Private/CesiumVectorStyle.cpp | 45 ++++++ .../CesiumVectorDocumentRasterOverlay.h | 54 +++++-- .../CesiumRuntime/Public/CesiumVectorNode.h | 21 +++ .../CesiumRuntime/Public/CesiumVectorStyle.h | 138 ++++++++++++++++++ extern/cesium-native | 2 +- 7 files changed, 319 insertions(+), 36 deletions(-) create mode 100644 Source/CesiumRuntime/Private/CesiumVectorStyle.cpp create mode 100644 Source/CesiumRuntime/Public/CesiumVectorStyle.h diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index cc6a0ff4a..5a3f84da0 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -11,6 +11,31 @@ #include "CesiumRuntime.h" +namespace { +CesiumVectorData::VectorStyle +unrealToNativeVectorStyle(const FCesiumVectorStyle& style) { + return CesiumVectorData::VectorStyle{ + CesiumVectorData::LineStyle{ + CesiumVectorData::Color{ + style.LineStyle.Color.R, + style.LineStyle.Color.G, + style.LineStyle.Color.B, + style.LineStyle.Color.A}, + (CesiumVectorData::ColorMode)style.LineStyle.ColorMode, + style.LineStyle.Width, + (CesiumVectorData::LineWidthMode)style.LineStyle.WidthMode}, + CesiumVectorData::PolygonStyle{ + CesiumVectorData::Color{ + style.PolygonStyle.Color.R, + style.PolygonStyle.Color.G, + style.PolygonStyle.Color.B, + style.PolygonStyle.Color.A}, + (CesiumVectorData::ColorMode)style.PolygonStyle.ColorMode, + style.PolygonStyle.Fill, + style.PolygonStyle.Stroke}}; +} +} // namespace + std::unique_ptr UCesiumVectorDocumentRasterOverlay::CreateOverlay( const CesiumRasterOverlays::RasterOverlayOptions& options) { @@ -20,24 +45,37 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( return nullptr; } - const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid; - CesiumGeospatial::Projection projection; if (this->Projection == ECesiumVectorDocumentRasterOverlayProjection::Geographic) { - projection = CesiumGeospatial::GeographicProjection(ellipsoid); + projection = CesiumGeospatial::GeographicProjection(options.ellipsoid); } else { - projection = CesiumGeospatial::WebMercatorProjection(ellipsoid); + projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); + } + + CesiumVectorData::VectorStyle style = + unrealToNativeVectorStyle(this->DefaultStyle); + + std::optional + callbackOpt = std::nullopt; + + if (this->StyleCallback.IsBound()) { + callbackOpt = [Callback = this->StyleCallback]( + const CesiumUtility::IntrusivePointer< + CesiumVectorData::VectorDocument>& doc, + const CesiumVectorData::VectorNode* pNode) { + return Callback.Execute(FCesiumVectorNode(doc, pNode)).toNative(); + }; } - CesiumVectorData::VectorRasterizerStyle style{ - CesiumVectorData::Color{ - std::byte{this->Color.R}, - std::byte{this->Color.G}, - std::byte{this->Color.B}, - std::byte{this->Color.A}}, - this->LineWidth, - (CesiumVectorData::VectorLineWidthMode)this->LineWidthMode}; + CesiumRasterOverlays::VectorDocumentRasterOverlayOptions vectorOptions{ + unrealToNativeVectorStyle(this->DefaultStyle), + callbackOpt, + std::move(projection), + options.ellipsoid, + this->MipLevels}; + + const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid; if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon) { if (!IsValid(this->CesiumIonServer)) { @@ -50,19 +88,13 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( this->IonAssetID, TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)}, - style, - projection, - ellipsoid, - (uint32_t)this->MipLevels, + vectorOptions, options); } return std::make_unique( TCHAR_TO_UTF8(*this->MaterialLayerKey), this->VectorDocument.GetDocument(), - style, - projection, - ellipsoid, - (uint32_t)this->MipLevels, + vectorOptions, options); } diff --git a/Source/CesiumRuntime/Private/CesiumVectorNode.cpp b/Source/CesiumRuntime/Private/CesiumVectorNode.cpp index 6808e4a74..9eb4eb8db 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorNode.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorNode.cpp @@ -256,6 +256,29 @@ bool UCesiumVectorNodeBlueprintLibrary::FindNodeByIntId( return false; } +bool UCesiumVectorNodeBlueprintLibrary::GetStyle( + const FCesiumVectorNode& InVectorNode, + FCesiumVectorStyle& OutStyle) { + if (!InVectorNode._document || InVectorNode._node == nullptr || + !InVectorNode._node->style) { + return false; + } + + OutStyle = FCesiumVectorStyle::fromNative(*InVectorNode._node->style); + return true; +} + +FCesiumVectorStyle UCesiumVectorNodeBlueprintLibrary::GetStyleOrDefault( + const FCesiumVectorNode& InVectorNode, + const FCesiumVectorStyle& InDefaultStyle) { + if (!InVectorNode._document || InVectorNode._node == nullptr || + !InVectorNode._node->style) { + return InDefaultStyle; + } + + return FCesiumVectorStyle::fromNative(*InVectorNode._node->style); +} + ECesiumVectorPrimitiveType UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveType( const FCesiumVectorPrimitive& InPrimitive) { diff --git a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp new file mode 100644 index 000000000..4aecf1d63 --- /dev/null +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -0,0 +1,45 @@ +#include "CesiumVectorStyle.h" + +CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { + return CesiumVectorData::VectorStyle{ + CesiumVectorData::LineStyle{ + CesiumVectorData::Color{ + this->LineStyle.Color.R, + this->LineStyle.Color.G, + this->LineStyle.Color.B, + this->LineStyle.Color.A}, + (CesiumVectorData::ColorMode)this->LineStyle.ColorMode, + this->LineStyle.Width, + (CesiumVectorData::LineWidthMode)this->LineStyle.WidthMode}, + CesiumVectorData::PolygonStyle{ + CesiumVectorData::Color{ + this->PolygonStyle.Color.R, + this->PolygonStyle.Color.G, + this->PolygonStyle.Color.B, + this->PolygonStyle.Color.A}, + (CesiumVectorData::ColorMode)this->PolygonStyle.ColorMode, + this->PolygonStyle.Fill, + this->PolygonStyle.Outline}}; +} + +FCesiumVectorStyle FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) { + return FCesiumVectorStyle{ + FCesiumVectorLineStyle{ + FColor( + (uint8)style.line.color.r, + (uint8)style.line.color.g, + (uint8)style.line.color.b, + (uint8)style.line.color.a), + (ECesiumVectorColorMode)style.line.colorMode, + style.line.width, + (ECesiumVectorLineWidthMode)style.line.widthMode}, + FCesiumVectorPolygonStyle{ + FColor( + (uint8)style.polygon.color.r, + (uint8)style.polygon.color.g, + (uint8)style.polygon.color.b, + (uint8)style.polygon.color.a), + (ECesiumVectorColorMode)style.polygon.colorMode, + style.polygon.fill, + style.polygon.outline}}; +} diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index e794e6111..05af89752 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -5,10 +5,15 @@ #include "CesiumIonServer.h" #include "CesiumRasterOverlay.h" #include "CesiumVectorDocument.h" +#include "CesiumVectorStyle.h" #include "Components/ActorComponent.h" #include "CoreMinimal.h" +#include "Delegates/Delegate.h" #include "CesiumVectorDocumentRasterOverlay.generated.h" +/** + * The projection used by a CesiumVectorDocumentRasterOverlay. + */ UENUM(BlueprintType) enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { /** @@ -22,19 +27,33 @@ enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { Geographic }; +/** + * Configures where the CesiumVectorDocumentRasterOverlay should load its vector + * data from. + */ UENUM(BlueprintType) enum class ECesiumVectorDocumentRasterOverlaySource : uint8 { + /** + * The raster overlay will display the provided VectorDocument. + */ FromDocument = 0, + /** + * The raster overlay will load the VectorDocument from Cesium ion. + */ FromCesiumIon = 1 }; -UENUM(BlueprintType) -enum class ECesiumVectorDocumentRasterOverlayLineWidthMode : uint8 { - Pixels = 0, - Meters = 1 -}; - -UCLASS(ClassGroup = Cesium, meta = (BlueprintSpawnableComponent)) +DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam( + FCesiumVectorStyle, + FCesiumVectorDocumentRasterOverlayStyleCallback, + FCesiumVectorNode, + InNode); + +UCLASS( + ClassGroup = Cesium, + BlueprintType, + Blueprintable, + meta = (BlueprintSpawnableComponent)) class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay : public UCesiumRasterOverlay { GENERATED_BODY() @@ -56,7 +75,13 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay /** * The ID of the Cesium ion asset to use. */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta=(EditCondition="Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = + (EditCondition = + "Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) int64 IonAssetID; /** @@ -89,14 +114,13 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay int32 MipLevels = 0; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FColor Color = FColor(0, 0, 0, 255); - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta=(ClampMin = "0")) - double LineWidth = 1.0; + FCesiumVectorStyle DefaultStyle; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorDocumentRasterOverlayLineWidthMode LineWidthMode = - ECesiumVectorDocumentRasterOverlayLineWidthMode::Pixels; + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium") + FCesiumVectorDocumentRasterOverlayStyleCallback StyleCallback; protected: virtual std::unique_ptr CreateOverlay( diff --git a/Source/CesiumRuntime/Public/CesiumVectorNode.h b/Source/CesiumRuntime/Public/CesiumVectorNode.h index c6ce2445d..f7f934fea 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorNode.h +++ b/Source/CesiumRuntime/Public/CesiumVectorNode.h @@ -5,6 +5,7 @@ #include "CesiumUtility/IntrusivePointer.h" #include "CesiumVectorData/VectorDocument.h" #include "CesiumVectorData/VectorNode.h" +#include "CesiumVectorStyle.h" #include "JsonObjectWrapper.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "Templates/SharedPointer.h" @@ -179,6 +180,26 @@ class UCesiumVectorNodeBlueprintLibrary : public UBlueprintFunctionLibrary { const FCesiumVectorNode& InVectorNode, int64 InNodeId, FCesiumVectorNode& OutNode); + + /** + * @brief Returns true if this node has a style, or false if no style is + * attached. If this node has a style, OutStyle will be set to that style. + */ + UFUNCTION( + BlueprintCallable, + Category = "Cesium|Vector|Node", + meta = (DisplayName = "Get Node Style")) + static UPARAM(DisplayName = "Has Style") bool GetStyle( + const FCesiumVectorNode& InVectorNode, + FCesiumVectorStyle& OutStyle); + + /** + * @brief Returns the style on this node, or the default style if this node + * has no style attached. + */ + static FCesiumVectorStyle GetStyleOrDefault( + const FCesiumVectorNode& InVectorNode, + const FCesiumVectorStyle& InDefaultStyle); }; /** diff --git a/Source/CesiumRuntime/Public/CesiumVectorStyle.h b/Source/CesiumRuntime/Public/CesiumVectorStyle.h new file mode 100644 index 000000000..6031dd6ad --- /dev/null +++ b/Source/CesiumRuntime/Public/CesiumVectorStyle.h @@ -0,0 +1,138 @@ +#pragma once + +#include "CoreMinimal.h" +#include "UObject/ObjectMacros.h" +#include "CesiumVectorData/VectorStyle.h" + +#include "CesiumVectorStyle.generated.h" + +/** + * The mode used to render polylines and strokes. + */ + UENUM(BlueprintType) + enum class ECesiumVectorLineWidthMode : uint8 { + /** + * The line width represents the number of pixels the line will take up, + * regardless of LOD. + */ + Pixels = 0, + /** + * The line width represents the physical size of the line in meters. + */ + Meters = 1 + }; + + /** + * The mode used to interpret the color value provided in a style. + */ + UENUM(BlueprintType) + enum class ECesiumVectorColorMode : uint8 { + /** + * The normal color mode. The color will be used directly. + */ + Normal = 0, + /** + * The color will be chosen randomly. + * + * The color randomization will be applied to each component, with the + * resulting value between 0 and the specified color component value. Alpha is + * always ignored. For example, if the color was 0xff000077 (only 0x77 in the + * green component), the resulting randomized value could be 0xff000041, or + * 0xff000076, but never 0xff0000aa. + */ + Random = 1 + }; + + /** + * The style used to draw polylines and strokes. + */ + USTRUCT(BlueprintType) + struct FCesiumVectorLineStyle { + GENERATED_BODY() + + /** + * The color to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + /** + * The color mode to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorColorMode ColorMode = + ECesiumVectorColorMode::Normal; + /** + * The width of the line or stroke, with the unit specified by `WidthMode`. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta = (ClampMin = "0")) + double Width = 1.0; + /** + * The mode to use when interpreting `Width`. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorLineWidthMode WidthMode = + ECesiumVectorLineWidthMode::Pixels; + }; + + /** + * The style used to draw polygons. + */ + USTRUCT(BlueprintType) + struct FCesiumVectorPolygonStyle { + GENERATED_BODY() + + /** + * The color to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + /** + * The color mode to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorColorMode ColorMode = + ECesiumVectorColorMode::Normal; + /** + * Whether the polygon should be filled. The `ColorStyle` specified + * here will be used for the fill color. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + bool Fill = true; + /** + * Whether the polygon should be outlined. The `LineStyle` specified on + * the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for + * the stroke color. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + bool Outline = false; + }; + + /** + * Style information to use when drawing vector data. + */ + USTRUCT(BlueprintType) + struct FCesiumVectorStyle { + GENERATED_BODY() + + /** + * Styles to use when drawing polylines and stroking shapes. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumVectorLineStyle LineStyle; + + /** + * Styles to use when drawing polygons. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumVectorPolygonStyle PolygonStyle; + + /** + * Converts this Unreal representation into the Cesium Native equivalent. + */ + CesiumVectorData::VectorStyle toNative() const; + + /** + * Creates this Unreal representation from the Cesium Native equivalent. + */ + static FCesiumVectorStyle fromNative(const CesiumVectorData::VectorStyle& style); + }; diff --git a/extern/cesium-native b/extern/cesium-native index bd7ce78e8..63f569813 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit bd7ce78e84148fad175784f14d6d64b3e0c063b5 +Subproject commit 63f56981335b5f55d9d82cd6c2c0330fe372150e From 992c2eeb165693c63a90e396cec2aaffd82de508 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 2 May 2025 16:14:14 -0400 Subject: [PATCH 05/36] Working style callback --- .../CesiumVectorDocumentRasterOverlay.cpp | 12 +- .../Private/CesiumVectorStyle.cpp | 5 +- .../CesiumVectorDocumentRasterOverlay.h | 13 +- .../CesiumRuntime/Public/CesiumVectorStyle.h | 254 +++++++++--------- extern/cesium-native | 2 +- 5 files changed, 147 insertions(+), 139 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index 5a3f84da0..14b67aabf 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -32,7 +32,7 @@ unrealToNativeVectorStyle(const FCesiumVectorStyle& style) { style.PolygonStyle.Color.A}, (CesiumVectorData::ColorMode)style.PolygonStyle.ColorMode, style.PolygonStyle.Fill, - style.PolygonStyle.Stroke}}; + style.PolygonStyle.Outline}}; } } // namespace @@ -63,8 +63,14 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( callbackOpt = [Callback = this->StyleCallback]( const CesiumUtility::IntrusivePointer< CesiumVectorData::VectorDocument>& doc, - const CesiumVectorData::VectorNode* pNode) { - return Callback.Execute(FCesiumVectorNode(doc, pNode)).toNative(); + const CesiumVectorData::VectorNode* pNode) + -> std::optional { + FCesiumVectorStyle style; + if (Callback.Execute(FCesiumVectorNode(doc, pNode), style)) { + return style.toNative(); + } + + return std::nullopt; }; } diff --git a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp index 4aecf1d63..0a34fc0e2 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -1,6 +1,6 @@ #include "CesiumVectorStyle.h" -CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { +CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { return CesiumVectorData::VectorStyle{ CesiumVectorData::LineStyle{ CesiumVectorData::Color{ @@ -22,7 +22,8 @@ CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { this->PolygonStyle.Outline}}; } -FCesiumVectorStyle FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) { +FCesiumVectorStyle +FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) { return FCesiumVectorStyle{ FCesiumVectorLineStyle{ FColor( diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index 05af89752..71420b484 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -43,11 +43,13 @@ enum class ECesiumVectorDocumentRasterOverlaySource : uint8 { FromCesiumIon = 1 }; -DECLARE_DYNAMIC_DELEGATE_RetVal_OneParam( - FCesiumVectorStyle, +DECLARE_DYNAMIC_DELEGATE_RetVal_TwoParams( + bool, FCesiumVectorDocumentRasterOverlayStyleCallback, FCesiumVectorNode, - InNode); + InNode, + FCesiumVectorStyle&, + OutStyle); UCLASS( ClassGroup = Cesium, @@ -116,10 +118,7 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") FCesiumVectorStyle DefaultStyle; - UPROPERTY( - EditAnywhere, - BlueprintReadWrite, - Category = "Cesium") + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") FCesiumVectorDocumentRasterOverlayStyleCallback StyleCallback; protected: diff --git a/Source/CesiumRuntime/Public/CesiumVectorStyle.h b/Source/CesiumRuntime/Public/CesiumVectorStyle.h index 6031dd6ad..0d0f235ae 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorStyle.h +++ b/Source/CesiumRuntime/Public/CesiumVectorStyle.h @@ -1,138 +1,140 @@ #pragma once +#include "CesiumVectorData/VectorStyle.h" #include "CoreMinimal.h" #include "UObject/ObjectMacros.h" -#include "CesiumVectorData/VectorStyle.h" #include "CesiumVectorStyle.generated.h" /** * The mode used to render polylines and strokes. */ - UENUM(BlueprintType) - enum class ECesiumVectorLineWidthMode : uint8 { - /** - * The line width represents the number of pixels the line will take up, - * regardless of LOD. - */ - Pixels = 0, - /** - * The line width represents the physical size of the line in meters. - */ - Meters = 1 - }; - - /** - * The mode used to interpret the color value provided in a style. - */ - UENUM(BlueprintType) - enum class ECesiumVectorColorMode : uint8 { - /** - * The normal color mode. The color will be used directly. - */ - Normal = 0, - /** - * The color will be chosen randomly. - * - * The color randomization will be applied to each component, with the - * resulting value between 0 and the specified color component value. Alpha is - * always ignored. For example, if the color was 0xff000077 (only 0x77 in the - * green component), the resulting randomized value could be 0xff000041, or - * 0xff000076, but never 0xff0000aa. - */ - Random = 1 - }; - - /** - * The style used to draw polylines and strokes. - */ - USTRUCT(BlueprintType) - struct FCesiumVectorLineStyle { - GENERATED_BODY() - - /** - * The color to be used. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); - /** - * The color mode to be used. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorColorMode ColorMode = - ECesiumVectorColorMode::Normal; - /** - * The width of the line or stroke, with the unit specified by `WidthMode`. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta = (ClampMin = "0")) - double Width = 1.0; - /** - * The mode to use when interpreting `Width`. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorLineWidthMode WidthMode = - ECesiumVectorLineWidthMode::Pixels; - }; - - /** - * The style used to draw polygons. - */ - USTRUCT(BlueprintType) - struct FCesiumVectorPolygonStyle { - GENERATED_BODY() - - /** - * The color to be used. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); - /** - * The color mode to be used. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorColorMode ColorMode = - ECesiumVectorColorMode::Normal; - /** - * Whether the polygon should be filled. The `ColorStyle` specified - * here will be used for the fill color. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - bool Fill = true; - /** - * Whether the polygon should be outlined. The `LineStyle` specified on - * the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for - * the stroke color. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - bool Outline = false; - }; - - /** - * Style information to use when drawing vector data. - */ - USTRUCT(BlueprintType) - struct FCesiumVectorStyle { - GENERATED_BODY() - - /** - * Styles to use when drawing polylines and stroking shapes. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FCesiumVectorLineStyle LineStyle; - - /** - * Styles to use when drawing polygons. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FCesiumVectorPolygonStyle PolygonStyle; +UENUM(BlueprintType) +enum class ECesiumVectorLineWidthMode : uint8 { + /** + * The line width represents the number of pixels the line will take up, + * regardless of LOD. + */ + Pixels = 0, + /** + * The line width represents the physical size of the line in meters. + */ + Meters = 1 +}; + +/** + * The mode used to interpret the color value provided in a style. + */ +UENUM(BlueprintType) +enum class ECesiumVectorColorMode : uint8 { + /** + * The normal color mode. The color will be used directly. + */ + Normal = 0, + /** + * The color will be chosen randomly. + * + * The color randomization will be applied to each component, with the + * resulting value between 0 and the specified color component value. Alpha is + * always ignored. For example, if the color was 0xff000077 (only 0x77 in the + * green component), the resulting randomized value could be 0xff000041, or + * 0xff000076, but never 0xff0000aa. + */ + Random = 1 +}; + +/** + * The style used to draw polylines and strokes. + */ +USTRUCT(BlueprintType) +struct FCesiumVectorLineStyle { + GENERATED_BODY() + + /** + * The color to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + /** + * The color mode to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorColorMode ColorMode = ECesiumVectorColorMode::Normal; + /** + * The width of the line or stroke, with the unit specified by `WidthMode`. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = (ClampMin = "0")) + double Width = 1.0; + /** + * The mode to use when interpreting `Width`. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorLineWidthMode WidthMode = ECesiumVectorLineWidthMode::Pixels; +}; + +/** + * The style used to draw polygons. + */ +USTRUCT(BlueprintType) +struct FCesiumVectorPolygonStyle { + GENERATED_BODY() + + /** + * The color to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + /** + * The color mode to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumVectorColorMode ColorMode = ECesiumVectorColorMode::Normal; + /** + * Whether the polygon should be filled. The `ColorStyle` specified + * here will be used for the fill color. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + bool Fill = true; + /** + * Whether the polygon should be outlined. The `LineStyle` specified on + * the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for + * the stroke color. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + bool Outline = false; +}; + +/** + * Style information to use when drawing vector data. + */ +USTRUCT(BlueprintType) +struct FCesiumVectorStyle { + GENERATED_BODY() + + /** + * Styles to use when drawing polylines and stroking shapes. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumVectorLineStyle LineStyle; + + /** + * Styles to use when drawing polygons. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumVectorPolygonStyle PolygonStyle; - /** - * Converts this Unreal representation into the Cesium Native equivalent. - */ - CesiumVectorData::VectorStyle toNative() const; + /** + * Converts this Unreal representation into the Cesium Native equivalent. + */ + CesiumVectorData::VectorStyle toNative() const; - /** - * Creates this Unreal representation from the Cesium Native equivalent. - */ - static FCesiumVectorStyle fromNative(const CesiumVectorData::VectorStyle& style); - }; + /** + * Creates this Unreal representation from the Cesium Native equivalent. + */ + static FCesiumVectorStyle + fromNative(const CesiumVectorData::VectorStyle& style); +}; diff --git a/extern/cesium-native b/extern/cesium-native index 63f569813..a0d53793d 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 63f56981335b5f55d9d82cd6c2c0330fe372150e +Subproject commit a0d53793d4cfeafee01a9e9d9a2fbf6345ffb2f2 From 35cf828a5319131aae3fc57f6ceb369303d0f9a9 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 2 May 2025 16:37:11 -0400 Subject: [PATCH 06/36] Cleanup --- .../CesiumVectorDocumentRasterOverlay.cpp | 32 +------------------ 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index 14b67aabf..7dbba4768 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -11,31 +11,6 @@ #include "CesiumRuntime.h" -namespace { -CesiumVectorData::VectorStyle -unrealToNativeVectorStyle(const FCesiumVectorStyle& style) { - return CesiumVectorData::VectorStyle{ - CesiumVectorData::LineStyle{ - CesiumVectorData::Color{ - style.LineStyle.Color.R, - style.LineStyle.Color.G, - style.LineStyle.Color.B, - style.LineStyle.Color.A}, - (CesiumVectorData::ColorMode)style.LineStyle.ColorMode, - style.LineStyle.Width, - (CesiumVectorData::LineWidthMode)style.LineStyle.WidthMode}, - CesiumVectorData::PolygonStyle{ - CesiumVectorData::Color{ - style.PolygonStyle.Color.R, - style.PolygonStyle.Color.G, - style.PolygonStyle.Color.B, - style.PolygonStyle.Color.A}, - (CesiumVectorData::ColorMode)style.PolygonStyle.ColorMode, - style.PolygonStyle.Fill, - style.PolygonStyle.Outline}}; -} -} // namespace - std::unique_ptr UCesiumVectorDocumentRasterOverlay::CreateOverlay( const CesiumRasterOverlays::RasterOverlayOptions& options) { @@ -53,9 +28,6 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); } - CesiumVectorData::VectorStyle style = - unrealToNativeVectorStyle(this->DefaultStyle); - std::optional callbackOpt = std::nullopt; @@ -75,14 +47,12 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( } CesiumRasterOverlays::VectorDocumentRasterOverlayOptions vectorOptions{ - unrealToNativeVectorStyle(this->DefaultStyle), + this->DefaultStyle.toNative(), callbackOpt, std::move(projection), options.ellipsoid, this->MipLevels}; - const CesiumGeospatial::Ellipsoid& ellipsoid = options.ellipsoid; - if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon) { if (!IsValid(this->CesiumIonServer)) { this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects(); From 4649dcef3bd56db481532654a38dd1354c5d6539 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 20 May 2025 17:27:18 -0400 Subject: [PATCH 07/36] Update from changes in Native --- .../CesiumVectorDocumentRasterOverlay.cpp | 6 +- .../Private/CesiumVectorNode.cpp | 399 ------------------ .../Public/CesiumGeoJsonDocument.h | 2 +- .../CesiumVectorDocumentRasterOverlay.h | 8 +- .../CesiumRuntime/Public/CesiumVectorNode.h | 331 --------------- 5 files changed, 8 insertions(+), 738 deletions(-) delete mode 100644 Source/CesiumRuntime/Private/CesiumVectorNode.cpp delete mode 100644 Source/CesiumRuntime/Public/CesiumVectorNode.h diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index 7dbba4768..974fcab67 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -34,11 +34,11 @@ UCesiumVectorDocumentRasterOverlay::CreateOverlay( if (this->StyleCallback.IsBound()) { callbackOpt = [Callback = this->StyleCallback]( const CesiumUtility::IntrusivePointer< - CesiumVectorData::VectorDocument>& doc, - const CesiumVectorData::VectorNode* pNode) + CesiumVectorData::GeoJsonDocument>& doc, + const CesiumVectorData::GeoJsonObject* pNode) -> std::optional { FCesiumVectorStyle style; - if (Callback.Execute(FCesiumVectorNode(doc, pNode), style)) { + if (Callback.Execute(FCesiumGeoJsonObject(doc, pNode), style)) { return style.toNative(); } diff --git a/Source/CesiumRuntime/Private/CesiumVectorNode.cpp b/Source/CesiumRuntime/Private/CesiumVectorNode.cpp deleted file mode 100644 index 9eb4eb8db..000000000 --- a/Source/CesiumRuntime/Private/CesiumVectorNode.cpp +++ /dev/null @@ -1,399 +0,0 @@ -#include "CesiumVectorNode.h" - -#include "CesiumGeospatial/Cartographic.h" -#include "CesiumGeospatial/CompositeCartographicPolygon.h" -#include "Dom/JsonObject.h" - -#include -#include -#include - -int64 UCesiumVectorNodeBlueprintLibrary::GetIdAsInteger( - const FCesiumVectorNode& InVectorNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return -1; - } - const int64_t* pId = std::get_if(&InVectorNode._node->id); - if (!pId) { - return -1; - } - - return *pId; -} - -FString UCesiumVectorNodeBlueprintLibrary::GetIdAsString( - const FCesiumVectorNode& InVectorNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - struct GetIdVisitor { - FString operator()(const int64_t& id) { return FString::FromInt(id); } - FString operator()(const std::string& id) { - return UTF8_TO_TCHAR(id.c_str()); - } - FString operator()(const std::monostate& id) { return {}; } - }; - - return std::visit(GetIdVisitor{}, InVectorNode._node->id); -} - -TArray UCesiumVectorNodeBlueprintLibrary::GetChildren( - const FCesiumVectorNode& InVectorNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - TArray children; - children.Reserve(InVectorNode._node->children.size()); - for (const CesiumVectorData::VectorNode& child : - InVectorNode._node->children) { - children.Emplace(InVectorNode._document, &child); - } - return children; -} - -namespace { -TSharedPtr -jsonValueToUnrealJsonValue(const CesiumUtility::JsonValue& value) { - struct JsonValueVisitor { - TSharedPtr operator()(const CesiumUtility::JsonValue::Null&) { - return MakeShared(); - } - TSharedPtr - operator()(const CesiumUtility::JsonValue::Bool& value) { - return MakeShared(value); - } - TSharedPtr operator()(const std::string& value) { - return MakeShared(UTF8_TO_TCHAR(value.c_str())); - } - TSharedPtr operator()(const double& value) { - return MakeShared(value); - } - TSharedPtr operator()(const std::uint64_t& value) { - return MakeShared(FString::FromInt(value)); - } - TSharedPtr operator()(const std::int64_t& value) { - return MakeShared(FString::FromInt(value)); - } - TSharedPtr - operator()(const CesiumUtility::JsonValue::Array& value) { - TArray> values; - values.Reserve(value.size()); - for (const CesiumUtility::JsonValue& v : value) { - values.Emplace(jsonValueToUnrealJsonValue(v)); - } - return MakeShared(MoveTemp(values)); - } - TSharedPtr - operator()(const CesiumUtility::JsonValue::Object& value) { - TSharedPtr obj = MakeShared(); - for (const auto& [k, v] : value) { - obj->SetField(UTF8_TO_TCHAR(k.c_str()), jsonValueToUnrealJsonValue(v)); - } - return MakeShared(MoveTemp(obj)); - }; - }; - - return std::visit(JsonValueVisitor{}, value.value); -} -} // namespace - -FJsonObjectWrapper UCesiumVectorNodeBlueprintLibrary::GetProperties( - const FCesiumVectorNode& InVectorNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - TSharedPtr object = MakeShared(); - if (InVectorNode._node->properties) { - for (const auto& [k, v] : *InVectorNode._node->properties) { - object->SetField(UTF8_TO_TCHAR(k.c_str()), jsonValueToUnrealJsonValue(v)); - } - } - - FJsonObjectWrapper wrapper; - wrapper.JsonObject = object; - return wrapper; -} - -TArray UCesiumVectorNodeBlueprintLibrary::GetPrimitives( - const FCesiumVectorNode& InVectorNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - TArray primitives; - primitives.Reserve(InVectorNode._node->primitives.size()); - for (const CesiumVectorData::VectorPrimitive& primitive : - InVectorNode._node->primitives) { - primitives.Emplace(InVectorNode._document, &primitive); - } - return primitives; -} - -namespace { -TArray GetPrimitivesOfTypeInternal( - CesiumUtility::IntrusivePointer pDocument, - const CesiumVectorData::VectorNode& node, - ECesiumVectorPrimitiveType InType) { - struct CheckTypeVisitor { - ECesiumVectorPrimitiveType IntendedType; - bool operator()(const CesiumGeospatial::Cartographic&) { - return IntendedType == ECesiumVectorPrimitiveType::Point; - } - bool operator()(const std::vector&) { - return IntendedType == ECesiumVectorPrimitiveType::Line; - } - bool operator()(const CesiumGeospatial::CompositeCartographicPolygon&) { - return IntendedType == ECesiumVectorPrimitiveType::Polygon; - } - }; - - TArray primitives; - for (const CesiumVectorData::VectorPrimitive& primitive : node.primitives) { - if (std::visit(CheckTypeVisitor{InType}, primitive)) { - primitives.Emplace(pDocument, &primitive); - } - } - - return primitives; -} - -TArray GetPrimitivesOfTypeRecursivelyInternal( - CesiumUtility::IntrusivePointer pDocument, - const CesiumVectorData::VectorNode& node, - ECesiumVectorPrimitiveType InType) { - TArray primitives = - GetPrimitivesOfTypeInternal(pDocument, node, InType); - for (const CesiumVectorData::VectorNode& child : node.children) { - TArray childPrimitives = - GetPrimitivesOfTypeRecursivelyInternal(pDocument, child, InType); - for (FCesiumVectorPrimitive& childPrimitive : childPrimitives) { - primitives.Emplace(MoveTemp(childPrimitive)); - } - } - return primitives; -} -} // namespace - -TArray -UCesiumVectorNodeBlueprintLibrary::GetPrimitivesOfType( - const FCesiumVectorNode& InVectorNode, - ECesiumVectorPrimitiveType InType) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - return GetPrimitivesOfTypeInternal( - InVectorNode._document, - *InVectorNode._node, - InType); -} - -TArray -UCesiumVectorNodeBlueprintLibrary::GetPrimitivesOfTypeRecursively( - const FCesiumVectorNode& InVectorNode, - ECesiumVectorPrimitiveType InType) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - return GetPrimitivesOfTypeRecursivelyInternal( - InVectorNode._document, - *InVectorNode._node, - InType); -} - -namespace { -template -const CesiumVectorData::VectorNode* -FindNodeById(const CesiumVectorData::VectorNode& node, const T& InNodeId) { - for (const CesiumVectorData::VectorNode& child : node.children) { - const T* nodeId = std::get_if(&child.id); - if (nodeId && *nodeId == InNodeId) { - return &child; - } - - // Check children. - const CesiumVectorData::VectorNode* pChildResult = - FindNodeById(child, InNodeId); - if (pChildResult != nullptr) { - return pChildResult; - } - } - - return nullptr; -} -} // namespace - -bool UCesiumVectorNodeBlueprintLibrary::FindNodeByStringId( - const FCesiumVectorNode& InVectorNode, - const FString& InNodeId, - FCesiumVectorNode& OutNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - const std::string& id = TCHAR_TO_UTF8(*InNodeId); - const CesiumVectorData::VectorNode* pNode = - FindNodeById(*InVectorNode._node, id); - if (pNode != nullptr) { - OutNode = FCesiumVectorNode(InVectorNode._document, pNode); - return true; - } - - return false; -} - -bool UCesiumVectorNodeBlueprintLibrary::FindNodeByIntId( - const FCesiumVectorNode& InVectorNode, - int64 InNodeId, - FCesiumVectorNode& OutNode) { - if (!InVectorNode._document || InVectorNode._node == nullptr) { - return {}; - } - const CesiumVectorData::VectorNode* pNode = - FindNodeById(*InVectorNode._node, InNodeId); - if (pNode != nullptr) { - OutNode = FCesiumVectorNode(InVectorNode._document, pNode); - return true; - } - - return false; -} - -bool UCesiumVectorNodeBlueprintLibrary::GetStyle( - const FCesiumVectorNode& InVectorNode, - FCesiumVectorStyle& OutStyle) { - if (!InVectorNode._document || InVectorNode._node == nullptr || - !InVectorNode._node->style) { - return false; - } - - OutStyle = FCesiumVectorStyle::fromNative(*InVectorNode._node->style); - return true; -} - -FCesiumVectorStyle UCesiumVectorNodeBlueprintLibrary::GetStyleOrDefault( - const FCesiumVectorNode& InVectorNode, - const FCesiumVectorStyle& InDefaultStyle) { - if (!InVectorNode._document || InVectorNode._node == nullptr || - !InVectorNode._node->style) { - return InDefaultStyle; - } - - return FCesiumVectorStyle::fromNative(*InVectorNode._node->style); -} - -ECesiumVectorPrimitiveType -UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveType( - const FCesiumVectorPrimitive& InPrimitive) { - if (!InPrimitive._document || InPrimitive._primitive == nullptr) { - return {}; - } - - struct GetTypeVisitor { - ECesiumVectorPrimitiveType - operator()(const CesiumGeospatial::Cartographic&) { - return ECesiumVectorPrimitiveType::Point; - } - ECesiumVectorPrimitiveType - operator()(const std::vector&) { - return ECesiumVectorPrimitiveType::Line; - } - ECesiumVectorPrimitiveType - operator()(const CesiumGeospatial::CompositeCartographicPolygon&) { - return ECesiumVectorPrimitiveType::Polygon; - } - }; - - return std::visit(GetTypeVisitor{}, *InPrimitive._primitive); -} - -FVector UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint( - const FCesiumVectorPrimitive& InPrimitive) { - if (!InPrimitive._document || InPrimitive._primitive == nullptr) { - return {}; - } - - const CesiumGeospatial::Cartographic* pCartographic = - std::get_if(InPrimitive._primitive); - if (!pCartographic) { - return FVector::ZeroVector; - } - - return FVector( - CesiumUtility::Math::radiansToDegrees(pCartographic->longitude), - CesiumUtility::Math::radiansToDegrees(pCartographic->latitude), - pCartographic->height); -} - -TArray UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsLine( - const FCesiumVectorPrimitive& InPrimitive) { - if (!InPrimitive._document || InPrimitive._primitive == nullptr) { - return {}; - } - - const std::vector* pCartographicLine = - std::get_if>( - InPrimitive._primitive); - if (!pCartographicLine) { - return TArray(); - } - - TArray line; - line.Reserve(pCartographicLine->size()); - for (const CesiumGeospatial::Cartographic& point : *pCartographicLine) { - line.Emplace( - CesiumUtility::Math::radiansToDegrees(point.longitude), - CesiumUtility::Math::radiansToDegrees(point.latitude), - point.height); - } - - return line; -} - -FCesiumCompositeCartographicPolygon -UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPolygon( - const FCesiumVectorPrimitive& InPrimitive) { - if (!InPrimitive._document || InPrimitive._primitive == nullptr) { - return {}; - } - - const CesiumGeospatial::CompositeCartographicPolygon* pPolygon = - std::get_if( - InPrimitive._primitive); - if (!pPolygon) { - return FCesiumCompositeCartographicPolygon( - CesiumGeospatial::CompositeCartographicPolygon({})); - } - - return FCesiumCompositeCartographicPolygon(*pPolygon); -} - -FCesiumPolygonLinearRing::FCesiumPolygonLinearRing(TArray&& InPoints) - : Points(MoveTemp(InPoints)) {} - -bool UCesiumCompositeCartographicPolygonBlueprintLibrary::PolygonContainsPoint( - const FCesiumCompositeCartographicPolygon& InPolygon, - const FVector& InPoint) { - return InPolygon._polygon.contains(CesiumGeospatial::Cartographic( - CesiumUtility::Math::degreesToRadians(InPoint.X), - CesiumUtility::Math::degreesToRadians(InPoint.Y), - InPoint.Z)); -} - -TArray -UCesiumCompositeCartographicPolygonBlueprintLibrary::GetPolygonRings( - const FCesiumCompositeCartographicPolygon& InPolygon) { - const std::vector& polygons = - InPolygon._polygon.getLinearRings(); - TArray linearRings; - linearRings.Reserve(polygons.size()); - for (const CesiumGeospatial::CartographicPolygon& polygon : polygons) { - TArray points; - points.Reserve(polygon.getVertices().size()); - for (const glm::dvec2& point : polygon.getVertices()) { - points.Emplace(FVector( - CesiumUtility::Math::radiansToDegrees(point.x), - CesiumUtility::Math::radiansToDegrees(point.y), - 0)); - } - linearRings.Emplace(MoveTemp(points)); - } - return linearRings; -} diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h index c36da44fb..bea153797 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h @@ -44,7 +44,7 @@ struct FCesiumGeoJsonDocument { /** * @brief Returns the `CesiumVectorData::VectorDocument` this wraps. */ - const CesiumUtility::IntrusivePointer& + const CesiumUtility::IntrusivePointer& GetDocument() const { return this->_document; } diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index 71420b484..96eee5470 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -4,7 +4,7 @@ #include "CesiumIonServer.h" #include "CesiumRasterOverlay.h" -#include "CesiumVectorDocument.h" +#include "CesiumGeoJsonDocument.h" #include "CesiumVectorStyle.h" #include "Components/ActorComponent.h" #include "CoreMinimal.h" @@ -46,8 +46,8 @@ enum class ECesiumVectorDocumentRasterOverlaySource : uint8 { DECLARE_DYNAMIC_DELEGATE_RetVal_TwoParams( bool, FCesiumVectorDocumentRasterOverlayStyleCallback, - FCesiumVectorNode, - InNode, + FCesiumGeoJsonObject, + InObject, FCesiumVectorStyle&, OutStyle); @@ -106,7 +106,7 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay meta = (EditCondition = "Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument")) - FCesiumVectorDocument VectorDocument; + FCesiumGeoJsonDocument VectorDocument; UPROPERTY( EditAnywhere, diff --git a/Source/CesiumRuntime/Public/CesiumVectorNode.h b/Source/CesiumRuntime/Public/CesiumVectorNode.h deleted file mode 100644 index f7f934fea..000000000 --- a/Source/CesiumRuntime/Public/CesiumVectorNode.h +++ /dev/null @@ -1,331 +0,0 @@ -// Copyright 2020-2025 CesiumGS, Inc. and Contributors - -#pragma once - -#include "CesiumUtility/IntrusivePointer.h" -#include "CesiumVectorData/VectorDocument.h" -#include "CesiumVectorData/VectorNode.h" -#include "CesiumVectorStyle.h" -#include "JsonObjectWrapper.h" -#include "Kismet/BlueprintFunctionLibrary.h" -#include "Templates/SharedPointer.h" - -#include "CesiumVectorNode.generated.h" - -/** - * @brief A single node in the vector document. - * - * A node typically contains geometry along with metadata attached to that - * geometry. - */ -USTRUCT(BlueprintType) -struct FCesiumVectorNode { - GENERATED_BODY() - - /** - * @brief Creates a new `FCesiumVectorNode` containing an empty vector node. - */ - FCesiumVectorNode() : _document(nullptr), _node(nullptr) {} - - /** - * @brief Creates a new `FCesiumVectorNode` wrapping the provided - * `CesiumVectorData::VectorNode`. - */ - FCesiumVectorNode( - const CesiumUtility::IntrusivePointer& - doc, - const CesiumVectorData::VectorNode* node) - : _document(doc), _node(node) {} - -private: - CesiumUtility::IntrusivePointer _document; - const CesiumVectorData::VectorNode* _node; - - friend class UCesiumVectorNodeBlueprintLibrary; -}; - -/** - * @brief The supported types of vector data geometry primitive. - */ -UENUM(BlueprintType) -enum class ECesiumVectorPrimitiveType : uint8 { - /** @brief The Point primitive represents a single point in space. */ - Point = 0, - /** - * @brief The Line primitive represents a series of one or more line - * segments. - */ - Line = 1, - /** - * @brief The Polygon primitive represents a polygon made up of one or more - * linear rings. - */ - Polygon = 2 -}; - -/** - * @brief A single geometry primitive. The type of the primitive is represented - * by `ECesiumVectorPrimitiveType`. - */ -USTRUCT(BlueprintType) -struct FCesiumVectorPrimitive { - GENERATED_BODY() - - /** @brief Creates a new `FCesiumVectorPrimitive` with an empty primitive. */ - FCesiumVectorPrimitive() : _document(nullptr), _primitive(nullptr) {} - - /** - * @brief Creates a new `FCesiumVectorPrimitive` wrapping the provided - * `CesiumVectorData::VectorPrimitive`. - */ - FCesiumVectorPrimitive( - const CesiumUtility::IntrusivePointer& - document, - const CesiumVectorData::VectorPrimitive* primitive) - : _document(document), _primitive(primitive) {} - -private: - CesiumUtility::IntrusivePointer _document; - const CesiumVectorData::VectorPrimitive* _primitive; - - friend class UCesiumVectorPrimitiveBlueprintLibrary; -}; - -/** - * @brief A Blueprint Funciton Library for interacting with `FCesiumVectorNode` - * values. - */ -UCLASS() -class UCesiumVectorNodeBlueprintLibrary : public UBlueprintFunctionLibrary { - GENERATED_BODY() - -public: - /** - * @brief Returns the ID of the provided vector node, or -1 if no ID was - * present or if the ID is not an integer. - */ - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Node") - static int64 GetIdAsInteger(const FCesiumVectorNode& InVectorNode); - - /** - * @brief Returns the ID of the provided vector node, or an empty string if no - * ID was present. If the ID is an integer, it will be converted to a string. - */ - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Node") - static FString GetIdAsString(const FCesiumVectorNode& InVectorNode); - - /** - * @brief Returns any child nodes of this vector node. - */ - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Node") - static TArray - GetChildren(const FCesiumVectorNode& InVectorNode); - - /** - * @brief Obtains the properties attached to this node, if any. - */ - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Node") - static FJsonObjectWrapper - GetProperties(const FCesiumVectorNode& InVectorNode); - - /** - * @brief Returns an array of primitives contained in this node. - */ - UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Node") - static TArray - GetPrimitives(const FCesiumVectorNode& InVectorNode); - - /** - * @brief Returns all primitives of the given type from this node. - */ - UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Node") - static TArray GetPrimitivesOfType( - const FCesiumVectorNode& InVectorNode, - ECesiumVectorPrimitiveType InType); - - /** - * @brief Returns all primitives of the given type in this node or in any - * child nodes, recursively. - */ - UFUNCTION( - BlueprintCallable, - Category = "Cesium|Vector|Node", - meta = (DisplayName = "Get All Primitives of Type")) - static TArray GetPrimitivesOfTypeRecursively( - const FCesiumVectorNode& InVectorNode, - ECesiumVectorPrimitiveType InType); - - /** - * @brief Returns the first child node found with the given ID. If no node was - * found, "Success" will return false. - */ - UFUNCTION( - BlueprintCallable, - Category = "Cesium|Vector|Node", - meta = (DisplayName = "Find Node By String ID")) - static UPARAM(DisplayName = "Success") bool FindNodeByStringId( - const FCesiumVectorNode& InVectorNode, - const FString& InNodeId, - FCesiumVectorNode& OutNode); - - /** - * @brief Returns the first child node found with the given ID. If no node was - * found, "Success" will return false. - */ - UFUNCTION( - BlueprintCallable, - Category = "Cesium|Vector|Node", - meta = (DisplayName = "Find Node By Integer ID")) - static UPARAM(DisplayName = "Success") bool FindNodeByIntId( - const FCesiumVectorNode& InVectorNode, - int64 InNodeId, - FCesiumVectorNode& OutNode); - - /** - * @brief Returns true if this node has a style, or false if no style is - * attached. If this node has a style, OutStyle will be set to that style. - */ - UFUNCTION( - BlueprintCallable, - Category = "Cesium|Vector|Node", - meta = (DisplayName = "Get Node Style")) - static UPARAM(DisplayName = "Has Style") bool GetStyle( - const FCesiumVectorNode& InVectorNode, - FCesiumVectorStyle& OutStyle); - - /** - * @brief Returns the style on this node, or the default style if this node - * has no style attached. - */ - static FCesiumVectorStyle GetStyleOrDefault( - const FCesiumVectorNode& InVectorNode, - const FCesiumVectorStyle& InDefaultStyle); -}; - -/** - * @brief A `FCesiumCompositeCartographicPolygon` is a polygon made up of one or - * more linear rings. - */ -USTRUCT(BlueprintType) -struct FCesiumCompositeCartographicPolygon { - GENERATED_BODY() - - /** - * @brief Creates a new `FCesiumCompositeCartographicPolygon` with an empty - * composite polygon. - */ - FCesiumCompositeCartographicPolygon() : _polygon({}) {} - - /** - * @brief Creates a new `FCesiumCompositeCartographicPolygon` wrapping the - * provided `CesiumGeospatial::CompositeCartographicPolygon`. - */ - FCesiumCompositeCartographicPolygon( - const CesiumGeospatial::CompositeCartographicPolygon& polygon) - : _polygon(polygon) {} - -private: - CesiumGeospatial::CompositeCartographicPolygon _polygon; - - friend class UCesiumCompositeCartographicPolygonBlueprintLibrary; -}; - -/** - * @brief A `FCesiumPolygonLinearRing` is a single linear ring of a - * `FCesiumCompositeCartographicPolygon`. - */ -USTRUCT(BlueprintType) -struct FCesiumPolygonLinearRing { - GENERATED_BODY() -public: - /** - * @brief Creates a new `FCesiumPolygonLinearRing` with an empty linear ring. - */ - FCesiumPolygonLinearRing() : Points() {} - - /** - * @brief Creates a new `FCesiumPolygonLinearRing` from a set of - * Longitude-Latitude-Height points. - */ - FCesiumPolygonLinearRing(TArray&& InPoints); - - /** - * @brief The Longitude-Latitude-Height points of this polygon. - */ - UPROPERTY(BlueprintReadOnly, Category = "Cesium|Vector|Polygon") - TArray Points; -}; - -UCLASS() -class UCesiumCompositeCartographicPolygonBlueprintLibrary - : public UBlueprintFunctionLibrary { - GENERATED_BODY() -public: - /** - * @brief Returns whether this `FCesiumCompositeCartographicPolygon` contains - * the provided Longitude-Latitude-Height position. - */ - UFUNCTION( - BlueprintCallable, - BlueprintPure, - Category = "Cesium|Vector|Polygon") - static bool PolygonContainsPoint( - const FCesiumCompositeCartographicPolygon& InPolygon, - const FVector& InPoint); - - /** - * @brief Returns the linear rings that make up this composite polygon. - * - * The first returned ring represents the outer bounds of the polygon. Any - * additional rings define holes within those bounds. - */ - UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Polygon") - static TArray - GetPolygonRings(const FCesiumCompositeCartographicPolygon& InPolygon); -}; - -/** - * @brief A Blueprint Funciton Library for interacting with - * `FCesiumVectorPrimitive` values. - */ -UCLASS() -class UCesiumVectorPrimitiveBlueprintLibrary - : public UBlueprintFunctionLibrary { - GENERATED_BODY() -public: - /** - * @brief Returns the `ECesiumVectorPrimitiveType` of this - * `FCesiumVectorPrimitive`. - */ - UFUNCTION( - BlueprintCallable, - BlueprintPure, - Category = "Cesium|Vector|Primitive") - static ECesiumVectorPrimitiveType - GetPrimitiveType(const FCesiumVectorPrimitive& InPrimitive); - - /** - * @brief Assuming this primitive is a `ECesiumVectorPrimitiveType::Point`, - * returns the point value. If it is not a point, returns `FVector(0, 0, 0)`. - */ - UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Primitive") - static FVector GetPrimitiveAsPoint(const FCesiumVectorPrimitive& InPrimitive); - - /** - * @brief Assuming this primitive is a `ECesiumVectorPrimitiveType::Line`, - * returns the points defining the line segments. If it is not a line, returns - * an empty `TArray`. - */ - UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Primitive") - static TArray - GetPrimitiveAsLine(const FCesiumVectorPrimitive& InPrimitive); - - /** - * @brife Assuming this primitive is a `ECesiumVectorPrimitiveType::Polygon`, - * returns the `FCesiumCompositeCartographicPolygon`. If it is not a polygon, - * returns a default-constructed `FCesiumCompositeCartographicPolygon`. - */ - UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Primitive") - static FCesiumCompositeCartographicPolygon - GetPrimitiveAsPolygon(const FCesiumVectorPrimitive& InPrimitive); -}; From eb9fc2a2176f895fbb45f30d32a67b54cce58f61 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 20 May 2025 17:44:25 -0400 Subject: [PATCH 08/36] Format --- Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h | 3 ++- Source/CesiumRuntime/Public/CesiumGeoJsonObject.h | 3 +-- .../CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h index bea153797..7ee984134 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h @@ -60,7 +60,8 @@ struct FCesiumGeoJsonDocument { * a `FCesiumVectorDocument`. */ UCLASS() -class UCesiumGeoJsonDocumentBlueprintLibrary : public UBlueprintFunctionLibrary { +class UCesiumGeoJsonDocumentBlueprintLibrary + : public UBlueprintFunctionLibrary { GENERATED_BODY() public: diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h b/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h index ac323250e..16603c3e1 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h @@ -168,8 +168,7 @@ struct FCesiumGeoJsonPolygon { : _document(document), _rings(rings) {} private: - CesiumUtility::IntrusivePointer - _document; + CesiumUtility::IntrusivePointer _document; const std::vector>* _rings; friend class UCesiumGeoJsonPolygonBlueprintFunctionLibrary; diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h index 96eee5470..31243bdff 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h @@ -2,9 +2,9 @@ #pragma once +#include "CesiumGeoJsonDocument.h" #include "CesiumIonServer.h" #include "CesiumRasterOverlay.h" -#include "CesiumGeoJsonDocument.h" #include "CesiumVectorStyle.h" #include "Components/ActorComponent.h" #include "CoreMinimal.h" From 95423628b51a99891774623112ff026abb7f8858 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Wed, 21 May 2025 11:46:32 -0400 Subject: [PATCH 09/36] Remove unnecessary includes --- Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp | 2 +- .../CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp index 35290b613..cb8eed6ad 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp @@ -1,7 +1,7 @@ #include "CesiumGeoJsonObject.h" #include "CesiumGeospatial/Cartographic.h" -#include "CesiumGeospatial/CompositeCartographicPolygon.h" +#include "CesiumGeospatial/CartographicPolygon.h" #include "Dom/JsonObject.h" #include diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp index 974fcab67..5faccdcf0 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp @@ -7,7 +7,7 @@ #include "CesiumGeospatial/GlobeRectangle.h" #include "CesiumGeospatial/Projection.h" #include "CesiumRasterOverlays/VectorDocumentRasterOverlay.h" -#include "CesiumVectorData/VectorRasterizerStyle.h" +#include "CesiumVectorData/VectorStyle.h" #include "CesiumRuntime.h" From db89632d62fb8c9e29b4bfeb94566cac4f0e2c5d Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 12 Jun 2025 11:23:47 -0400 Subject: [PATCH 10/36] Update overlay for GeoJSON changes --- .../Private/CesiumGeoJsonDocument.cpp | 9 ++ .../CesiumGeoJsonDocumentRasterOverlay.cpp | 93 +++++++++++++++++++ .../CesiumVectorDocumentRasterOverlay.cpp | 76 --------------- .../Private/CesiumVectorStyle.cpp | 6 +- .../Public/CesiumGeoJsonDocument.h | 11 +-- ...h => CesiumGeoJsonDocumentRasterOverlay.h} | 82 ++++++++++++---- extern/cesium-native | 2 +- 7 files changed, 176 insertions(+), 103 deletions(-) create mode 100644 Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp delete mode 100644 Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp rename Source/CesiumRuntime/Public/{CesiumVectorDocumentRasterOverlay.h => CesiumGeoJsonDocumentRasterOverlay.h} (50%) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp index 24a8dc400..defc5baa1 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp @@ -13,6 +13,15 @@ FCesiumGeoJsonDocument::FCesiumGeoJsonDocument( std::shared_ptr&& document) : _pDocument(std::move(document)) {} +bool FCesiumGeoJsonDocument::IsValid() const { + return this->_pDocument != nullptr; +} + +const std::shared_ptr& +FCesiumGeoJsonDocument::GetDocument() const { + return this->_pDocument; +} + bool UCesiumGeoJsonDocumentBlueprintLibrary::LoadGeoJsonFromString( const FString& InString, FCesiumGeoJsonDocument& OutVectorDocument) { diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp new file mode 100644 index 000000000..10578ec13 --- /dev/null +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -0,0 +1,93 @@ +// Copyright 2020-2024 CesiumGS, Inc. and Contributors + +#include "CesiumGeoJsonDocumentRasterOverlay.h" + +#include "CesiumCustomVersion.h" +#include "CesiumGeometry/QuadtreeTilingScheme.h" +#include "CesiumGeospatial/GlobeRectangle.h" +#include "CesiumGeospatial/Projection.h" +#include "CesiumRasterOverlays/GeoJsonDocumentRasterOverlay.h" +#include "CesiumVectorData/VectorStyle.h" + +#include "CesiumRuntime.h" + +std::unique_ptr +UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( + const CesiumRasterOverlays::RasterOverlayOptions& options) { + if (this->Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromDocument && + !this->GeoJsonDocument.IsValid()) { + // Don't create an overlay with an invalid document. + return nullptr; + } + + CesiumGeospatial::Projection projection; + if (this->Projection == + ECesiumGeoJsonDocumentRasterOverlayProjection::Geographic) { + projection = CesiumGeospatial::GeographicProjection(options.ellipsoid); + } else { + projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); + } + + std::optional + callbackOpt = std::nullopt; + + if (this->StyleCallback.IsBound()) { + callbackOpt = + [Callback = this->StyleCallback]( + const std::shared_ptr& doc, + const CesiumVectorData::GeoJsonObject* pNode) + -> std::optional { + FCesiumVectorStyle style; + if (Callback.Execute(FCesiumGeoJsonObject(doc, pNode), style)) { + return style.toNative(); + } + + return std::nullopt; + }; + } + + CesiumRasterOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{ + this->DefaultStyle.toNative(), + callbackOpt, + std::move(projection), + options.ellipsoid, + this->MipLevels}; + + if (this->Source == + ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon) { + if (!IsValid(this->CesiumIonServer)) { + this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects(); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + CesiumRasterOverlays::IonGeoJsonDocumentRasterOverlaySource{ + this->IonAssetID, + TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), + TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)}, + vectorOptions, + options); + } else if ( + this->Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromUrl) { + std::vector headers; + headers.reserve(this->RequestHeaders.Num()); + + for (auto& [k, v] : this->RequestHeaders) { + headers.push_back({TCHAR_TO_UTF8(*k), TCHAR_TO_UTF8(*v)}); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + CesiumRasterOverlays::UrlGeoJsonDocumentRasterOverlaySource{ + TCHAR_TO_UTF8(*this->Url), + std::move(headers)}, + vectorOptions, + options); + } + + return std::make_unique( + TCHAR_TO_UTF8(*this->MaterialLayerKey), + this->GeoJsonDocument.GetDocument(), + vectorOptions, + options); +} diff --git a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp deleted file mode 100644 index 5faccdcf0..000000000 --- a/Source/CesiumRuntime/Private/CesiumVectorDocumentRasterOverlay.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright 2020-2024 CesiumGS, Inc. and Contributors - -#include "CesiumVectorDocumentRasterOverlay.h" - -#include "CesiumCustomVersion.h" -#include "CesiumGeometry/QuadtreeTilingScheme.h" -#include "CesiumGeospatial/GlobeRectangle.h" -#include "CesiumGeospatial/Projection.h" -#include "CesiumRasterOverlays/VectorDocumentRasterOverlay.h" -#include "CesiumVectorData/VectorStyle.h" - -#include "CesiumRuntime.h" - -std::unique_ptr -UCesiumVectorDocumentRasterOverlay::CreateOverlay( - const CesiumRasterOverlays::RasterOverlayOptions& options) { - if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument && - !this->VectorDocument.IsValid()) { - // Don't create an overlay with an invalid document. - return nullptr; - } - - CesiumGeospatial::Projection projection; - if (this->Projection == - ECesiumVectorDocumentRasterOverlayProjection::Geographic) { - projection = CesiumGeospatial::GeographicProjection(options.ellipsoid); - } else { - projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); - } - - std::optional - callbackOpt = std::nullopt; - - if (this->StyleCallback.IsBound()) { - callbackOpt = [Callback = this->StyleCallback]( - const CesiumUtility::IntrusivePointer< - CesiumVectorData::GeoJsonDocument>& doc, - const CesiumVectorData::GeoJsonObject* pNode) - -> std::optional { - FCesiumVectorStyle style; - if (Callback.Execute(FCesiumGeoJsonObject(doc, pNode), style)) { - return style.toNative(); - } - - return std::nullopt; - }; - } - - CesiumRasterOverlays::VectorDocumentRasterOverlayOptions vectorOptions{ - this->DefaultStyle.toNative(), - callbackOpt, - std::move(projection), - options.ellipsoid, - this->MipLevels}; - - if (this->Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon) { - if (!IsValid(this->CesiumIonServer)) { - this->CesiumIonServer = UCesiumIonServer::GetServerForNewObjects(); - } - - return std::make_unique( - TCHAR_TO_UTF8(*this->MaterialLayerKey), - CesiumRasterOverlays::IonVectorDocumentRasterOverlaySource{ - this->IonAssetID, - TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), - TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)}, - vectorOptions, - options); - } - - return std::make_unique( - TCHAR_TO_UTF8(*this->MaterialLayerKey), - this->VectorDocument.GetDocument(), - vectorOptions, - options); -} diff --git a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp index 0a34fc0e2..a639c80bf 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -1,9 +1,11 @@ #include "CesiumVectorStyle.h" +#include "CesiumUtility/Color.h" + CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { return CesiumVectorData::VectorStyle{ CesiumVectorData::LineStyle{ - CesiumVectorData::Color{ + CesiumUtility::Color{ this->LineStyle.Color.R, this->LineStyle.Color.G, this->LineStyle.Color.B, @@ -12,7 +14,7 @@ CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { this->LineStyle.Width, (CesiumVectorData::LineWidthMode)this->LineStyle.WidthMode}, CesiumVectorData::PolygonStyle{ - CesiumVectorData::Color{ + CesiumUtility::Color{ this->PolygonStyle.Color.R, this->PolygonStyle.Color.G, this->PolygonStyle.Color.B, diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h index e1e78518c..e1a944ba0 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h @@ -35,18 +35,15 @@ struct FCesiumGeoJsonDocument { std::shared_ptr&& document); /** - * @brief Checks if this FCesiumVectorDocument is valid (document is not + * @brief Checks if this FCesiumGeoJsonDocument is valid (document is not * nullptr). */ - bool IsValid() const { return this->_document != nullptr; } + bool IsValid() const; /** - * @brief Returns the `CesiumVectorData::VectorDocument` this wraps. + * @brief Returns the `CesiumVectorData::GeoJsonDocument` this wraps. */ - const CesiumUtility::IntrusivePointer& - GetDocument() const { - return this->_document; - } + const std::shared_ptr& GetDocument() const; private: std::shared_ptr _pDocument; diff --git a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h similarity index 50% rename from Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h rename to Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h index 31243bdff..0d75455b3 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h @@ -9,13 +9,13 @@ #include "Components/ActorComponent.h" #include "CoreMinimal.h" #include "Delegates/Delegate.h" -#include "CesiumVectorDocumentRasterOverlay.generated.h" +#include "CesiumGeoJsonDocumentRasterOverlay.generated.h" /** * The projection used by a CesiumVectorDocumentRasterOverlay. */ UENUM(BlueprintType) -enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { +enum class ECesiumGeoJsonDocumentRasterOverlayProjection : uint8 { /** * The raster overlay is projected using Web Mercator. */ @@ -32,20 +32,24 @@ enum class ECesiumVectorDocumentRasterOverlayProjection : uint8 { * data from. */ UENUM(BlueprintType) -enum class ECesiumVectorDocumentRasterOverlaySource : uint8 { +enum class ECesiumGeoJsonDocumentRasterOverlaySource : uint8 { /** - * The raster overlay will display the provided VectorDocument. + * The raster overlay will display the provided GeoJsonDocument. */ FromDocument = 0, /** - * The raster overlay will load the VectorDocument from Cesium ion. + * The raster overlay will load a GeoJsonDocument from Cesium ion. */ - FromCesiumIon = 1 + FromCesiumIon = 1, + /** + * The raster overlay will load a GeoJsonDocument from a URL. + */ + FromUrl = 2 }; DECLARE_DYNAMIC_DELEGATE_RetVal_TwoParams( bool, - FCesiumVectorDocumentRasterOverlayStyleCallback, + FCesiumGeoJsonDocumentRasterOverlayStyleCallback, FCesiumGeoJsonObject, InObject, FCesiumVectorStyle&, @@ -56,7 +60,7 @@ UCLASS( BlueprintType, Blueprintable, meta = (BlueprintSpawnableComponent)) -class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay +class CESIUMRUNTIME_API UCesiumGeoJsonDocumentRasterOverlay : public UCesiumRasterOverlay { GENERATED_BODY() @@ -67,12 +71,12 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay * Mercator. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorDocumentRasterOverlayProjection Projection = - ECesiumVectorDocumentRasterOverlayProjection::WebMercator; + ECesiumGeoJsonDocumentRasterOverlayProjection Projection = + ECesiumGeoJsonDocumentRasterOverlayProjection::WebMercator; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumVectorDocumentRasterOverlaySource Source = - ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon; + ECesiumGeoJsonDocumentRasterOverlaySource Source = + ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon; /** * The ID of the Cesium ion asset to use. @@ -83,7 +87,7 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay Category = "Cesium", meta = (EditCondition = - "Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon")) int64 IonAssetID; /** @@ -96,18 +100,52 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay AdvancedDisplay, meta = (EditCondition = - "Source == ECesiumVectorDocumentRasterOverlaySource::FromCesiumIon")) + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon")) UCesiumIonServer* CesiumIonServer; + /** + * A FCesiumGeoJsonDocument to display. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = + (EditCondition = + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromDocument")) + FCesiumGeoJsonDocument GeoJsonDocument; + + /** + * A URL to load a GeoJSON document from. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = + (EditCondition = + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromUrl")) + FString Url; + + /** + * Headers to use while making a request to `Url` to load a GeoJSON document. + */ UPROPERTY( EditAnywhere, BlueprintReadWrite, Category = "Cesium", meta = (EditCondition = - "Source == ECesiumVectorDocumentRasterOverlaySource::FromDocument")) - FCesiumGeoJsonDocument VectorDocument; + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromUrl")) + TMap RequestHeaders; + /** + * The number of mip levels to generate for each tile of this raster overlay. + * + * Additional mip levels can improve the visual quality of tiles farther from + * the camera at the cost of additional rasterization time to create each mip + * level. + */ UPROPERTY( EditAnywhere, BlueprintReadWrite, @@ -115,11 +153,21 @@ class CESIUMRUNTIME_API UCesiumVectorDocumentRasterOverlay meta = (ClampMin = "0", ClampMax = "8")) int32 MipLevels = 0; + /** + * The default style to use for this raster overlay. + * + * If no style is set on a GeoJSON object or any of its parents, this style + * will be used instead. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") FCesiumVectorStyle DefaultStyle; + /** + * A callback that will be called to set the styles of each object in the + * loaded document. + */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FCesiumVectorDocumentRasterOverlayStyleCallback StyleCallback; + FCesiumGeoJsonDocumentRasterOverlayStyleCallback StyleCallback; protected: virtual std::unique_ptr CreateOverlay( diff --git a/extern/cesium-native b/extern/cesium-native index 4220ead21..5575109d6 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 4220ead21b4ea43dea2923f8210cd69eaadde4f1 +Subproject commit 5575109d6f86c532e13dfd993725d60739e75cf0 From ffc975f1ca2de50ce9722f781eefb60d62435c53 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 12 Jun 2025 11:28:30 -0400 Subject: [PATCH 11/36] Add overlay to disable JIT on iOS --- extern/vcpkg-overlays/blend2d/portfile.cmake | 51 ++++++++++++++++++++ extern/vcpkg-overlays/blend2d/usage.txt | 4 ++ extern/vcpkg-overlays/blend2d/vcpkg.json | 34 +++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 extern/vcpkg-overlays/blend2d/portfile.cmake create mode 100644 extern/vcpkg-overlays/blend2d/usage.txt create mode 100644 extern/vcpkg-overlays/blend2d/vcpkg.json diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake new file mode 100644 index 000000000..028609644 --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -0,0 +1,51 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO blend2d/blend2d + REF d2027ebfd6aaf53b190b6b3b497425fc85f14251 # commited on 2025-03-08 + SHA512 f7ecda8280290a1692bbec618522eccf1d74f79c688affc687848459c06762e405ad2f319845a548d478723ed8bf8db609e4691bc335f364baceb20d9d3aa597 + HEAD_REF master +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BLEND2D_STATIC) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + jit BLEND2D_NO_JIT +) + +# iOS will not allow us to use JIT, so we need to disable it in Blend2D. +# Once we're using manifest mode for Unreal, we can get rid of this overlay port and use the above feature. +if(IOS) + set(IOS_DISABLE_JIT "-DBLEND2D_NO_JIT") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DBLEND2D_STATIC=${BLEND2D_STATIC}" + "-DBLEND2D_NO_FUTEX=OFF" + "-DBLEND2D_EXTERNAL_ASMJIT=ON" + ${IOS_DISABLE_JIT} + ${FEATURE_OPTIONS} +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d/api.h" + "#if !defined(BL_STATIC)" + "#if 0" + ) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d-debug.h" + "#if defined(BL_STATIC)" + "#if 1" + ) +endif() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/extern/vcpkg-overlays/blend2d/usage.txt b/extern/vcpkg-overlays/blend2d/usage.txt new file mode 100644 index 000000000..e5adf17e4 --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/usage.txt @@ -0,0 +1,4 @@ +blend2d provides CMake targets: + + find_package(blend2d CONFIG REQUIRED) + target_link_libraries(main PRIVATE blend2d::blend2d) diff --git a/extern/vcpkg-overlays/blend2d/vcpkg.json b/extern/vcpkg-overlays/blend2d/vcpkg.json new file mode 100644 index 000000000..e9f9f7cc3 --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/vcpkg.json @@ -0,0 +1,34 @@ +{ + "name": "blend2d", + "version-date": "2025-03-08", + "description": "2D Vector Graphics Engine Powered by a JIT Compiler", + "homepage": "https://github.com/blend2d/blend2d", + "documentation": "https://blend2d.com/doc/index.html", + "license": "Zlib", + "supports": "!wasm32", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "jit", + "platform": "!arm32" + } + ], + "features": { + "jit": { + "description": "Enables JIT compiler to generate optimized pipelines.", + "supports": "!arm32", + "dependencies": [ + "asmjit" + ] + } + } +} From 35347f92552ab5a82c87704ffbfcf52730e60443 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 12 Jun 2025 12:07:23 -0400 Subject: [PATCH 12/36] Fix portfile --- extern/cesium-native | 2 +- extern/vcpkg-overlays/blend2d/portfile.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/cesium-native b/extern/cesium-native index 5575109d6..2c78343d4 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 5575109d6f86c532e13dfd993725d60739e75cf0 +Subproject commit 2c78343d4fc55b66dd90c0a4eb91626b66b8b986 diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake index 028609644..bfb543b71 100644 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -15,7 +15,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS # iOS will not allow us to use JIT, so we need to disable it in Blend2D. # Once we're using manifest mode for Unreal, we can get rid of this overlay port and use the above feature. -if(IOS) +if(VCPKG_TARGET_IS_IOS) set(IOS_DISABLE_JIT "-DBLEND2D_NO_JIT") endif() From efaaae52135ddb8faf85fb5b8d323af356a6da71 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 12 Jun 2025 14:40:00 -0400 Subject: [PATCH 13/36] Fix incorrectly named usage --- extern/cesium-native | 2 +- extern/vcpkg-overlays/blend2d/{usage.txt => usage} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename extern/vcpkg-overlays/blend2d/{usage.txt => usage} (100%) diff --git a/extern/cesium-native b/extern/cesium-native index 2c78343d4..d459cee70 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 2c78343d4fc55b66dd90c0a4eb91626b66b8b986 +Subproject commit d459cee706da9bf3a07ae48317b0ef16521dd758 diff --git a/extern/vcpkg-overlays/blend2d/usage.txt b/extern/vcpkg-overlays/blend2d/usage similarity index 100% rename from extern/vcpkg-overlays/blend2d/usage.txt rename to extern/vcpkg-overlays/blend2d/usage From d413312e671817c2e25e74069e5ece69789138bb Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 13 Jun 2025 11:00:03 -0400 Subject: [PATCH 14/36] Fix CI issue --- .../Private/CesiumVectorStyle.cpp | 24 +++++++++---------- extern/cesium-native | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp index a639c80bf..719cf36cd 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -5,21 +5,21 @@ CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { return CesiumVectorData::VectorStyle{ CesiumVectorData::LineStyle{ - CesiumUtility::Color{ - this->LineStyle.Color.R, - this->LineStyle.Color.G, - this->LineStyle.Color.B, - this->LineStyle.Color.A}, - (CesiumVectorData::ColorMode)this->LineStyle.ColorMode, + {CesiumUtility::Color{ + this->LineStyle.Color.R, + this->LineStyle.Color.G, + this->LineStyle.Color.B, + this->LineStyle.Color.A}, + (CesiumVectorData::ColorMode)this->LineStyle.ColorMode}, this->LineStyle.Width, (CesiumVectorData::LineWidthMode)this->LineStyle.WidthMode}, CesiumVectorData::PolygonStyle{ - CesiumUtility::Color{ - this->PolygonStyle.Color.R, - this->PolygonStyle.Color.G, - this->PolygonStyle.Color.B, - this->PolygonStyle.Color.A}, - (CesiumVectorData::ColorMode)this->PolygonStyle.ColorMode, + {CesiumUtility::Color{ + this->PolygonStyle.Color.R, + this->PolygonStyle.Color.G, + this->PolygonStyle.Color.B, + this->PolygonStyle.Color.A}, + (CesiumVectorData::ColorMode)this->PolygonStyle.ColorMode}, this->PolygonStyle.Fill, this->PolygonStyle.Outline}}; } diff --git a/extern/cesium-native b/extern/cesium-native index d459cee70..771990d4a 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit d459cee706da9bf3a07ae48317b0ef16521dd758 +Subproject commit 771990d4aeb44c67271f484fb329da14d744adad From 0a564398466056d250fc829860fac0ec330a23b5 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 13 Jun 2025 11:44:15 -0400 Subject: [PATCH 15/36] Update cesium-native --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index 771990d4a..b7e70f654 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 771990d4aeb44c67271f484fb329da14d744adad +Subproject commit b7e70f654136d1aa9a31c9ff342595182cc95ae0 From 98fb46b70030b3f0895c0e89eb4a727c36ca05db Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 13 Jun 2025 12:19:10 -0400 Subject: [PATCH 16/36] Update cesium-native --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index b7e70f654..6ad785817 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit b7e70f654136d1aa9a31c9ff342595182cc95ae0 +Subproject commit 6ad785817a474d61a304cbc1df148fb1d3b1f6d6 From 96ce2c822519cd52170206a6d136ba03609ca4ea Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 13 Jun 2025 13:09:44 -0400 Subject: [PATCH 17/36] Set BLEND2D_NO_JIT to ON --- extern/vcpkg-overlays/blend2d/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake index bfb543b71..6787a7552 100644 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -16,7 +16,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS # iOS will not allow us to use JIT, so we need to disable it in Blend2D. # Once we're using manifest mode for Unreal, we can get rid of this overlay port and use the above feature. if(VCPKG_TARGET_IS_IOS) - set(IOS_DISABLE_JIT "-DBLEND2D_NO_JIT") + set(IOS_DISABLE_JIT "-DBLEND2D_NO_JIT=ON") endif() vcpkg_cmake_configure( From 43da958a21507de57e66df963c0c2de92410ad65 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Fri, 13 Jun 2025 16:06:03 -0400 Subject: [PATCH 18/36] Remove overlay port, update cesium-native --- extern/cesium-native | 2 +- extern/vcpkg-overlays/blend2d/portfile.cmake | 51 -------------------- extern/vcpkg-overlays/blend2d/usage | 4 -- extern/vcpkg-overlays/blend2d/vcpkg.json | 34 ------------- 4 files changed, 1 insertion(+), 90 deletions(-) delete mode 100644 extern/vcpkg-overlays/blend2d/portfile.cmake delete mode 100644 extern/vcpkg-overlays/blend2d/usage delete mode 100644 extern/vcpkg-overlays/blend2d/vcpkg.json diff --git a/extern/cesium-native b/extern/cesium-native index 6ad785817..1fabf5b1b 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 6ad785817a474d61a304cbc1df148fb1d3b1f6d6 +Subproject commit 1fabf5b1bdc368d2c64ef5f91e7b03f858ccfc08 diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake deleted file mode 100644 index 6787a7552..000000000 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ /dev/null @@ -1,51 +0,0 @@ -vcpkg_from_github( - OUT_SOURCE_PATH SOURCE_PATH - REPO blend2d/blend2d - REF d2027ebfd6aaf53b190b6b3b497425fc85f14251 # commited on 2025-03-08 - SHA512 f7ecda8280290a1692bbec618522eccf1d74f79c688affc687848459c06762e405ad2f319845a548d478723ed8bf8db609e4691bc335f364baceb20d9d3aa597 - HEAD_REF master -) - -string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BLEND2D_STATIC) - -vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS - INVERTED_FEATURES - jit BLEND2D_NO_JIT -) - -# iOS will not allow us to use JIT, so we need to disable it in Blend2D. -# Once we're using manifest mode for Unreal, we can get rid of this overlay port and use the above feature. -if(VCPKG_TARGET_IS_IOS) - set(IOS_DISABLE_JIT "-DBLEND2D_NO_JIT=ON") -endif() - -vcpkg_cmake_configure( - SOURCE_PATH "${SOURCE_PATH}" - OPTIONS - "-DBLEND2D_STATIC=${BLEND2D_STATIC}" - "-DBLEND2D_NO_FUTEX=OFF" - "-DBLEND2D_EXTERNAL_ASMJIT=ON" - ${IOS_DISABLE_JIT} - ${FEATURE_OPTIONS} -) - -vcpkg_cmake_install() -vcpkg_copy_pdbs() - -vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") - -file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") - -if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d/api.h" - "#if !defined(BL_STATIC)" - "#if 0" - ) - vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d-debug.h" - "#if defined(BL_STATIC)" - "#if 1" - ) -endif() - -file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") -vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/extern/vcpkg-overlays/blend2d/usage b/extern/vcpkg-overlays/blend2d/usage deleted file mode 100644 index e5adf17e4..000000000 --- a/extern/vcpkg-overlays/blend2d/usage +++ /dev/null @@ -1,4 +0,0 @@ -blend2d provides CMake targets: - - find_package(blend2d CONFIG REQUIRED) - target_link_libraries(main PRIVATE blend2d::blend2d) diff --git a/extern/vcpkg-overlays/blend2d/vcpkg.json b/extern/vcpkg-overlays/blend2d/vcpkg.json deleted file mode 100644 index e9f9f7cc3..000000000 --- a/extern/vcpkg-overlays/blend2d/vcpkg.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "blend2d", - "version-date": "2025-03-08", - "description": "2D Vector Graphics Engine Powered by a JIT Compiler", - "homepage": "https://github.com/blend2d/blend2d", - "documentation": "https://blend2d.com/doc/index.html", - "license": "Zlib", - "supports": "!wasm32", - "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } - ], - "default-features": [ - { - "name": "jit", - "platform": "!arm32" - } - ], - "features": { - "jit": { - "description": "Enables JIT compiler to generate optimized pipelines.", - "supports": "!arm32", - "dependencies": [ - "asmjit" - ] - } - } -} From e93154e4cad7fc6aa6a481e23ced57548c3731fb Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 12:04:36 -0400 Subject: [PATCH 19/36] Bring up to date with vector-rasterizer --- .../CesiumGeoJsonDocumentRasterOverlay.cpp | 79 ++++++++++----- .../Private/CesiumVectorStyle.cpp | 99 ++++++++++++++----- .../CesiumGeoJsonDocumentRasterOverlay.h | 16 ++- .../CesiumRuntime/Public/CesiumVectorStyle.h | 41 ++++++-- extern/cesium-native | 2 +- 5 files changed, 168 insertions(+), 69 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp index 10578ec13..77f776cd8 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -11,6 +11,38 @@ #include "CesiumRuntime.h" +namespace { +CesiumAsync::Future> +wrapLoaderFuture( + UCesiumGeoJsonDocumentRasterOverlay* pThis, + CesiumAsync::Future< + CesiumUtility::Result>&& future) { + return std::move(future).thenInMainThread( + [pThis](CesiumUtility::Result&& + documentResult) + -> std::shared_ptr { + if (!documentResult.errors) { + documentResult.errors.logError( + spdlog::default_logger(), + "Errors loading GeoJSON document: "); + return nullptr; + } + + std::shared_ptr pGeoJsonDocument = + std::make_shared( + std::move(*documentResult.value)); + + /*if (pThis->OnDocumentLoaded.IsBound()) { + pThis->OnDocumentLoaded.Execute(FCesiumGeoJsonDocument( + std::shared_ptr( + pGeoJsonDocument))); + }*/ + + return std::move(pGeoJsonDocument); + }); +} +} // namespace + std::unique_ptr UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( const CesiumRasterOverlays::RasterOverlayOptions& options) { @@ -28,27 +60,8 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); } - std::optional - callbackOpt = std::nullopt; - - if (this->StyleCallback.IsBound()) { - callbackOpt = - [Callback = this->StyleCallback]( - const std::shared_ptr& doc, - const CesiumVectorData::GeoJsonObject* pNode) - -> std::optional { - FCesiumVectorStyle style; - if (Callback.Execute(FCesiumGeoJsonObject(doc, pNode), style)) { - return style.toNative(); - } - - return std::nullopt; - }; - } - CesiumRasterOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{ this->DefaultStyle.toNative(), - callbackOpt, std::move(projection), options.ellipsoid, this->MipLevels}; @@ -61,10 +74,15 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( return std::make_unique( TCHAR_TO_UTF8(*this->MaterialLayerKey), - CesiumRasterOverlays::IonGeoJsonDocumentRasterOverlaySource{ - this->IonAssetID, - TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), - TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)}, + wrapLoaderFuture( + this, + CesiumVectorData::GeoJsonDocument::fromCesiumIonAsset( + getAsyncSystem(), + getAssetAccessor(), + this->IonAssetID, + TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken), + std::string(TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)) + + "/")), vectorOptions, options); } else if ( @@ -78,14 +96,23 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( return std::make_unique( TCHAR_TO_UTF8(*this->MaterialLayerKey), - CesiumRasterOverlays::UrlGeoJsonDocumentRasterOverlaySource{ - TCHAR_TO_UTF8(*this->Url), - std::move(headers)}, + wrapLoaderFuture( + this, + CesiumVectorData::GeoJsonDocument::fromUrl( + getAsyncSystem(), + getAssetAccessor(), + TCHAR_TO_UTF8(*this->Url), + std::move(headers))), vectorOptions, options); } + if (this->OnDocumentLoaded.IsBound()) { + this->OnDocumentLoaded.Execute(this->GeoJsonDocument); + } + return std::make_unique( + getAsyncSystem(), TCHAR_TO_UTF8(*this->MaterialLayerKey), this->GeoJsonDocument.GetDocument(), vectorOptions, diff --git a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp index 719cf36cd..ed9f03539 100644 --- a/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -2,30 +2,83 @@ #include "CesiumUtility/Color.h" +namespace { +CesiumVectorData::LineStyle +lineStyleToNative(const FCesiumVectorLineStyle& InLineStyle) { + return CesiumVectorData::LineStyle{ + {CesiumUtility::Color{ + InLineStyle.Color.R, + InLineStyle.Color.G, + InLineStyle.Color.B, + InLineStyle.Color.A}, + (CesiumVectorData::ColorMode)InLineStyle.ColorMode}, + InLineStyle.Width, + (CesiumVectorData::LineWidthMode)InLineStyle.WidthMode}; +} +} // namespace + CesiumVectorData::VectorStyle FCesiumVectorStyle::toNative() const { + // Assert that enums are equivalent to catch any issues. + static_assert( + (uint8)CesiumVectorData::ColorMode::Normal == + (uint8)ECesiumVectorColorMode::Normal); + static_assert( + (uint8)CesiumVectorData::ColorMode::Random == + (uint8)ECesiumVectorColorMode::Random); + static_assert( + (uint8)CesiumVectorData::LineWidthMode::Meters == + (uint8)ECesiumVectorLineWidthMode::Meters); + static_assert( + (uint8)CesiumVectorData::LineWidthMode::Pixels == + (uint8)ECesiumVectorLineWidthMode::Pixels); + + std::optional fillStyle; + if (this->PolygonStyle.Fill) { + fillStyle = CesiumVectorData::ColorStyle{ + CesiumUtility::Color{ + this->PolygonStyle.FillStyle.Color.R, + this->PolygonStyle.FillStyle.Color.G, + this->PolygonStyle.FillStyle.Color.B, + this->PolygonStyle.FillStyle.Color.A}, + (CesiumVectorData::ColorMode)this->LineStyle.ColorMode}; + } + return CesiumVectorData::VectorStyle{ - CesiumVectorData::LineStyle{ - {CesiumUtility::Color{ - this->LineStyle.Color.R, - this->LineStyle.Color.G, - this->LineStyle.Color.B, - this->LineStyle.Color.A}, - (CesiumVectorData::ColorMode)this->LineStyle.ColorMode}, - this->LineStyle.Width, - (CesiumVectorData::LineWidthMode)this->LineStyle.WidthMode}, + lineStyleToNative(this->LineStyle), CesiumVectorData::PolygonStyle{ - {CesiumUtility::Color{ - this->PolygonStyle.Color.R, - this->PolygonStyle.Color.G, - this->PolygonStyle.Color.B, - this->PolygonStyle.Color.A}, - (CesiumVectorData::ColorMode)this->PolygonStyle.ColorMode}, - this->PolygonStyle.Fill, - this->PolygonStyle.Outline}}; + fillStyle, + this->PolygonStyle.Outline + ? std::optional( + lineStyleToNative(this->PolygonStyle.OutlineStyle)) + : std::nullopt}}; } FCesiumVectorStyle FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) { + FCesiumVectorLineStyle OutlineStyle; + if (style.polygon.outline) { + OutlineStyle = FCesiumVectorLineStyle{ + FColor( + (uint8)style.polygon.outline->color.r, + (uint8)style.polygon.outline->color.g, + (uint8)style.polygon.outline->color.b, + (uint8)style.polygon.outline->color.a), + (ECesiumVectorColorMode)style.polygon.outline->colorMode, + style.polygon.outline->width, + (ECesiumVectorLineWidthMode)style.polygon.outline->widthMode}; + } + + FCesiumVectorPolygonFillStyle FillStyle; + if (style.polygon.fill) { + FillStyle = FCesiumVectorPolygonFillStyle{ + FColor( + (uint8)style.polygon.fill->color.r, + (uint8)style.polygon.fill->color.g, + (uint8)style.polygon.fill->color.b, + (uint8)style.polygon.fill->color.a), + (ECesiumVectorColorMode)style.polygon.fill->colorMode}; + } + return FCesiumVectorStyle{ FCesiumVectorLineStyle{ FColor( @@ -37,12 +90,8 @@ FCesiumVectorStyle::fromNative(const CesiumVectorData::VectorStyle& style) { style.line.width, (ECesiumVectorLineWidthMode)style.line.widthMode}, FCesiumVectorPolygonStyle{ - FColor( - (uint8)style.polygon.color.r, - (uint8)style.polygon.color.g, - (uint8)style.polygon.color.b, - (uint8)style.polygon.color.a), - (ECesiumVectorColorMode)style.polygon.colorMode, - style.polygon.fill, - style.polygon.outline}}; + style.polygon.fill.has_value(), + FillStyle, + style.polygon.outline.has_value(), + OutlineStyle}}; } diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h index 0d75455b3..0827db809 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h @@ -47,13 +47,10 @@ enum class ECesiumGeoJsonDocumentRasterOverlaySource : uint8 { FromUrl = 2 }; -DECLARE_DYNAMIC_DELEGATE_RetVal_TwoParams( - bool, - FCesiumGeoJsonDocumentRasterOverlayStyleCallback, - FCesiumGeoJsonObject, - InObject, - FCesiumVectorStyle&, - OutStyle); +DECLARE_DYNAMIC_DELEGATE_OneParam( + FCesiumGeoJsonDocumentRasterOverlayOnDocumentLoadedCallback, + FCesiumGeoJsonDocument, + InDocument); UCLASS( ClassGroup = Cesium, @@ -163,11 +160,10 @@ class CESIUMRUNTIME_API UCesiumGeoJsonDocumentRasterOverlay FCesiumVectorStyle DefaultStyle; /** - * A callback that will be called to set the styles of each object in the - * loaded document. + * A callback that will be called when the document has been loaded. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FCesiumGeoJsonDocumentRasterOverlayStyleCallback StyleCallback; + FCesiumGeoJsonDocumentRasterOverlayOnDocumentLoadedCallback OnDocumentLoaded; protected: virtual std::unique_ptr CreateOverlay( diff --git a/Source/CesiumRuntime/Public/CesiumVectorStyle.h b/Source/CesiumRuntime/Public/CesiumVectorStyle.h index 0d0f235ae..e09992a39 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorStyle.h +++ b/Source/CesiumRuntime/Public/CesiumVectorStyle.h @@ -77,10 +77,10 @@ struct FCesiumVectorLineStyle { }; /** - * The style used to draw polygons. + * The style used to fill polygons. */ USTRUCT(BlueprintType) -struct FCesiumVectorPolygonStyle { +struct FCesiumVectorPolygonFillStyle { GENERATED_BODY() /** @@ -93,19 +93,46 @@ struct FCesiumVectorPolygonStyle { */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") ECesiumVectorColorMode ColorMode = ECesiumVectorColorMode::Normal; +}; + +/** + * The style used to draw polygons. + */ +USTRUCT(BlueprintType) +struct FCesiumVectorPolygonStyle { + GENERATED_BODY() + /** - * Whether the polygon should be filled. The `ColorStyle` specified - * here will be used for the fill color. + * Whether the polygon should be filled. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") bool Fill = true; + + /** + * If `Fill` is true, this style will be used when filling the polygon. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = (EditCondition = "Fill")) + FCesiumVectorPolygonFillStyle FillStyle; + /** - * Whether the polygon should be outlined. The `LineStyle` specified on - * the same `FCesiumVectorDocumentRasterOverlayStyle` as this will be used for - * the stroke color. + * Whether the polygon should be outlined. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") bool Outline = false; + + /** + * If `Outline` is true, this style will be used when outlining the polygon. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = (EditCondition = "Outline")) + FCesiumVectorLineStyle OutlineStyle; }; /** diff --git a/extern/cesium-native b/extern/cesium-native index 1fabf5b1b..9a3eed6af 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 1fabf5b1bdc368d2c64ef5f91e7b03f858ccfc08 +Subproject commit 9a3eed6afd9b3d7a40a1d49813f4bc5c5e325214 From 1596f6767ccac8761978307349edcb0f51db8c46 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 13:23:37 -0400 Subject: [PATCH 20/36] Remove std::move --- .../Private/CesiumGeoJsonDocumentRasterOverlay.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp index 77f776cd8..68bc2fe7e 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -32,13 +32,13 @@ wrapLoaderFuture( std::make_shared( std::move(*documentResult.value)); - /*if (pThis->OnDocumentLoaded.IsBound()) { + if (pThis->OnDocumentLoaded.IsBound()) { pThis->OnDocumentLoaded.Execute(FCesiumGeoJsonDocument( std::shared_ptr( pGeoJsonDocument))); - }*/ + } - return std::move(pGeoJsonDocument); + return pGeoJsonDocument; }); } } // namespace From 4630fc6c69bf0468c4c540d4a58c36253afb505f Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 13:27:52 -0400 Subject: [PATCH 21/36] Re-add overlay port --- extern/vcpkg-overlays/blend2d/portfile.cmake | 50 ++++++++++++++++++++ extern/vcpkg-overlays/blend2d/usage | 4 ++ extern/vcpkg-overlays/blend2d/vcpkg.json | 34 +++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 extern/vcpkg-overlays/blend2d/portfile.cmake create mode 100644 extern/vcpkg-overlays/blend2d/usage create mode 100644 extern/vcpkg-overlays/blend2d/vcpkg.json diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake new file mode 100644 index 000000000..f9afa2fda --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -0,0 +1,50 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO blend2d/blend2d + REF d2027ebfd6aaf53b190b6b3b497425fc85f14251 # commited on 2025-03-08 + SHA512 f7ecda8280290a1692bbec618522eccf1d74f79c688affc687848459c06762e405ad2f319845a548d478723ed8bf8db609e4691bc335f364baceb20d9d3aa597 + HEAD_REF master +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BLEND2D_STATIC) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + INVERTED_FEATURES + jit BLEND2D_NO_JIT +) + +if(BLEND2D_NO_JIT) + set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=OFF") +else() + set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=ON") +endif() + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + "-DBLEND2D_STATIC=${BLEND2D_STATIC}" + "-DBLEND2D_NO_FUTEX=OFF" + ${BLEND2D_NO_JIT} + ${FEATURE_OPTIONS} +) + +vcpkg_cmake_install() +vcpkg_copy_pdbs() + +vcpkg_cmake_config_fixup(CONFIG_PATH "lib/cmake/${PORT}") + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "static") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d/api.h" + "#if !defined(BL_STATIC)" + "#if 0" + ) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/blend2d-debug.h" + "#if defined(BL_STATIC)" + "#if 1" + ) +endif() + +file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}") +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.md") diff --git a/extern/vcpkg-overlays/blend2d/usage b/extern/vcpkg-overlays/blend2d/usage new file mode 100644 index 000000000..e5adf17e4 --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/usage @@ -0,0 +1,4 @@ +blend2d provides CMake targets: + + find_package(blend2d CONFIG REQUIRED) + target_link_libraries(main PRIVATE blend2d::blend2d) diff --git a/extern/vcpkg-overlays/blend2d/vcpkg.json b/extern/vcpkg-overlays/blend2d/vcpkg.json new file mode 100644 index 000000000..e9f9f7cc3 --- /dev/null +++ b/extern/vcpkg-overlays/blend2d/vcpkg.json @@ -0,0 +1,34 @@ +{ + "name": "blend2d", + "version-date": "2025-03-08", + "description": "2D Vector Graphics Engine Powered by a JIT Compiler", + "homepage": "https://github.com/blend2d/blend2d", + "documentation": "https://blend2d.com/doc/index.html", + "license": "Zlib", + "supports": "!wasm32", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "default-features": [ + { + "name": "jit", + "platform": "!arm32" + } + ], + "features": { + "jit": { + "description": "Enables JIT compiler to generate optimized pipelines.", + "supports": "!arm32", + "dependencies": [ + "asmjit" + ] + } + } +} From 53b62a26b3b141673db011ef29a15aee1b3cfd91 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 14:24:01 -0400 Subject: [PATCH 22/36] Fix portfile --- extern/vcpkg-overlays/blend2d/portfile.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake index f9afa2fda..502f99997 100644 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -13,7 +13,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS jit BLEND2D_NO_JIT ) -if(BLEND2D_NO_JIT) +if(BLEND2D_NO_JIT MATCHES "ON") set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=OFF") else() set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=ON") From ecccf91915f0e28464c96c3ff86fe1014b802cad Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 14:46:41 -0400 Subject: [PATCH 23/36] Fix portfile again --- extern/cesium-native | 2 +- extern/vcpkg-overlays/blend2d/portfile.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/cesium-native b/extern/cesium-native index 9a3eed6af..0e9b5be50 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 9a3eed6afd9b3d7a40a1d49813f4bc5c5e325214 +Subproject commit 0e9b5be5045bb08bc8855b0f41d3f58361ad20fb diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake index 502f99997..10b9fed26 100644 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -13,7 +13,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS jit BLEND2D_NO_JIT ) -if(BLEND2D_NO_JIT MATCHES "ON") +if(NOT BLEND2D_NO_JIT) set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=OFF") else() set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=ON") From b9bd5a5d410c4895af6820720ce87a3de9c88bd5 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 15:49:13 -0400 Subject: [PATCH 24/36] Give that portfile another go --- extern/vcpkg-overlays/blend2d/portfile.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake index 10b9fed26..74521c956 100644 --- a/extern/vcpkg-overlays/blend2d/portfile.cmake +++ b/extern/vcpkg-overlays/blend2d/portfile.cmake @@ -13,7 +13,7 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS jit BLEND2D_NO_JIT ) -if(NOT BLEND2D_NO_JIT) +if(BLEND2D_NO_JIT) set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=OFF") else() set(BLEND2D_EXTERNAL_ASMJIT_D "-DBLEND2D_EXTERNAL_ASMJIT=ON") @@ -24,7 +24,7 @@ vcpkg_cmake_configure( OPTIONS "-DBLEND2D_STATIC=${BLEND2D_STATIC}" "-DBLEND2D_NO_FUTEX=OFF" - ${BLEND2D_NO_JIT} + ${BLEND2D_EXTERNAL_ASMJIT_D} ${FEATURE_OPTIONS} ) From d0140d4444bb649283601898a0c3a3b74143b30f Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 17:16:08 -0400 Subject: [PATCH 25/36] Exclude curl from build --- extern/CMakeLists.txt | 2 ++ extern/cesium-native | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index e33615bcc..2e96a0ac6 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -124,6 +124,8 @@ endif() # Our OpenSSL is part of Unreal Engine, so need to install it. set(CESIUM_EXCLUDE_INSTALL_HEADERS openssl) set(CESIUM_EXCLUDE_INSTALL_STATIC_LIBS openssl) +# Skip including curl asset accessor as it causes issues on Android and iOS +set(CESIUM_DISABLE_CesiumCurl TRUE) add_subdirectory(cesium-native) diff --git a/extern/cesium-native b/extern/cesium-native index 0e9b5be50..2dcc22339 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 0e9b5be5045bb08bc8855b0f41d3f58361ad20fb +Subproject commit 2dcc22339b16bc5a4259495e65f6cbc44294de3a From 058283f4df2f1709ee7052358007a6483e2e94bb Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Tue, 17 Jun 2025 17:33:12 -0400 Subject: [PATCH 26/36] Update cesium-native --- extern/CMakeLists.txt | 2 +- extern/cesium-native | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 2e96a0ac6..790dfce05 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -125,7 +125,7 @@ endif() set(CESIUM_EXCLUDE_INSTALL_HEADERS openssl) set(CESIUM_EXCLUDE_INSTALL_STATIC_LIBS openssl) # Skip including curl asset accessor as it causes issues on Android and iOS -set(CESIUM_DISABLE_CesiumCurl TRUE) +set(CESIUM_DISABLE_CURL TRUE) add_subdirectory(cesium-native) diff --git a/extern/cesium-native b/extern/cesium-native index 2dcc22339..58329b5d3 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 2dcc22339b16bc5a4259495e65f6cbc44294de3a +Subproject commit 58329b5d3bd92865e2f61fdd596d90544ffd084b From d5d68a362af45ec4108bb7830c379845f2342107 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 18 Jun 2025 23:58:29 +1000 Subject: [PATCH 27/36] Fix inverted logic. --- .../Private/CesiumGeoJsonDocumentRasterOverlay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp index 68bc2fe7e..6cae3c823 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -21,7 +21,7 @@ wrapLoaderFuture( [pThis](CesiumUtility::Result&& documentResult) -> std::shared_ptr { - if (!documentResult.errors) { + if (documentResult.errors) { documentResult.errors.logError( spdlog::default_logger(), "Errors loading GeoJSON document: "); From e38019724e4e11d069301d43eadba2d85f555ba6 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Wed, 18 Jun 2025 14:08:11 -0400 Subject: [PATCH 28/36] Update cesium-native --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index 58329b5d3..39f987d25 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 58329b5d3bd92865e2f61fdd596d90544ffd084b +Subproject commit 39f987d250fed38853b14f8f5c152afbb1a93d66 From 1be940f599b4270dcfb3ee0e310fbc7aef319c22 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Wed, 18 Jun 2025 15:02:19 -0400 Subject: [PATCH 29/36] Add functions for modifying style --- .../Private/CesiumGeoJsonObject.cpp | 35 +++++++++++++++++++ .../Public/CesiumGeoJsonObject.h | 32 +++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp index 72d187f93..116c48eaa 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp @@ -451,6 +451,41 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeatureCollection( return Features; } +FCesiumVectorStyle UCesiumGeoJsonObjectBlueprintLibrary::GetStyle( + const FCesiumGeoJsonObject& InObject, + EHasValue& Branches) { + if (!InObject._pDocument || !InObject._pObject) { + Branches = EHasValue::NoValue; + return FCesiumVectorStyle(); + } + + const std::optional style = + InObject._pObject->getStyle(); + Branches = style ? EHasValue::HasValue : EHasValue::NoValue; + return style ? FCesiumVectorStyle::fromNative(*style) : FCesiumVectorStyle(); +} + +void UCesiumGeoJsonObjectBlueprintLibrary::SetStyle( + UPARAM(Ref) FCesiumGeoJsonObject& InObject, + const FCesiumVectorStyle& InStyle) { + if (!InObject._pDocument || !InObject._pObject) { + return; + } + + const_cast(InObject._pObject)->getStyle() = + InStyle.toNative(); +} + +void UCesiumGeoJsonObjectBlueprintLibrary::ClearStyle( + UPARAM(Ref) FCesiumGeoJsonObject& InObject) { + if (!InObject._pDocument || !InObject._pObject) { + return; + } + + const_cast(InObject._pObject)->getStyle() = + std::nullopt; +} + FCesiumGeoJsonLineString::FCesiumGeoJsonLineString(TArray&& InPoints) : Points(MoveTemp(InPoints)) {} diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h b/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h index 4954d8359..3dc8f7745 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonObject.h @@ -5,6 +5,7 @@ #include "CesiumUtility/IntrusivePointer.h" #include "CesiumVectorData/GeoJsonDocument.h" #include "CesiumVectorData/GeoJsonObject.h" +#include "CesiumVectorStyle.h" #include "JsonObjectWrapper.h" #include "Kismet/BlueprintFunctionLibrary.h" #include "Templates/SharedPointer.h" @@ -381,4 +382,35 @@ class UCesiumGeoJsonObjectBlueprintLibrary : public UBlueprintFunctionLibrary { UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object") static TArray GetObjectAsFeatureCollection(const FCesiumGeoJsonObject& InObject); + + /** + * @brief Returns the `FCesiumVectorStyle` attached to this object, if any. If + * there is no style attached to this object, the `No Value` branch is taken. + */ + UFUNCTION( + BlueprintCallable, + BlueprintPure, + Category = "Cesium|Vector|Object", + Meta = (ExpandEnumAsExecs = "Branches")) + static FCesiumVectorStyle + GetStyle(const FCesiumGeoJsonObject& InObject, EHasValue& Branches); + + /** + * @brief Sets the style of the given `FCesiumGeoJsonObject`. + */ + UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Object") + static void SetStyle( + UPARAM(Ref) FCesiumGeoJsonObject& InObject, + const FCesiumVectorStyle& InStyle); + + /** + * @brief Removes any existing style on the given GeoJSON object. + * + * GeoJSON objects without a style specified will inherit their style from + * their parent object, or that parent's parent, and so on up the tree. If no + * styles are found anywhere in the ancestors of this object, the default + * style will be used. + */ + UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Object") + static void ClearStyle(UPARAM(Ref) FCesiumGeoJsonObject& InObject); }; From a6c3062b4070b26a889da36796a2c2ead41f6e1a Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 26 Jun 2025 11:51:35 -0400 Subject: [PATCH 30/36] Update cesium-native --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index 39f987d25..a46d0687b 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit 39f987d250fed38853b14f8f5c152afbb1a93d66 +Subproject commit a46d0687ba596a3af7c3c8494213fea09c701ed9 From 06593d96308975a17a5f86334e1be41dcb6fc429 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 30 Jul 2025 18:55:51 +1000 Subject: [PATCH 31/36] Update cesium-native. --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index fef0fadc2..cf473b1ce 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit fef0fadc265ba6263d72ca6a353a688627770d83 +Subproject commit cf473b1ce07e8271a9343510e471700fd46fa08b From 175a92a5b5ae91babf7a71a4644855595dcf7092 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 30 Jul 2025 19:50:46 +1000 Subject: [PATCH 32/36] Update cesium-native. --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index cf473b1ce..81323b6de 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit cf473b1ce07e8271a9343510e471700fd46fa08b +Subproject commit 81323b6dec1b1838279090156e272d13a58dfc1b From bf499970536e9d8142a0b5674e6b74db976b0046 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Thu, 31 Jul 2025 19:59:51 +1000 Subject: [PATCH 33/36] Update changelog. --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 8dcaad04b..6d7913e21 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,7 @@ ##### Additions :tada: +- Added `CesiumGeoJsonDocumentRasterOverlay`, allowing stylized GeoJSON to be rasterized and draped over terrain and other 3D Tiles. - Added `FCesiumPropertyAttributeProperty` to represent glTF property attribute properties and `UCesiumPropertyAttributePropertyBlueprintLibrary` to retrieve their values. - Added `FCesiumPropertyAttribute` to represent glTF property attributes and `UCesiumPropertyAttributeBlueprintLibrary` to act upon them with Blueprints. - Added `UCesiumPrimitiveMetadataBlueprintLibrary::GetPropertyAttributes` to retrieve the property attributes from a `FCesiumPrimitiveMetadata`. From eb2ea66192b7d028cf570c8d93a0ece4d5cc9b64 Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 31 Jul 2025 16:49:54 -0400 Subject: [PATCH 34/36] Remove projection from GeoJsonDocumentRasterOverlay --- .../CesiumGeoJsonDocumentRasterOverlay.cpp | 9 ------- .../CesiumGeoJsonDocumentRasterOverlay.h | 25 ------------------- extern/cesium-native | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp index 6cae3c823..8978132c2 100644 --- a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -52,17 +52,8 @@ UCesiumGeoJsonDocumentRasterOverlay::CreateOverlay( return nullptr; } - CesiumGeospatial::Projection projection; - if (this->Projection == - ECesiumGeoJsonDocumentRasterOverlayProjection::Geographic) { - projection = CesiumGeospatial::GeographicProjection(options.ellipsoid); - } else { - projection = CesiumGeospatial::WebMercatorProjection(options.ellipsoid); - } - CesiumRasterOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{ this->DefaultStyle.toNative(), - std::move(projection), options.ellipsoid, this->MipLevels}; diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h index 0827db809..f14c1513b 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h @@ -11,22 +11,6 @@ #include "Delegates/Delegate.h" #include "CesiumGeoJsonDocumentRasterOverlay.generated.h" -/** - * The projection used by a CesiumVectorDocumentRasterOverlay. - */ -UENUM(BlueprintType) -enum class ECesiumGeoJsonDocumentRasterOverlayProjection : uint8 { - /** - * The raster overlay is projected using Web Mercator. - */ - WebMercator, - - /** - * The raster overlay is projected using a geographic projection. - */ - Geographic -}; - /** * Configures where the CesiumVectorDocumentRasterOverlay should load its vector * data from. @@ -62,15 +46,6 @@ class CESIUMRUNTIME_API UCesiumGeoJsonDocumentRasterOverlay GENERATED_BODY() public: - /** - * The type of projection used to project the imagery onto the globe. - * For instance, EPSG:4326 uses geographic projection and EPSG:3857 uses Web - * Mercator. - */ - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - ECesiumGeoJsonDocumentRasterOverlayProjection Projection = - ECesiumGeoJsonDocumentRasterOverlayProjection::WebMercator; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") ECesiumGeoJsonDocumentRasterOverlaySource Source = ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon; diff --git a/extern/cesium-native b/extern/cesium-native index a46d0687b..c750295cb 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit a46d0687ba596a3af7c3c8494213fea09c701ed9 +Subproject commit c750295cb013784db7492f53d2a5aed8a3e815fa From 6bb68a9b14bb7947eb107cc9f6fee243e8bbf73b Mon Sep 17 00:00:00 2001 From: Ashley Rogers Date: Thu, 31 Jul 2025 17:32:29 -0400 Subject: [PATCH 35/36] Default color for vector style --- Source/CesiumRuntime/Public/CesiumVectorStyle.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/CesiumRuntime/Public/CesiumVectorStyle.h b/Source/CesiumRuntime/Public/CesiumVectorStyle.h index e09992a39..5f2286417 100644 --- a/Source/CesiumRuntime/Public/CesiumVectorStyle.h +++ b/Source/CesiumRuntime/Public/CesiumVectorStyle.h @@ -54,7 +54,7 @@ struct FCesiumVectorLineStyle { * The color to be used. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + FColor Color = FColor(0xff, 0xff, 0xff); /** * The color mode to be used. */ @@ -87,7 +87,7 @@ struct FCesiumVectorPolygonFillStyle { * The color to be used. */ UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") - FColor Color = FColor(1.0f, 1.0f, 1.0f, 1.0f); + FColor Color = FColor(0xff, 0xff, 0xff); /** * The color mode to be used. */ From 761bf2809acaba45d5d923dce79b2ad1245dd63e Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Fri, 1 Aug 2025 08:12:00 +1000 Subject: [PATCH 36/36] Update cesium-native. --- extern/cesium-native | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extern/cesium-native b/extern/cesium-native index c750295cb..d1fe3ba2a 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit c750295cb013784db7492f53d2a5aed8a3e815fa +Subproject commit d1fe3ba2a7b53c4d82a0ec88f1654457d999f968