Add StructuralMetadataPropertyTypeTraits

This commit is contained in:
Janine Liu 2023-05-15 18:13:47 -04:00
parent 14997fb031
commit 1433243c3d
3 changed files with 1327 additions and 0 deletions

View File

@ -0,0 +1,145 @@
#pragma once
#include "CesiumGltf/StructuralMetadataPropertyType.h"
#include <CesiumUtility/SpanHelper.h>
#include <gsl/span>
#include <cassert>
#include <cstddef>
/**
* @brief A view on an array element of a
* ExtensionExtStructuralMetadataPropertyTableProperty.
*
* Provides utility to retrieve the data stored in the array of
* elements via the array index operator.
*/
namespace CesiumGltf {
namespace StructuralMetadata {
template <typename ElementType> class MetadataArrayView {
public:
MetadataArrayView() : _values{} {}
MetadataArrayView(const gsl::span<const std::byte>& buffer) noexcept
: _values{
CesiumUtility::reintepretCastSpan<const ElementType>(buffer)} {}
const ElementType& operator[](int64_t index) const noexcept {
return _values[index];
}
int64_t size() const noexcept {
return static_cast<int64_t>(_values.size());
}
private:
gsl::span<const ElementType> _values;
};
template <> class MetadataArrayView<bool> {
public:
MetadataArrayView()
: _values{}, _bitOffset{0}, _instanceCount{0} {}
MetadataArrayView(
const gsl::span<const std::byte>& buffer,
int64_t bitOffset,
int64_t instanceCount) noexcept
: _values{buffer},
_bitOffset{bitOffset},
_instanceCount{instanceCount} {}
bool operator[](int64_t index) const noexcept {
index += _bitOffset;
const int64_t byteIndex = index / 8;
const int64_t bitIndex = index % 8;
const int bitValue =
static_cast<int>(_values[byteIndex] >> bitIndex) & 1;
return bitValue == 1;
}
int64_t size() const noexcept { return _instanceCount; }
private:
gsl::span<const std::byte> _values;
int64_t _bitOffset;
int64_t _instanceCount;
};
template <> class MetadataArrayView<std::string_view> {
public:
MetadataArrayView()
: _values{}, _stringOffsets{}, _stringOffsetType{}, _size{0} {}
MetadataArrayView(
const gsl::span<const std::byte>& values,
const gsl::span<const std::byte>& stringOffsets,
StructuralMetadata::PropertyComponentType stringOffsetType,
int64_t size) noexcept
: _values{values},
_stringOffsets{stringOffsets},
_stringOffsetType{stringOffsetType},
_size{size} {}
std::string_view operator[](int64_t index) const noexcept {
const size_t currentOffset = getOffsetFromStringOffsetsBuffer(
index,
_stringOffsets,
_stringOffsetType);
const size_t nextOffset = getOffsetFromStringOffsetsBuffer(
index + 1,
_stringOffsets,
_stringOffsetType);
return std::string_view(
reinterpret_cast<const char*>(_values.data() + currentOffset),
(nextOffset - currentOffset));
}
int64_t size() const noexcept { return _size; }
private:
static size_t getOffsetFromStringOffsetsBuffer(
size_t instance,
const gsl::span<const std::byte>& stringOffsetBuffer,
StructuralMetadata::PropertyComponentType offsetType) noexcept {
switch (offsetType) {
case StructuralMetadata::PropertyComponentType::Uint8: {
assert(instance < stringOffsetBuffer.size() / sizeof(uint8_t));
const uint8_t offset = *reinterpret_cast<const uint8_t*>(
stringOffsetBuffer.data() + instance * sizeof(uint8_t));
return static_cast<size_t>(offset);
}
case StructuralMetadata::PropertyComponentType::Uint16: {
assert(instance < stringOffsetBuffer.size() / sizeof(uint16_t));
const uint16_t offset = *reinterpret_cast<const uint16_t*>(
stringOffsetBuffer.data() + instance * sizeof(uint16_t));
return static_cast<size_t>(offset);
}
case StructuralMetadata::PropertyComponentType::Uint32: {
assert(instance < stringOffsetBuffer.size() / sizeof(uint32_t));
const uint32_t offset = *reinterpret_cast<const uint32_t*>(
stringOffsetBuffer.data() + instance * sizeof(uint32_t));
return static_cast<size_t>(offset);
}
case StructuralMetadata::PropertyComponentType::Uint64: {
assert(instance < stringOffsetBuffer.size() / sizeof(uint64_t));
const uint64_t offset = *reinterpret_cast<const uint64_t*>(
stringOffsetBuffer.data() + instance * sizeof(uint64_t));
return static_cast<size_t>(offset);
}
default:
assert(false && "Offset type has unknown type");
return 0;
}
}
gsl::span<const std::byte> _values;
gsl::span<const std::byte> _stringOffsets;
StructuralMetadata::PropertyComponentType _stringOffsetType;
int64_t _size;
};
} // namespace StructuralMetadata
} // namespace CesiumGltf

