// Copyright 2020-2024 CesiumGS, Inc. and Contributors #include "CesiumPropertyTableProperty.h" #include "CesiumGltf/MetadataConversions.h" #include "CesiumGltf/PropertyTypeTraits.h" #include "UnrealMetadataConversions.h" #include namespace { /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * of the specified type. If the type does not match, the callback is performed * on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param callback The callback function. * * @tparam TProperty The property type. * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template < typename TProperty, bool Normalized, typename TResult, typename Callback> TResult propertyTablePropertyCallback(const std::any& property, Callback&& callback) { const CesiumGltf::PropertyTablePropertyView* pProperty = std::any_cast< CesiumGltf::PropertyTablePropertyView>( &property); if (pProperty) { return callback(*pProperty); } return callback(CesiumGltf::PropertyTablePropertyView()); } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a scalar type. If the valueType does not have a valid component type, the * callback is performed on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult scalarPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback( property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< uint8_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< int16_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< uint16_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< int32_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< uint32_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< int64_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< uint64_t, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback( property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback( property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a scalar array type. If the valueType does not have a valid component * type, the callback is performed on an invalid PropertyTablePropertyView * instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult scalarArrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::vecN type. If the valueType does not have a valid component type, * the callback is performed on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam N The dimensions of the glm::vecN * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult vecNPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< glm::vec, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback< glm::vec, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback< glm::vec, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::vecN type. If the valueType does not have a valid component type, * the callback is performed on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult vecNPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { if (valueType.Type == ECesiumMetadataType::Vec2) { return vecNPropertyTablePropertyCallback<2, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Vec3) { return vecNPropertyTablePropertyCallback<3, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Vec4) { return vecNPropertyTablePropertyCallback<4, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } return callback(CesiumGltf::PropertyTablePropertyView()); } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::vecN array type. If the valueType does not have a valid component * type, the callback is performed on an invalid PropertyTablePropertyView * instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam N The dimensions of the glm::vecN * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult vecNArrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::vecN array type. If the valueType does not have a valid component * type, the callback is performed on an invalid PropertyTablePropertyView * instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult vecNArrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { if (valueType.Type == ECesiumMetadataType::Vec2) { return vecNArrayPropertyTablePropertyCallback< 2, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Vec3) { return vecNArrayPropertyTablePropertyCallback< 3, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Vec4) { return vecNArrayPropertyTablePropertyCallback< 4, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } return callback(CesiumGltf::PropertyTablePropertyView()); } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::matN type. If the valueType does not have a valid component type, * the callback is performed on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam N The dimensions of the glm::matN * @tparam TNormalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult matNPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< glm::mat, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback< glm::mat, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback< glm::mat, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::matN type. If the valueType does not have a valid component type, * the callback is performed on an invalid PropertyTablePropertyView instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult matNPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { if (valueType.Type == ECesiumMetadataType::Mat2) { return matNPropertyTablePropertyCallback<2, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Mat3) { return matNPropertyTablePropertyCallback<3, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Mat4) { return matNPropertyTablePropertyCallback<4, Normalized, TResult, Callback>( property, valueType, std::forward(callback)); } return callback(CesiumGltf::PropertyTablePropertyView()); } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::matN array type. If the valueType does not have a valid component * type, the callback is performed on an invalid PropertyTablePropertyView * instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam N The dimensions of the glm::matN * @tparam TNormalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult matNArrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.ComponentType) { case ECesiumMetadataComponentType::Int8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint8: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint16: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Int64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Uint64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, Normalized, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float32: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataComponentType::Float64: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView>, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } /** * Callback on a std::any, assuming that it contains a PropertyTablePropertyView * on a glm::matN array type. If the valueType does not have a valid component * type, the callback is performed on an invalid PropertyTablePropertyView * instead. * * @param property The std::any containing the property. * @param valueType The FCesiumMetadataValueType of the property. * @param callback The callback function. * * @tparam Normalized Whether the PropertyTablePropertyView is normalized. * @tparam TResult The type of the output from the callback function. * @tparam Callback The callback function type. */ template TResult matNArrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { if (valueType.Type == ECesiumMetadataType::Mat2) { return matNArrayPropertyTablePropertyCallback< 2, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Mat3) { return matNArrayPropertyTablePropertyCallback< 3, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } if (valueType.Type == ECesiumMetadataType::Mat4) { return matNArrayPropertyTablePropertyCallback< 4, Normalized, TResult, Callback>(property, valueType, std::forward(callback)); } return callback(CesiumGltf::PropertyTablePropertyView()); } template TResult arrayPropertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, Callback&& callback) { switch (valueType.Type) { case ECesiumMetadataType::Scalar: return scalarArrayPropertyTablePropertyCallback< Normalized, TResult, Callback>(property, valueType, std::forward(callback)); case ECesiumMetadataType::Vec2: case ECesiumMetadataType::Vec3: case ECesiumMetadataType::Vec4: return vecNArrayPropertyTablePropertyCallback< Normalized, TResult, Callback>(property, valueType, std::forward(callback)); case ECesiumMetadataType::Mat2: case ECesiumMetadataType::Mat3: case ECesiumMetadataType::Mat4: return matNArrayPropertyTablePropertyCallback< Normalized, TResult, Callback>(property, valueType, std::forward(callback)); case ECesiumMetadataType::Boolean: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, false, TResult, Callback>(property, std::forward(callback)); case ECesiumMetadataType::String: return propertyTablePropertyCallback< CesiumGltf::PropertyArrayView, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } template TResult propertyTablePropertyCallback( const std::any& property, const FCesiumMetadataValueType& valueType, bool normalized, Callback&& callback) { if (valueType.bIsArray) { return normalized ? arrayPropertyTablePropertyCallback( property, valueType, std::forward(callback)) : arrayPropertyTablePropertyCallback( property, valueType, std::forward(callback)); } switch (valueType.Type) { case ECesiumMetadataType::Scalar: return normalized ? scalarPropertyTablePropertyCallback( property, valueType, std::forward(callback)) : scalarPropertyTablePropertyCallback( property, valueType, std::forward(callback)); case ECesiumMetadataType::Vec2: case ECesiumMetadataType::Vec3: case ECesiumMetadataType::Vec4: return normalized ? vecNPropertyTablePropertyCallback( property, valueType, std::forward(callback)) : vecNPropertyTablePropertyCallback( property, valueType, std::forward(callback)); case ECesiumMetadataType::Mat2: case ECesiumMetadataType::Mat3: case ECesiumMetadataType::Mat4: return normalized ? matNPropertyTablePropertyCallback( property, valueType, std::forward(callback)) : matNPropertyTablePropertyCallback( property, valueType, std::forward(callback)); case ECesiumMetadataType::Boolean: return propertyTablePropertyCallback( property, std::forward(callback)); case ECesiumMetadataType::String: return propertyTablePropertyCallback< std::string_view, false, TResult, Callback>(property, std::forward(callback)); default: return callback(CesiumGltf::PropertyTablePropertyView()); } } } // namespace ECesiumPropertyTablePropertyStatus UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertyTablePropertyStatus( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return Property._status; } ECesiumMetadataBlueprintType UCesiumPropertyTablePropertyBlueprintLibrary::GetBlueprintType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return CesiumMetadataValueTypeToBlueprintType(Property._valueType); } ECesiumMetadataBlueprintType UCesiumPropertyTablePropertyBlueprintLibrary::GetArrayElementBlueprintType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { if (!Property._valueType.bIsArray) { return ECesiumMetadataBlueprintType::None; } FCesiumMetadataValueType valueType(Property._valueType); valueType.bIsArray = false; return CesiumMetadataValueTypeToBlueprintType(valueType); } FCesiumMetadataValueType UCesiumPropertyTablePropertyBlueprintLibrary::GetValueType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return Property._valueType; } int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> int64 { return view.size(); }); } int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetArraySize( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> int64 { return view.arrayCount(); }); } bool UCesiumPropertyTablePropertyBlueprintLibrary::GetBoolean( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, bool DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> bool { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } uint8 UCesiumPropertyTablePropertyBlueprintLibrary::GetByte( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, uint8 DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> uint8 { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } int32 UCesiumPropertyTablePropertyBlueprintLibrary::GetInteger( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, int32 DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> int32 { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetInteger64( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, int64 DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> int64 { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } float UCesiumPropertyTablePropertyBlueprintLibrary::GetFloat( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, float DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> float { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } double UCesiumPropertyTablePropertyBlueprintLibrary::GetFloat64( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, double DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, DefaultValue](const auto& v) -> double { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value) .value_or(DefaultValue); } return DefaultValue; }); } FIntPoint UCesiumPropertyTablePropertyBlueprintLibrary::GetIntPoint( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FIntPoint& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FIntPoint { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toIntPoint(value, DefaultValue); } else { auto maybeVec2 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec2 ? UnrealMetadataConversions::toIntPoint(*maybeVec2) : DefaultValue; } }); } FVector2D UCesiumPropertyTablePropertyBlueprintLibrary::GetVector2D( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FVector2D& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FVector2D { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toVector2D(value, DefaultValue); } else { auto maybeVec2 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec2 ? UnrealMetadataConversions::toVector2D(*maybeVec2) : DefaultValue; } }); } FIntVector UCesiumPropertyTablePropertyBlueprintLibrary::GetIntVector( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FIntVector& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FIntVector { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toIntVector(value, DefaultValue); } else { auto maybeVec3 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec3 ? UnrealMetadataConversions::toIntVector(*maybeVec3) : DefaultValue; } }); } FVector3f UCesiumPropertyTablePropertyBlueprintLibrary::GetVector3f( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FVector3f& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FVector3f { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toVector3f(value, DefaultValue); } else { auto maybeVec3 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec3 ? UnrealMetadataConversions::toVector3f(*maybeVec3) : DefaultValue; } }); } FVector UCesiumPropertyTablePropertyBlueprintLibrary::GetVector( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FVector& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FVector { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toVector(value, DefaultValue); } else { auto maybeVec3 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec3 ? UnrealMetadataConversions::toVector(*maybeVec3) : DefaultValue; } }); } FVector4 UCesiumPropertyTablePropertyBlueprintLibrary::GetVector4( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FVector4& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FVector4 { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toVector4(value, DefaultValue); } else { auto maybeVec4 = CesiumGltf:: MetadataConversions::convert(value); return maybeVec4 ? UnrealMetadataConversions::toVector4(*maybeVec4) : DefaultValue; } }); } FMatrix UCesiumPropertyTablePropertyBlueprintLibrary::GetMatrix( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FMatrix& DefaultValue) { auto maybeMat4 = propertyTablePropertyCallback>( Property._property, Property._valueType, Property._normalized, [FeatureID](const auto& v) -> std::optional { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return std::nullopt; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return std::nullopt; } auto value = *maybeValue; return CesiumGltf::MetadataConversions:: convert(value); }); return maybeMat4 ? UnrealMetadataConversions::toMatrix(*maybeMat4) : DefaultValue; } FString UCesiumPropertyTablePropertyBlueprintLibrary::GetString( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID, const FString& DefaultValue) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID, &DefaultValue](const auto& v) -> FString { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return DefaultValue; } auto maybeValue = v.get(FeatureID); if (!maybeValue) { return DefaultValue; } auto value = *maybeValue; using ValueType = decltype(value); if constexpr ( CesiumGltf::IsMetadataVecN::value || CesiumGltf::IsMetadataMatN::value || CesiumGltf::IsMetadataString::value) { return UnrealMetadataConversions::toString(value); } else { auto maybeString = CesiumGltf:: MetadataConversions::convert(value); return maybeString ? UnrealMetadataConversions::toString(*maybeString) : DefaultValue; } }); } FCesiumPropertyArray UCesiumPropertyTablePropertyBlueprintLibrary::GetArray( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID](const auto& v) -> FCesiumPropertyArray { // size() returns zero if the view is invalid. if (FeatureID < 0 || FeatureID >= v.size()) { return FCesiumPropertyArray(); } auto maybeValue = v.get(FeatureID); if (maybeValue) { auto value = *maybeValue; if constexpr (CesiumGltf::IsMetadataArray::value) { return FCesiumPropertyArray(std::move(value)); } } return FCesiumPropertyArray(); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID](const auto& view) -> FCesiumMetadataValue { // size() returns zero if the view is invalid. if (FeatureID >= 0 && FeatureID < view.size()) { return FCesiumMetadataValue(view.get(FeatureID)); } return FCesiumMetadataValue(); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetRawValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [FeatureID](const auto& view) -> FCesiumMetadataValue { // Return an empty value if the property is empty. if (view.status() == CesiumGltf::PropertyTablePropertyViewStatus:: EmptyPropertyWithDefault) { return FCesiumMetadataValue(); } // size() returns zero if the view is invalid. if (FeatureID >= 0 && FeatureID < view.size()) { return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.getRaw(FeatureID))); } return FCesiumMetadataValue(); }); } bool UCesiumPropertyTablePropertyBlueprintLibrary::IsNormalized( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return Property._normalized; } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetOffset( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no offset is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.offset())); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetScale( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no scale is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.scale())); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetMinimumValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no min is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.min())); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetMaximumValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no max is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.max())); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetNoDataValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no "no data" value is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.noData())); }); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetDefaultValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return propertyTablePropertyCallback( Property._property, Property._valueType, Property._normalized, [](const auto& view) -> FCesiumMetadataValue { // Returns an empty value if no default value is specified. return FCesiumMetadataValue( CesiumGltf::propertyValueViewToCopy(view.defaultValue())); }); } PRAGMA_DISABLE_DEPRECATION_WARNINGS ECesiumMetadataBlueprintType UCesiumPropertyTablePropertyBlueprintLibrary::GetBlueprintComponentType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return UCesiumPropertyTablePropertyBlueprintLibrary:: GetArrayElementBlueprintType(Property); } ECesiumMetadataTrueType_DEPRECATED UCesiumPropertyTablePropertyBlueprintLibrary::GetTrueType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return CesiumMetadataValueTypeToTrueType(Property._valueType); } ECesiumMetadataTrueType_DEPRECATED UCesiumPropertyTablePropertyBlueprintLibrary::GetTrueComponentType( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { FCesiumMetadataValueType type = Property._valueType; type.bIsArray = false; return CesiumMetadataValueTypeToTrueType(type); } int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetNumberOfFeatures( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return UCesiumPropertyTablePropertyBlueprintLibrary::GetPropertySize( Property); } int64 UCesiumPropertyTablePropertyBlueprintLibrary::GetComponentCount( UPARAM(ref) const FCesiumPropertyTableProperty& Property) { return UCesiumPropertyTablePropertyBlueprintLibrary::GetArraySize(Property); } FCesiumMetadataValue UCesiumPropertyTablePropertyBlueprintLibrary::GetGenericValue( UPARAM(ref) const FCesiumPropertyTableProperty& Property, int64 FeatureID) { return UCesiumPropertyTablePropertyBlueprintLibrary::GetValue( Property, FeatureID); } PRAGMA_ENABLE_DEPRECATION_WARNINGS