Cesium for Unreal 2.15.0
Loading...
Searching...
No Matches
CesiumPropertyArray.h
Go to the documentation of this file.
1// Copyright 2020-2024 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumGltf/PropertyArrayView.h"
6#include "CesiumGltf/PropertyTypeTraits.h"
9#include "UObject/ObjectMacros.h"
10#include <swl/variant.hpp>
11#include "CesiumPropertyArray.generated.h"
12
13/**
14 * A Blueprint-accessible wrapper for an array property in glTF metadata.
15 */
16USTRUCT(BlueprintType)
17struct CESIUMRUNTIME_API FCesiumPropertyArray {
18 GENERATED_USTRUCT_BODY()
19
20private:
21#pragma region ArrayType
22 template <typename T>
23 using ArrayPropertyView = CesiumGltf::PropertyArrayView<T>;
24
25 using ArrayType = swl::variant<
26 ArrayPropertyView<int8_t>,
27 ArrayPropertyView<uint8_t>,
28 ArrayPropertyView<int16_t>,
29 ArrayPropertyView<uint16_t>,
30 ArrayPropertyView<int32_t>,
31 ArrayPropertyView<uint32_t>,
32 ArrayPropertyView<int64_t>,
33 ArrayPropertyView<uint64_t>,
34 ArrayPropertyView<float>,
35 ArrayPropertyView<double>,
36 ArrayPropertyView<bool>,
37 ArrayPropertyView<std::string_view>,
38 ArrayPropertyView<glm::vec<2, int8_t>>,
39 ArrayPropertyView<glm::vec<2, uint8_t>>,
40 ArrayPropertyView<glm::vec<2, int16_t>>,
41 ArrayPropertyView<glm::vec<2, uint16_t>>,
42 ArrayPropertyView<glm::vec<2, int32_t>>,
43 ArrayPropertyView<glm::vec<2, uint32_t>>,
44 ArrayPropertyView<glm::vec<2, int64_t>>,
45 ArrayPropertyView<glm::vec<2, uint64_t>>,
46 ArrayPropertyView<glm::vec<2, float>>,
47 ArrayPropertyView<glm::vec<2, double>>,
48 ArrayPropertyView<glm::vec<3, int8_t>>,
49 ArrayPropertyView<glm::vec<3, uint8_t>>,
50 ArrayPropertyView<glm::vec<3, int16_t>>,
51 ArrayPropertyView<glm::vec<3, uint16_t>>,
52 ArrayPropertyView<glm::vec<3, int32_t>>,
53 ArrayPropertyView<glm::vec<3, uint32_t>>,
54 ArrayPropertyView<glm::vec<3, int64_t>>,
55 ArrayPropertyView<glm::vec<3, uint64_t>>,
56 ArrayPropertyView<glm::vec<3, float>>,
57 ArrayPropertyView<glm::vec<3, double>>,
58 ArrayPropertyView<glm::vec<4, int8_t>>,
59 ArrayPropertyView<glm::vec<4, uint8_t>>,
60 ArrayPropertyView<glm::vec<4, int16_t>>,
61 ArrayPropertyView<glm::vec<4, uint16_t>>,
62 ArrayPropertyView<glm::vec<4, int32_t>>,
63 ArrayPropertyView<glm::vec<4, uint32_t>>,
64 ArrayPropertyView<glm::vec<4, int64_t>>,
65 ArrayPropertyView<glm::vec<4, uint64_t>>,
66 ArrayPropertyView<glm::vec<4, float>>,
67 ArrayPropertyView<glm::vec<4, double>>,
68 ArrayPropertyView<glm::mat<2, 2, int8_t>>,
69 ArrayPropertyView<glm::mat<2, 2, uint8_t>>,
70 ArrayPropertyView<glm::mat<2, 2, int16_t>>,
71 ArrayPropertyView<glm::mat<2, 2, uint16_t>>,
72 ArrayPropertyView<glm::mat<2, 2, int32_t>>,
73 ArrayPropertyView<glm::mat<2, 2, uint32_t>>,
74 ArrayPropertyView<glm::mat<2, 2, int64_t>>,
75 ArrayPropertyView<glm::mat<2, 2, uint64_t>>,
76 ArrayPropertyView<glm::mat<2, 2, float>>,
77 ArrayPropertyView<glm::mat<2, 2, double>>,
78 ArrayPropertyView<glm::mat<3, 3, int8_t>>,
79 ArrayPropertyView<glm::mat<3, 3, uint8_t>>,
80 ArrayPropertyView<glm::mat<3, 3, int16_t>>,
81 ArrayPropertyView<glm::mat<3, 3, uint16_t>>,
82 ArrayPropertyView<glm::mat<3, 3, int32_t>>,
83 ArrayPropertyView<glm::mat<3, 3, uint32_t>>,
84 ArrayPropertyView<glm::mat<3, 3, int64_t>>,
85 ArrayPropertyView<glm::mat<3, 3, uint64_t>>,
86 ArrayPropertyView<glm::mat<3, 3, float>>,
87 ArrayPropertyView<glm::mat<3, 3, double>>,
88 ArrayPropertyView<glm::mat<4, 4, int8_t>>,
89 ArrayPropertyView<glm::mat<4, 4, uint8_t>>,
90 ArrayPropertyView<glm::mat<4, 4, int16_t>>,
91 ArrayPropertyView<glm::mat<4, 4, uint16_t>>,
92 ArrayPropertyView<glm::mat<4, 4, int32_t>>,
93 ArrayPropertyView<glm::mat<4, 4, uint32_t>>,
94 ArrayPropertyView<glm::mat<4, 4, int64_t>>,
95 ArrayPropertyView<glm::mat<4, 4, uint64_t>>,
96 ArrayPropertyView<glm::mat<4, 4, float>>,
97 ArrayPropertyView<glm::mat<4, 4, double>>>;
98#pragma endregion
99
100public:
101 /**
102 * Constructs an empty array instance with an unknown element type.
103 */
104 FCesiumPropertyArray() : _value(), _elementType() {}
105
106 /**
107 * Constructs an array instance.
108 * @param value The property array view that will be stored in this struct
109 * @param pEnumDefinition The enum definition this property uses, if any.
110 */
111 template <typename T>
114 TSharedPtr<FCesiumMetadataEnum> pEnumDefinition = nullptr)
115 : _value(),
116 _elementType(TypeToMetadataValueType<T>(pEnumDefinition)),
117 _storage(),
118 _pEnumDefinition(pEnumDefinition) {
119 this->_value = std::move(value).toViewAndExternalBuffer(this->_storage);
120 }
121
122 template <typename T>
125 TSharedPtr<FCesiumMetadataEnum> pEnumDefinition = nullptr)
127 CesiumGltf::PropertyArrayCopy<T>(value),
128 pEnumDefinition) {}
129
130 template <typename T>
133 TSharedPtr<FCesiumMetadataEnum> pEnumDefinition = nullptr)
134 : _value(value),
135 _elementType(TypeToMetadataValueType<T>(pEnumDefinition)),
136 _pEnumDefinition(pEnumDefinition) {}
137
142
143private:
144 template <typename T, typename... VariantType>
145 static bool
146 holdsArrayAlternative(const swl::variant<VariantType...>& variant) {
147 return swl::holds_alternative<CesiumGltf::PropertyArrayView<T>>(variant);
148 }
149
150 ArrayType _value;
151 FCesiumMetadataValueType _elementType;
152 std::vector<std::byte> _storage;
153 TSharedPtr<FCesiumMetadataEnum> _pEnumDefinition;
154
156};
Represents the true value type of a metadata value, akin to the property types in EXT_structural_meta...
FCesiumPropertyArray(const FCesiumPropertyArray &rhs)
FCesiumPropertyArray()
Constructs an empty array instance with an unknown element type.
FCesiumPropertyArray(FCesiumPropertyArray &&rhs)
FCesiumPropertyArray & operator=(FCesiumPropertyArray &&rhs)
FCesiumPropertyArray & operator=(const FCesiumPropertyArray &rhs)
FCesiumPropertyArray(CesiumGltf::PropertyArrayCopy< T > &&value, TSharedPtr< FCesiumMetadataEnum > pEnumDefinition=nullptr)
Constructs an array instance.
friend class UCesiumPropertyArrayBlueprintLibrary
FCesiumPropertyArray(const CesiumGltf::PropertyArrayView< T > &value, TSharedPtr< FCesiumMetadataEnum > pEnumDefinition=nullptr)
FCesiumPropertyArray(const CesiumGltf::PropertyArrayCopy< T > &value, TSharedPtr< FCesiumMetadataEnum > pEnumDefinition=nullptr)