Skip to content

Commit

Permalink
Merge pull request #1468 from CesiumGS/good-any-cast
Browse files Browse the repository at this point in the history
Fix bad_any_cast errors by disabling RTTI when building cesium-native
  • Loading branch information
j9liu authored Jul 22, 2024
2 parents 03e3818 + 3985d58 commit 3318683
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

### ? - ?

#### Fixes :wrench:
##### Fixes :wrench:

- 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.
- Fixed issue with `UCesiumGlobeAnchorComponent::GetEllipsoid` that caused compilation errors on some machines.

### v2.7.0 - 2024-07-01
Expand Down
6 changes: 3 additions & 3 deletions Source/CesiumRuntime/Private/CesiumMetadataValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ int64 UCesiumMetadataValueBlueprintLibrary::GetInteger64(
int64 DefaultValue) {
return std::visit(
[DefaultValue](auto value) -> int64 {
return CesiumGltf::MetadataConversions<int64, decltype(value)>::convert(
value)
.value_or(DefaultValue);
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(DefaultValue);
},
Value._value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ int64 UCesiumPropertyArrayBlueprintLibrary::GetInteger64(
return defaultValue;
}
auto value = v[index];
return CesiumGltf::MetadataConversions<int64, decltype(value)>::convert(
value)
.value_or(defaultValue);
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(defaultValue);
},
array._value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetInteger64(
auto maybeValue = v.get(FeatureID);
if (maybeValue) {
auto value = *maybeValue;
return CesiumGltf::MetadataConversions<int64, decltype(value)>::
return CesiumGltf::MetadataConversions<int64_t, decltype(value)>::
convert(value)
.value_or(DefaultValue);
}
Expand Down
6 changes: 3 additions & 3 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3318683

Please sign in to comment.