View File

@ -0,0 +1,658 @@
#pragma once
#include "CesiumGltf/StructuralMetadataArrayView.h"
#include "CesiumGltf/StructuralMetadataPropertyType.h"
#include <glm/glm.hpp>
#include <cstdint>
#include <type_traits>
namespace CesiumGltf {
namespace StructuralMetadata {
/**
* @brief Check if a C++ type can be represented as a scalar property type
*/
template <typename... T> struct IsMetadataScalar;
template <typename T> struct IsMetadataScalar<T> : std::false_type {};
template <> struct IsMetadataScalar<uint8_t> : std::true_type {};
template <> struct IsMetadataScalar<int8_t> : std::true_type {};
template <> struct IsMetadataScalar<uint16_t> : std::true_type {};
template <> struct IsMetadataScalar<int16_t> : std::true_type {};
template <> struct IsMetadataScalar<uint32_t> : std::true_type {};
template <> struct IsMetadataScalar<int32_t> : std::true_type {};
template <> struct IsMetadataScalar<uint64_t> : std::true_type {};
template <> struct IsMetadataScalar<int64_t> : std::true_type {};
template <> struct IsMetadataScalar<float> : std::true_type {};
template <> struct IsMetadataScalar<double> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as an integer property type
*/
template <typename... T> struct IsMetadataInteger;
template <typename T> struct IsMetadataInteger<T> : std::false_type {};
template <> struct IsMetadataInteger<uint8_t> : std::true_type {};
template <> struct IsMetadataInteger<int8_t> : std::true_type {};
template <> struct IsMetadataInteger<uint16_t> : std::true_type {};
template <> struct IsMetadataInteger<int16_t> : std::true_type {};
template <> struct IsMetadataInteger<uint32_t> : std::true_type {};
template <> struct IsMetadataInteger<int32_t> : std::true_type {};
template <> struct IsMetadataInteger<uint64_t> : std::true_type {};
template <> struct IsMetadataInteger<int64_t> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as a floating-point property
* type.
*/
template <typename... T> struct IsMetadataFloating;
template <typename T> struct IsMetadataFloating<T> : std::false_type {};
template <> struct IsMetadataFloating<float> : std::true_type {};
template <> struct IsMetadataFloating<double> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as a vecN type.
*/
template <typename... T> struct IsMetadataVecN;
template <typename T> struct IsMetadataVecN<T> : std::false_type {};
template <> struct IsMetadataVecN<glm::u8vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::u8vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::u8vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::i8vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::i8vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::i8vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::u16vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::u16vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::u16vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::i16vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::i16vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::i16vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::uvec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::uvec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::uvec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::ivec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::ivec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::ivec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::u64vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::u64vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::u64vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::i64vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::i64vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::i64vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::vec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::vec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::vec4> : std::true_type {};
template <> struct IsMetadataVecN<glm::dvec2> : std::true_type {};
template <> struct IsMetadataVecN<glm::dvec3> : std::true_type {};
template <> struct IsMetadataVecN<glm::dvec4> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as a matN type.
*/
template <typename... T> struct IsMetadataMatN;
template <typename T> struct IsMetadataMatN<T> : std::false_type {};
template <> struct IsMetadataMatN<glm::u8mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::u8mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::u8mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::i8mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::i8mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::i8mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::u16mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::u16mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::u16mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::i16mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::i16mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::i16mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::u32mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::u32mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::u32mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::i32mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::i32mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::i32mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::u64mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::u64mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::u64mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::i64mat2x2> : std::true_type {};
template <> struct IsMetadataMatN<glm::i64mat3x3> : std::true_type {};
template <> struct IsMetadataMatN<glm::i64mat4x4> : std::true_type {};
template <> struct IsMetadataMatN<glm::mat2> : std::true_type {};
template <> struct IsMetadataMatN<glm::mat3> : std::true_type {};
template <> struct IsMetadataMatN<glm::mat4> : std::true_type {};
template <> struct IsMetadataMatN<glm::dmat2> : std::true_type {};
template <> struct IsMetadataMatN<glm::dmat3> : std::true_type {};
template <> struct IsMetadataMatN<glm::dmat4> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as a numeric property, i.e.
* a scalar / vecN / matN type.
*/
template <typename... T> struct IsMetadataNumeric;
template <typename T> struct IsMetadataNumeric<T> {
static constexpr bool value = IsMetadataScalar<T>::value ||
IsMetadataVecN<T>::value ||
IsMetadataMatN<T>::value;
};
/**
* @brief Check if a C++ type can be represented as a boolean property type
*/
template <typename... T> struct IsMetadataBoolean;
template <typename T> struct IsMetadataBoolean<T> : std::false_type {};
template <> struct IsMetadataBoolean<bool> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as a string property type
*/
template <typename... T> struct IsMetadataString;
template <typename T> struct IsMetadataString<T> : std::false_type {};
template <> struct IsMetadataString<std::string_view> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as an array.
*/
template <typename... T> struct IsMetadataArray;
template <typename T> struct IsMetadataArray<T> : std::false_type {};
template <typename T>
struct IsMetadataArray<MetadataArrayView<T>> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as an array of numeric elements
* property type
*/
template <typename... T> struct IsMetadataNumericArray;
template <typename T> struct IsMetadataNumericArray<T> : std::false_type {};
template <typename T> struct IsMetadataNumericArray<MetadataArrayView<T>> {
static constexpr bool value = IsMetadataNumeric<T>::value;
};
/**
* @brief Check if a C++ type can be represented as an array of booleans
* property type
*/
template <typename... T> struct IsMetadataBooleanArray;
template <typename T> struct IsMetadataBooleanArray<T> : std::false_type {};
template <>
struct IsMetadataBooleanArray<MetadataArrayView<bool>> : std::true_type {};
/**
* @brief Check if a C++ type can be represented as an array of strings property
* type
*/
template <typename... T> struct IsMetadataStringArray;
template <typename T> struct IsMetadataStringArray<T> : std::false_type {};
template <>
struct IsMetadataStringArray<MetadataArrayView<std::string_view>>
: std::true_type {};
/**
* @brief Retrieve the component type of a metadata array
*/
template <typename T> struct MetadataArrayType;
template <typename T>
struct MetadataArrayType<CesiumGltf::StructuralMetadata::MetadataArrayView<T>> {
using type = T;
};
/**
* @brief Convert a C++ type to PropertyType and PropertyComponentType
*/
template <typename T> struct TypeToPropertyType;
#pragma region Scalar Property Types
template <> struct TypeToPropertyType<uint8_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<int8_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<uint16_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<int16_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<uint32_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<int32_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<uint64_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<int64_t> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<float> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Scalar;
};
template <> struct TypeToPropertyType<double> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Scalar;
};
#pragma endregion
#pragma region Vec2 Property Types
template <> struct TypeToPropertyType<glm::u8vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::i8vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::u16vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::i16vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::uvec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::ivec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::u64vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::i64vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::vec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Vec2;
};
template <> struct TypeToPropertyType<glm::dvec2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Vec2;
};
#pragma endregion
#pragma region Vec3 Property Types
template <> struct TypeToPropertyType<glm::u8vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::i8vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::u16vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::i16vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::uvec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::ivec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::u64vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::i64vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::vec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Vec3;
};
template <> struct TypeToPropertyType<glm::dvec3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Vec3;
};
#pragma endregion
#pragma region Vec4 Property Types
template <> struct TypeToPropertyType<glm::u8vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::i8vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::u16vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::i16vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::uvec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::ivec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::u64vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::i64vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::vec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Vec4;
};
template <> struct TypeToPropertyType<glm::dvec4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Vec4;
};
#pragma endregion
#pragma region Mat2 Property Types
template <> struct TypeToPropertyType<glm::u8mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::i8mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::u16mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::i16mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::u32mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::i32mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::u64mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::i64mat2x2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::mat2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Mat2;
};
template <> struct TypeToPropertyType<glm::dmat2> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Mat2;
};
#pragma endregion
#pragma region Mat3 Property Types
template <> struct TypeToPropertyType<glm::u8mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::i8mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::u16mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::i16mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::u32mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::i32mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::u64mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::i64mat3x3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::mat3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Mat3;
};
template <> struct TypeToPropertyType<glm::dmat3> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Mat3;
};
#pragma endregion
#pragma region Mat4 Property Types
template <> struct TypeToPropertyType<glm::u8mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint8;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::i8mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int8;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::u16mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint16;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::i16mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int16;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::u32mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint32;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::i32mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int32;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::u64mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Uint64;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::i64mat4x4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Int64;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::mat4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float32;
static constexpr PropertyType value = PropertyType::Mat4;
};
template <> struct TypeToPropertyType<glm::dmat4> {
static constexpr PropertyComponentType component =
PropertyComponentType::Float64;
static constexpr PropertyType value = PropertyType::Mat4;
};
#pragma endregion
template <> struct TypeToPropertyType<bool> {
static constexpr PropertyComponentType component =
PropertyComponentType::None;
static constexpr PropertyType value = PropertyType::Boolean;
};
template <> struct TypeToPropertyType<std::string_view> {
static constexpr PropertyComponentType component =
PropertyComponentType::None;
static constexpr PropertyType value = PropertyType::String;
};
} // namespace StructuralMetadata
} // namespace CesiumGltf

