From e46b86ee51eaffffe5c99b0a597e88a9037fb081 Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 2 Jul 2024 21:35:47 +1000 Subject: [PATCH 1/4] Fix bad_any_cast errors by disabling RTTI. UE disables it, and apparently on Linux/Android/Apple, mixing libraries compiled with and without RTTI is a mess. --- extern/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index c38c16a4d..b31a54cea 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -54,11 +54,11 @@ set(CMAKE_RELWITHDEBINFO_POSTFIX ${CESIUM_RELEASE_POSTFIX}) # On Mac and Linux, Unreal uses -fvisibility-ms-compat. # On Android, it uses -fvisibility=hidden if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-ms-compat -fvisibility-inlines-hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-ms-compat -fvisibility-inlines-hidden -fno-rtti") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Android") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fvisibility-inlines-hidden -fno-rtti") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "iOS") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fno-rtti") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") # Unreal Engine adds /Zp8 in 64-bit Windows builds to align structs to 8 bytes instead of the # default of 16 bytes. There's this nice note in the documentation for that option: From 97f68d00abca7ba7f5948f788ffb5161e9b065cc Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Tue, 2 Jul 2024 21:42:16 +1000 Subject: [PATCH 2/4] Update CHANGES.md. --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index e5ad54822..a0f48abbb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Change Log +### ? - ? + +##### Fixes :wrench: + +- Fixed a bug that could cause a `bad_any_cast` exception when trying to access glTF extensions. This commonly popped up when loading tilesets with metadata. + ### v2.7.0 - 2024-07-01 ##### Additions :tada: From 9f1c89cf7c357a79440734f0ab2905546bb5b1ff Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 3 Jul 2024 11:12:55 +1000 Subject: [PATCH 3/4] Fix test failures on Linux. --- CHANGES.md | 3 ++- Source/CesiumRuntime/Private/CesiumMetadataValue.cpp | 2 +- .../Private/CesiumPropertyArrayBlueprintLibrary.cpp | 2 +- Source/CesiumRuntime/Private/CesiumPropertyTableProperty.cpp | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a0f48abbb..854477543 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,8 @@ ##### Fixes :wrench: -- Fixed a bug that could cause a `bad_any_cast` exception when trying to access glTF extensions. This commonly popped up when loading tilesets with metadata. +- Fixed a bug that could cause a `bad_any_cast` exception when trying to access glTF extensions on non-Windows platforms. This commonly popped up when loading tilesets with metadata. +- Fixed a bug that caused the `GetInteger64` functions on `CesiumMetadataValue`, `CesiumPropertyArray`, and `CesiumPropertyTableProperty` to always return the default value on non-Windows platforms. ### v2.7.0 - 2024-07-01 diff --git a/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp b/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp index 44580b035..a666ba959 100644 --- a/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp +++ b/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp @@ -91,7 +91,7 @@ int64 UCesiumMetadataValueBlueprintLibrary::GetInteger64( int64 DefaultValue) { return std::visit( [DefaultValue](auto value) -> int64 { - return CesiumGltf::MetadataConversions::convert( + return CesiumGltf::MetadataConversions::convert( value) .value_or(DefaultValue); }, diff --git a/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp b/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp index f96fa4181..feef89fcf 100644 --- a/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp +++ b/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp @@ -120,7 +120,7 @@ int64 UCesiumPropertyArrayBlueprintLibrary::GetInteger64( return defaultValue; } auto value = v[index]; - return CesiumGltf::MetadataConversions::convert( + return CesiumGltf::MetadataConversions::convert( value) .value_or(defaultValue); }, diff --git a/Source/CesiumRuntime/Private/CesiumPropertyTableProperty.cpp b/Source/CesiumRuntime/Private/CesiumPropertyTableProperty.cpp index a3aba9f56..fa8a6117c 100644 --- a/Source/CesiumRuntime/Private/CesiumPropertyTableProperty.cpp +++ b/Source/CesiumRuntime/Private/CesiumPropertyTableProperty.cpp @@ -969,7 +969,7 @@ int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetInteger64( auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; - return CesiumGltf::MetadataConversions:: + return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } From a22b842e9b04c3a6fb83a5ececf7aa65e0169b1c Mon Sep 17 00:00:00 2001 From: Kevin Ring Date: Wed, 3 Jul 2024 11:15:29 +1000 Subject: [PATCH 4/4] Formatting. --- Source/CesiumRuntime/Private/CesiumMetadataValue.cpp | 6 +++--- .../Private/CesiumPropertyArrayBlueprintLibrary.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp b/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp index a666ba959..140dce068 100644 --- a/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp +++ b/Source/CesiumRuntime/Private/CesiumMetadataValue.cpp @@ -91,9 +91,9 @@ int64 UCesiumMetadataValueBlueprintLibrary::GetInteger64( int64 DefaultValue) { return std::visit( [DefaultValue](auto value) -> int64 { - return CesiumGltf::MetadataConversions::convert( - value) - .value_or(DefaultValue); + return CesiumGltf::MetadataConversions:: + convert(value) + .value_or(DefaultValue); }, Value._value); } diff --git a/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp b/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp index feef89fcf..e9d6d6ec7 100644 --- a/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp +++ b/Source/CesiumRuntime/Private/CesiumPropertyArrayBlueprintLibrary.cpp @@ -120,9 +120,9 @@ int64 UCesiumPropertyArrayBlueprintLibrary::GetInteger64( return defaultValue; } auto value = v[index]; - return CesiumGltf::MetadataConversions::convert( - value) - .value_or(defaultValue); + return CesiumGltf::MetadataConversions:: + convert(value) + .value_or(defaultValue); }, array._value); }