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