/*
-* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+* Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
*/
#include "dali-scene-loader/internal/gltf2-asset.h"
-#include "dali/public-api/math/matrix.h"
#include <algorithm>
#include <map>
+#include "dali/public-api/math/matrix.h"
-#define ENUM_STRING_MAPPING(t, x) { #x, t::x }
+#define ENUM_STRING_MAPPING(t, x) \
+ { \
+#x, t::x \
+ }
using namespace Dali;
{
namespace
{
-
constexpr uint32_t ACCESSOR_TYPE_ELEMENT_COUNT[]{
1,
2,
4,
9,
16,
- static_cast<uint32_t>(-1)
-};
+ static_cast<uint32_t>(-1)};
const std::map<std::string_view, AccessorType::Type> ACCESSOR_TYPES{
ENUM_STRING_MAPPING(AccessorType, SCALAR),
ENUM_STRING_MAPPING(Animation::Channel::Target::Type, WEIGHTS),
};
-}
+} // namespace
bool Component::IsUnsigned(Type t)
{
uint32_t Component::Size(Type t)
{
- switch (t)
+ switch(t)
{
- case BYTE:
- case UNSIGNED_BYTE:
- return 1;
- case SHORT:
- case UNSIGNED_SHORT:
- return 2;
- case UNSIGNED_INT:
- case FLOAT:
- return 4;
- default:
- return -1;
+ case BYTE:
+ case UNSIGNED_BYTE:
+ return 1;
+ case SHORT:
+ case UNSIGNED_SHORT:
+ return 2;
+ case UNSIGNED_INT:
+ case FLOAT:
+ return 4;
+ default:
+ return -1;
}
}
AccessorType::Type AccessorType::FromString(const char* s, size_t len)
{
auto iFind = ACCESSOR_TYPES.find(std::string_view(s, len));
- if (iFind != ACCESSOR_TYPES.end())
+ if(iFind != ACCESSOR_TYPES.end())
{
return iFind->second;
}
AlphaMode::Type AlphaMode::FromString(const char* s, size_t len)
{
auto iFind = ALPHA_MODE_TYPES.find(std::string_view(s, len));
- if (iFind != ALPHA_MODE_TYPES.end())
+ if(iFind != ALPHA_MODE_TYPES.end())
{
return iFind->second;
}
Attribute::Type Attribute::FromString(const char* s, size_t len)
{
auto iFind = ATTRIBUTE_TYPES.find(std::string_view(s, len));
- if (iFind != ATTRIBUTE_TYPES.end())
+ if(iFind != ATTRIBUTE_TYPES.end())
{
return iFind->second;
}
Animation::Sampler::Interpolation::Type Animation::Sampler::Interpolation::FromString(const char* s, size_t len)
{
auto iFind = ANIMATION_SAMPLER_INTERPOLATION.find(std::string_view(s, len));
- if (iFind != ANIMATION_SAMPLER_INTERPOLATION.end())
+ if(iFind != ANIMATION_SAMPLER_INTERPOLATION.end())
{
return iFind->second;
}
std::transform(target.begin(), target.end(), target.begin(), ::toupper);
auto iFind = ANIMATION_CHANNEL_TARGET_PATH_TYPES.find(std::string_view(target.c_str(), len));
- if (iFind != ANIMATION_CHANNEL_TARGET_PATH_TYPES.end())
+ if(iFind != ANIMATION_CHANNEL_TARGET_PATH_TYPES.end())
{
return iFind->second;
}
m.GetTransformComponents(mTranslation, mRotation, mScale);
}
-Quaternion ReadQuaternion(const json_value_s & j)
+Quaternion ReadQuaternion(const json_value_s& j)
{
- return Quaternion(ReadDaliVector<Vector4>(j));
+ return Quaternion(ReadDaliVector<Vector4>(j));
}
-}
+} // namespace gltf2