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`. diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp index 7b5f02c54..7f2f56b86 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& OutGeoJsonDocument) { diff --git a/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp new file mode 100644 index 000000000..8978132c2 --- /dev/null +++ b/Source/CesiumRuntime/Private/CesiumGeoJsonDocumentRasterOverlay.cpp @@ -0,0 +1,111 @@ +// 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" + +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 pGeoJsonDocument; + }); +} +} // namespace + +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; + } + + CesiumRasterOverlays::GeoJsonDocumentRasterOverlayOptions vectorOptions{ + this->DefaultStyle.toNative(), + 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), + 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 ( + 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), + 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, + options); +} 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/Private/CesiumVectorStyle.cpp b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp new file mode 100644 index 000000000..ed9f03539 --- /dev/null +++ b/Source/CesiumRuntime/Private/CesiumVectorStyle.cpp @@ -0,0 +1,97 @@ +#include "CesiumVectorStyle.h" + +#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{ + lineStyleToNative(this->LineStyle), + CesiumVectorData::PolygonStyle{ + 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( + (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{ + style.polygon.fill.has_value(), + FillStyle, + style.polygon.outline.has_value(), + OutlineStyle}}; +} diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h index 835fa9f4b..b6d5863fe 100644 --- a/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h @@ -34,6 +34,17 @@ struct FCesiumGeoJsonDocument { FCesiumGeoJsonDocument( std::shared_ptr&& document); + /** + * @brief Checks if this FCesiumGeoJsonDocument is valid (document is not + * nullptr). + */ + bool IsValid() const; + + /** + * @brief Returns the `CesiumVectorData::GeoJsonDocument` this wraps. + */ + const std::shared_ptr& GetDocument() const; + private: std::shared_ptr _pDocument; diff --git a/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h new file mode 100644 index 000000000..f14c1513b --- /dev/null +++ b/Source/CesiumRuntime/Public/CesiumGeoJsonDocumentRasterOverlay.h @@ -0,0 +1,146 @@ +// Copyright 2020-2024 CesiumGS, Inc. and Contributors + +#pragma once + +#include "CesiumGeoJsonDocument.h" +#include "CesiumIonServer.h" +#include "CesiumRasterOverlay.h" +#include "CesiumVectorStyle.h" +#include "Components/ActorComponent.h" +#include "CoreMinimal.h" +#include "Delegates/Delegate.h" +#include "CesiumGeoJsonDocumentRasterOverlay.generated.h" + +/** + * Configures where the CesiumVectorDocumentRasterOverlay should load its vector + * data from. + */ +UENUM(BlueprintType) +enum class ECesiumGeoJsonDocumentRasterOverlaySource : uint8 { + /** + * The raster overlay will display the provided GeoJsonDocument. + */ + FromDocument = 0, + /** + * The raster overlay will load a GeoJsonDocument from Cesium ion. + */ + FromCesiumIon = 1, + /** + * The raster overlay will load a GeoJsonDocument from a URL. + */ + FromUrl = 2 +}; + +DECLARE_DYNAMIC_DELEGATE_OneParam( + FCesiumGeoJsonDocumentRasterOverlayOnDocumentLoadedCallback, + FCesiumGeoJsonDocument, + InDocument); + +UCLASS( + ClassGroup = Cesium, + BlueprintType, + Blueprintable, + meta = (BlueprintSpawnableComponent)) +class CESIUMRUNTIME_API UCesiumGeoJsonDocumentRasterOverlay + : public UCesiumRasterOverlay { + GENERATED_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + ECesiumGeoJsonDocumentRasterOverlaySource Source = + ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon; + + /** + * The ID of the Cesium ion asset to use. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + meta = + (EditCondition = + "Source == ECesiumGeoJsonDocumentRasterOverlaySource::FromCesiumIon")) + int64 IonAssetID; + + /** + * The Cesium ion Server from which this raster overlay is loaded. + */ + UPROPERTY( + EditAnywhere, + BlueprintReadWrite, + Category = "Cesium", + AdvancedDisplay, + meta = + (EditCondition = + "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 == 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, + Category = "Cesium", + 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 when the document has been loaded. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FCesiumGeoJsonDocumentRasterOverlayOnDocumentLoadedCallback OnDocumentLoaded; + +protected: + virtual std::unique_ptr CreateOverlay( + const CesiumRasterOverlays::RasterOverlayOptions& options = {}) override; +}; 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); }; diff --git a/Source/CesiumRuntime/Public/CesiumVectorStyle.h b/Source/CesiumRuntime/Public/CesiumVectorStyle.h new file mode 100644 index 000000000..5f2286417 --- /dev/null +++ b/Source/CesiumRuntime/Public/CesiumVectorStyle.h @@ -0,0 +1,167 @@ +#pragma once + +#include "CesiumVectorData/VectorStyle.h" +#include "CoreMinimal.h" +#include "UObject/ObjectMacros.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(0xff, 0xff, 0xff); + /** + * 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 fill polygons. + */ +USTRUCT(BlueprintType) +struct FCesiumVectorPolygonFillStyle { + GENERATED_BODY() + + /** + * The color to be used. + */ + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium") + FColor Color = FColor(0xff, 0xff, 0xff); + /** + * The color mode to be used. + */ + 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. + */ + 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. + */ + 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; +}; + +/** + * 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/CMakeLists.txt b/extern/CMakeLists.txt index 3d2ae71f4..f27c5928f 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -124,7 +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) -SET(CESIUM_DISABLE_CURL ON) +# Skip including curl asset accessor as it causes issues on Android and iOS +set(CESIUM_DISABLE_CURL TRUE) add_subdirectory(cesium-native) diff --git a/extern/cesium-native b/extern/cesium-native index a3c944a5d..d1fe3ba2a 160000 --- a/extern/cesium-native +++ b/extern/cesium-native @@ -1 +1 @@ -Subproject commit a3c944a5dcbd21fa1fd7943697a6dbf3ac5995e5 +Subproject commit d1fe3ba2a7b53c4d82a0ec88f1654457d999f968 diff --git a/extern/vcpkg-overlays/blend2d/portfile.cmake b/extern/vcpkg-overlays/blend2d/portfile.cmake new file mode 100644 index 000000000..74521c956 --- /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_EXTERNAL_ASMJIT_D} + ${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" + ] + } + } +}