Cesium for Unreal 2.12.0
Loading...
Searching...
No Matches
CesiumMetadataValueType.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/PropertyType.h"
7#include "CesiumGltf/PropertyTypeTraits.h"
8#include "CesiumMetadataValueType.generated.h"
9
13UENUM(BlueprintType)
14enum class ECesiumMetadataBlueprintType : uint8 {
15 /* Indicates a value cannot be represented in Blueprints. */
16 None,
17 /* Indicates a value is best represented as a Boolean. */
18 Boolean,
19 /* Indicates a value is best represented as a Byte (8-bit unsigned integer).
20 */
21 Byte,
22 /* Indicates a value is best represented as a Integer (32-bit signed). */
23 Integer,
24 /* Indicates a value is best represented as a Integer64 (64-bit signed). */
26 /* Indicates a value is best represented as a Float (32-bit). */
27 Float,
28 /* Indicates a value is best represented as a Float64 (64-bit). */
29 Float64,
30 /* Indicates a value is best represented as a FVector2D (2-dimensional
31 integer vector). */
33 /* Indicates a value is best represented as a FVector2D (2-dimensional
34 double-precision vector). */
36 /* Indicates a value is best represented as a FIntVector (3-dimensional
37 integer vector). */
39 /* Indicates a value is best represented as a FVector3f (3-dimensional
40 single-precision vector). */
42 /* Indicates a value is best represented as a FVector3 (3-dimensional
43 double-precision vector). */
44 Vector3,
45 /* Indicates a value is best represented as a FVector4 (4-dimensional
46 double-precision vector). */
47 Vector4,
48 /* Indicates a value is best represented as a FMatrix (4-by-4 double-precision
49 matrix). */
50 Matrix,
51 /* Indicates a value is best represented as a FString. This can be used as a
52 fallback for types with no proper Blueprints representation. */
53 String,
54 /* Indicates a value is best represented as a CesiumPropertyArray. */
55 Array
56};
57
58// UE requires us to have an enum with the value 0.
59// Invalid / None should have that value, but just make sure.
60static_assert(int(CesiumGltf::PropertyType::Invalid) == 0);
61static_assert(int(CesiumGltf::PropertyComponentType::None) == 0);
62
68UENUM(BlueprintType)
86
87// True types are cast, reintepreted, or parsed before being packed into gpu
88// types when encoding into a texture.
94
98UENUM(BlueprintType)
99enum class ECesiumMetadataType : uint8 {
100 Invalid = 0,
101 Scalar = int(CesiumGltf::PropertyType::Scalar),
102 Vec2 = int(CesiumGltf::PropertyType::Vec2),
103 Vec3 = int(CesiumGltf::PropertyType::Vec3),
104 Vec4 = int(CesiumGltf::PropertyType::Vec4),
105 Mat2 = int(CesiumGltf::PropertyType::Mat2),
106 Mat3 = int(CesiumGltf::PropertyType::Mat3),
107 Mat4 = int(CesiumGltf::PropertyType::Mat4),
108 Boolean = int(CesiumGltf::PropertyType::Boolean),
109 Enum = int(CesiumGltf::PropertyType::Enum),
110 String = int(CesiumGltf::PropertyType::String),
111};
112
117UENUM(BlueprintType)
119 None = 0,
120 Int8 = int(CesiumGltf::PropertyComponentType::Int8),
121 Uint8 = int(CesiumGltf::PropertyComponentType::Uint8),
122 Int16 = int(CesiumGltf::PropertyComponentType::Int16),
123 Uint16 = int(CesiumGltf::PropertyComponentType::Uint16),
124 Int32 = int(CesiumGltf::PropertyComponentType::Int32),
125 Uint32 = int(CesiumGltf::PropertyComponentType::Uint32),
126 Int64 = int(CesiumGltf::PropertyComponentType::Int64),
127 Uint64 = int(CesiumGltf::PropertyComponentType::Uint64),
128 Float32 = int(CesiumGltf::PropertyComponentType::Float32),
129 Float64 = int(CesiumGltf::PropertyComponentType::Float64),
130};
131
136USTRUCT(BlueprintType)
137struct CESIUMRUNTIME_API FCesiumMetadataValueType {
138 GENERATED_USTRUCT_BODY()
139
142 ComponentType(ECesiumMetadataComponentType::None),
143 bIsArray(false) {}
144
146 ECesiumMetadataType InType,
147 ECesiumMetadataComponentType InComponentType,
148 bool IsArray = false)
149 : Type(InType), ComponentType(InComponentType), bIsArray(IsArray) {}
150
154 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
156
161 UPROPERTY(
162 EditAnywhere,
163 BlueprintReadWrite,
164 Category = "Cesium",
165 Meta =
166 (EditCondition =
169
174 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Cesium")
175 bool bIsArray;
176
177 inline bool operator==(const FCesiumMetadataValueType& ValueType) const {
178 return Type == ValueType.Type && ComponentType == ValueType.ComponentType &&
179 bIsArray == ValueType.bIsArray;
180 }
181
182 inline bool operator!=(const FCesiumMetadataValueType& ValueType) const {
183 return Type != ValueType.Type || ComponentType != ValueType.ComponentType ||
184 bIsArray != ValueType.bIsArray;
185 }
186};
187
188template <typename T>
189static FCesiumMetadataValueType TypeToMetadataValueType() {
191 ECesiumMetadataComponentType componentType;
192 bool isArray;
193
195 using ArrayType = typename CesiumGltf::MetadataArrayType<T>::type;
196 type =
198 componentType = ECesiumMetadataComponentType(
200 isArray = true;
201 } else {
203 componentType = ECesiumMetadataComponentType(
205 isArray = false;
206 }
207
208 return {type, componentType, isArray};
209}
210
215static size_t GetMetadataTypeByteSize(
217 ECesiumMetadataComponentType ComponentType) {
218 size_t componentByteSize = 0;
219 if (ComponentType != ECesiumMetadataComponentType::None)
220 componentByteSize = CesiumGltf::getSizeOfComponentType(
221 CesiumGltf::PropertyComponentType(ComponentType));
222
223 size_t byteSize = componentByteSize;
224 switch (Type) {
226 byteSize = sizeof(bool);
227 break;
229 break;
231 byteSize *= 2;
232 break;
234 byteSize *= 3;
235 break;
237 byteSize *= 4;
238 break;
240 byteSize *= 4;
241 break;
243 byteSize *= 9;
244 break;
246 byteSize *= 16;
247 break;
248 default:
249 return 0;
250 }
251
252 return byteSize;
253}
ECesiumMetadataComponentType
The component type of a metadata property in EXT_structural_metadata.
ECesiumMetadataTrueType_DEPRECATED
The type of a metadata property in EXT_feature_metadata.
ECesiumMetadataBlueprintType
The Blueprint type that can losslessly represent values of a given property.
ECesiumMetadataPackedGpuType_DEPRECATED
ECesiumMetadataType
The type of a metadata property in EXT_structural_metadata.
Represents the true value type of a metadata value, akin to the property types in EXT_structural_meta...
bool operator!=(const FCesiumMetadataValueType &ValueType) const
ECesiumMetadataType Type
The type of the metadata property or value.
bool bIsArray
Whether or not this represents an array containing elements of the specified types.
FCesiumMetadataValueType(ECesiumMetadataType InType, ECesiumMetadataComponentType InComponentType, bool IsArray=false)
ECesiumMetadataComponentType ComponentType
The component of the metadata property or value.