View File

@ -0,0 +1,524 @@
#include "CesiumGltf/StructuralMetadataPropertyTypeTraits.h"
#include <catch2/catch.hpp>
using namespace CesiumGltf::StructuralMetadata;
TEST_CASE("Test StructuralMetadata PropertyTypeTraits") {
SECTION("IsScalar") {
REQUIRE(IsMetadataScalar<uint8_t>::value);
REQUIRE(IsMetadataScalar<int8_t>::value);
REQUIRE(IsMetadataScalar<uint16_t>::value);
REQUIRE(IsMetadataScalar<int16_t>::value);
REQUIRE(IsMetadataScalar<uint32_t>::value);
REQUIRE(IsMetadataScalar<int32_t>::value);
REQUIRE(IsMetadataScalar<uint64_t>::value);
REQUIRE(IsMetadataScalar<int64_t>::value);
REQUIRE(IsMetadataScalar<float>::value);
REQUIRE(IsMetadataScalar<double>::value);
REQUIRE(!IsMetadataScalar<glm::vec3>::value);
REQUIRE(!IsMetadataScalar<glm::mat3>::value);
REQUIRE(!IsMetadataScalar<bool>::value);
REQUIRE(!IsMetadataScalar<std::string_view>::value);
}
SECTION("IsVecN") {
REQUIRE(IsMetadataVecN<glm::u8vec2>::value);
REQUIRE(IsMetadataVecN<glm::u8vec3>::value);
REQUIRE(IsMetadataVecN<glm::u8vec4>::value);
REQUIRE(IsMetadataVecN<glm::i8vec2>::value);
REQUIRE(IsMetadataVecN<glm::i8vec3>::value);
REQUIRE(IsMetadataVecN<glm::i8vec4>::value);
REQUIRE(IsMetadataVecN<glm::u16vec2>::value);
REQUIRE(IsMetadataVecN<glm::u16vec3>::value);
REQUIRE(IsMetadataVecN<glm::u16vec4>::value);
REQUIRE(IsMetadataVecN<glm::i16vec2>::value);
REQUIRE(IsMetadataVecN<glm::i16vec3>::value);
REQUIRE(IsMetadataVecN<glm::i16vec4>::value);
REQUIRE(IsMetadataVecN<glm::uvec2>::value);
REQUIRE(IsMetadataVecN<glm::uvec3>::value);
REQUIRE(IsMetadataVecN<glm::uvec4>::value);
REQUIRE(IsMetadataVecN<glm::ivec2>::value);
REQUIRE(IsMetadataVecN<glm::ivec3>::value);
REQUIRE(IsMetadataVecN<glm::ivec4>::value);
REQUIRE(IsMetadataVecN<glm::u64vec2>::value);
REQUIRE(IsMetadataVecN<glm::u64vec3>::value);
REQUIRE(IsMetadataVecN<glm::u64vec4>::value);
REQUIRE(IsMetadataVecN<glm::i64vec2>::value);
REQUIRE(IsMetadataVecN<glm::i64vec3>::value);
REQUIRE(IsMetadataVecN<glm::i64vec4>::value);
REQUIRE(IsMetadataVecN<glm::vec2>::value);
REQUIRE(IsMetadataVecN<glm::vec3>::value);
REQUIRE(IsMetadataVecN<glm::vec4>::value);
REQUIRE(IsMetadataVecN<glm::dvec2>::value);
REQUIRE(IsMetadataVecN<glm::dvec3>::value);
REQUIRE(IsMetadataVecN<glm::dvec4>::value);
REQUIRE(!IsMetadataVecN<uint8_t>::value);
REQUIRE(!IsMetadataVecN<glm::mat3>::value);
}
SECTION("IsMatN") {
REQUIRE(IsMetadataMatN<glm::u8mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::u8mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::u8mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::i8mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::i8mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::i8mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::u16mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::u16mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::u16mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::i16mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::i16mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::i16mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::u32mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::u32mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::u32mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::i32mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::i32mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::i32mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::u64mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::u64mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::u64mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::i64mat2x2>::value);
REQUIRE(IsMetadataMatN<glm::i64mat3x3>::value);
REQUIRE(IsMetadataMatN<glm::i64mat4x4>::value);
REQUIRE(IsMetadataMatN<glm::mat2>::value);
REQUIRE(IsMetadataMatN<glm::mat3>::value);
REQUIRE(IsMetadataMatN<glm::mat4>::value);
REQUIRE(IsMetadataMatN<glm::dmat2>::value);
REQUIRE(IsMetadataMatN<glm::dmat3>::value);
REQUIRE(IsMetadataMatN<glm::dmat4>::value);
REQUIRE(!IsMetadataMatN<uint8_t>::value);
REQUIRE(!IsMetadataMatN<glm::vec3>::value);
}
SECTION("IsBoolean") {
REQUIRE(IsMetadataBoolean<bool>::value);
REQUIRE(!IsMetadataBoolean<uint8_t>::value);
REQUIRE(!IsMetadataBoolean<std::string_view>::value);
}
SECTION("IsString") {
REQUIRE(IsMetadataString<std::string_view>::value);
REQUIRE(!IsMetadataString<std::string>::value);
}
SECTION("IsNumeric") {
REQUIRE(IsMetadataNumeric<uint8_t>::value);
REQUIRE(IsMetadataNumeric<float>::value);
REQUIRE(IsMetadataNumeric<glm::i8vec2>::value);
REQUIRE(IsMetadataNumeric<glm::dvec4>::value);
REQUIRE(IsMetadataNumeric<glm::u32mat3x3>::value);
REQUIRE(IsMetadataNumeric<glm::mat3>::value);
REQUIRE(!IsMetadataNumeric<bool>::value);
REQUIRE(!IsMetadataNumeric<std::string_view>::value);
}
SECTION("IsNumericArray") {
REQUIRE(IsMetadataNumericArray<MetadataArrayView<uint32_t>>::value);
REQUIRE(IsMetadataNumericArray<MetadataArrayView<glm::vec3>>::value);
REQUIRE(IsMetadataNumericArray<MetadataArrayView<glm::mat4>>::value);
REQUIRE(!IsMetadataNumericArray<MetadataArrayView<bool>>::value);
}
SECTION("IsBooleanArray") {
REQUIRE(IsMetadataBooleanArray<MetadataArrayView<bool>>::value);
REQUIRE(!IsMetadataBooleanArray<MetadataArrayView<uint8_t>>::value);
}
SECTION("IsStringArray") {
REQUIRE(IsMetadataStringArray<MetadataArrayView<std::string_view>>::value);
REQUIRE(!IsMetadataStringArray<MetadataArrayView<std::string>>::value);
REQUIRE(!IsMetadataStringArray<MetadataArrayView<uint32_t>>::value);
}
SECTION("ArrayType") {
using type = MetadataArrayType<MetadataArrayView<uint32_t>>::type;
REQUIRE(std::is_same_v<type, uint32_t>);
}
SECTION("TypeToPropertyType scalar") {
REQUIRE(TypeToPropertyType<uint8_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<uint8_t>::component == PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<int8_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<int8_t>::component == PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<uint16_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<uint16_t>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<int16_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<int16_t>::component == PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<uint32_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<uint32_t>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<int32_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<int32_t>::component == PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<uint64_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<uint64_t>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<int64_t>::value == PropertyType::Scalar);
REQUIRE(
TypeToPropertyType<int64_t>::component == PropertyComponentType::Int64);
}
SECTION("TypeToPropertyType vecN") {
// Vec2
REQUIRE(TypeToPropertyType<glm::u8vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::u8vec2>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::i8vec2>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::u16vec2>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::i16vec2>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::uvec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::uvec2>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::ivec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::ivec2>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::u64vec2>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::i64vec2>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::vec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::vec2>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dvec2>::value == PropertyType::Vec2);
REQUIRE(
TypeToPropertyType<glm::dvec2>::component ==
PropertyComponentType::Float64);
// Vec3
REQUIRE(TypeToPropertyType<glm::u8vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::u8vec3>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::i8vec3>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::u16vec3>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::i16vec3>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::uvec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::uvec3>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::ivec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::ivec3>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::u64vec3>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::i64vec3>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::vec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::vec3>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dvec3>::value == PropertyType::Vec3);
REQUIRE(
TypeToPropertyType<glm::dvec3>::component ==
PropertyComponentType::Float64);
// Vec4
REQUIRE(TypeToPropertyType<glm::u8vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::u8vec4>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::i8vec4>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::u16vec4>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::i16vec4>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::uvec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::uvec4>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::ivec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::ivec4>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::u64vec4>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::i64vec4>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::vec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::vec4>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dvec4>::value == PropertyType::Vec4);
REQUIRE(
TypeToPropertyType<glm::dvec4>::component ==
PropertyComponentType::Float64);
}
SECTION("TypeToPropertyType matN") {
// Mat2
REQUIRE(TypeToPropertyType<glm::u8mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::u8mat2x2>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::i8mat2x2>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::u16mat2x2>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::i16mat2x2>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::u32mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::u32mat2x2>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::i32mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::i32mat2x2>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::u64mat2x2>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64mat2x2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::i64mat2x2>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::mat2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::mat2>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dmat2>::value == PropertyType::Mat2);
REQUIRE(
TypeToPropertyType<glm::dmat2>::component ==
PropertyComponentType::Float64);
// Mat3
REQUIRE(TypeToPropertyType<glm::u8mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::u8mat3x3>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::i8mat3x3>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::u16mat3x3>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::i16mat3x3>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::u32mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::u32mat3x3>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::i32mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::i32mat3x3>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::u64mat3x3>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64mat3x3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::i64mat3x3>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::mat3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::mat3>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dmat3>::value == PropertyType::Mat3);
REQUIRE(
TypeToPropertyType<glm::dmat3>::component ==
PropertyComponentType::Float64);
// Mat4
REQUIRE(TypeToPropertyType<glm::u8mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::u8mat4x4>::component ==
PropertyComponentType::Uint8);
REQUIRE(TypeToPropertyType<glm::i8mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::i8mat4x4>::component ==
PropertyComponentType::Int8);
REQUIRE(TypeToPropertyType<glm::u16mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::u16mat4x4>::component ==
PropertyComponentType::Uint16);
REQUIRE(TypeToPropertyType<glm::i16mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::i16mat4x4>::component ==
PropertyComponentType::Int16);
REQUIRE(TypeToPropertyType<glm::u32mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::u32mat4x4>::component ==
PropertyComponentType::Uint32);
REQUIRE(TypeToPropertyType<glm::i32mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::i32mat4x4>::component ==
PropertyComponentType::Int32);
REQUIRE(TypeToPropertyType<glm::u64mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::u64mat4x4>::component ==
PropertyComponentType::Uint64);
REQUIRE(TypeToPropertyType<glm::i64mat4x4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::i64mat4x4>::component ==
PropertyComponentType::Int64);
REQUIRE(TypeToPropertyType<glm::mat4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::mat4>::component ==
PropertyComponentType::Float32);
REQUIRE(TypeToPropertyType<glm::dmat4>::value == PropertyType::Mat4);
REQUIRE(
TypeToPropertyType<glm::dmat4>::component ==
PropertyComponentType::Float64);
}
SECTION("TypeToPropertyType boolean") {
REQUIRE(TypeToPropertyType<bool>::value == PropertyType::Boolean);
REQUIRE(TypeToPropertyType<bool>::component == PropertyComponentType::None);
}
SECTION("TypeToPropertyType string") {
REQUIRE(
TypeToPropertyType<std::string_view>::value == PropertyType::String);
REQUIRE(
TypeToPropertyType<std::string_view>::component ==
PropertyComponentType::None);
}
}