chore: update code style

This commit is contained in:
Jan 2025-01-26 22:35:27 +01:00
parent aab510c917
commit e13eb256bb
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
2 changed files with 21 additions and 23 deletions

View File

@ -286,7 +286,7 @@ namespace
common.m_vertices.emplace_back(vertex); common.m_vertices.emplace_back(vertex);
XModelVertexBoneWeights vertexWeights{common.m_bone_weight_data.weights.size(), 0u}; XModelVertexBoneWeights vertexWeights{.weightOffset = common.m_bone_weight_data.weights.size(), .weightCount = 0u};
for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++) for (auto i = 0u; i < std::extent_v<decltype(joints)>; i++)
{ {
if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon()) if (std::abs(weights[i]) < std::numeric_limits<float>::epsilon())
@ -315,12 +315,12 @@ namespace
throw GltfLoadException("Requires primitives attribute POSITION"); throw GltfLoadException("Requires primitives attribute POSITION");
AccessorsForVertex accessorsForVertex{ AccessorsForVertex accessorsForVertex{
*primitives.attributes.POSITION, .positionAccessor = *primitives.attributes.POSITION,
primitives.attributes.NORMAL, .normalAccessor = primitives.attributes.NORMAL,
primitives.attributes.COLOR_0, .colorAccessor = primitives.attributes.COLOR_0,
primitives.attributes.TEXCOORD_0, .uvAccessor = primitives.attributes.TEXCOORD_0,
primitives.attributes.JOINTS_0, .jointsAccessor = primitives.attributes.JOINTS_0,
primitives.attributes.WEIGHTS_0, .weightsAccessor = primitives.attributes.WEIGHTS_0,
}; };
const auto existingVertices = m_vertex_offset_for_accessors.find(accessorsForVertex); const auto existingVertices = m_vertex_offset_for_accessors.find(accessorsForVertex);
@ -328,7 +328,7 @@ namespace
existingVertices == m_vertex_offset_for_accessors.end() ? CreateVertices(common, accessorsForVertex) : existingVertices->second; existingVertices == m_vertex_offset_for_accessors.end() ? CreateVertices(common, accessorsForVertex) : existingVertices->second;
// clang-format off // clang-format off
auto* indexAccessor = GetAccessorForIndex( const auto* indexAccessor = GetAccessorForIndex(
"INDICES", "INDICES",
primitives.indices, primitives.indices,
{JsonAccessorType::SCALAR}, {JsonAccessorType::SCALAR},
@ -552,7 +552,7 @@ namespace
common.m_bones.resize(skinBoneOffset + skin.joints.size()); common.m_bones.resize(skinBoneOffset + skin.joints.size());
constexpr float defaultTranslation[3]{0.0f, 0.0f, 0.0f}; constexpr float defaultTranslation[3]{0.0f, 0.0f, 0.0f};
constexpr XModelQuaternion defaultRotation{0.0f, 0.0f, 0.0f, 1.0f}; constexpr XModelQuaternion defaultRotation{.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f};
constexpr float defaultScale[3]{1.0f, 1.0f, 1.0f}; constexpr float defaultScale[3]{1.0f, 1.0f, 1.0f};
return ConvertJoint(jRoot, skin, common, skinBoneOffset, rootNode, std::nullopt, defaultTranslation, defaultRotation, defaultScale); return ConvertJoint(jRoot, skin, common, skinBoneOffset, rootNode, std::nullopt, defaultTranslation, defaultRotation, defaultScale);

View File

@ -22,7 +22,6 @@
#include JSON_HEADER #include JSON_HEADER
#include "Asset/AssetRegistration.h" #include "Asset/AssetRegistration.h"
#include "ObjLoading.h"
#include "Utils/QuatInt16.h" #include "Utils/QuatInt16.h"
#include "Utils/StringUtils.h" #include "Utils/StringUtils.h"
#include "XModel/Gltf/GltfBinInput.h" #include "XModel/Gltf/GltfBinInput.h"
@ -44,7 +43,6 @@
#include <format> #include <format>
#include <iostream> #include <iostream>
#include <numeric> #include <numeric>
#include <set>
#include <vector> #include <vector>
using namespace GAME; using namespace GAME;
@ -146,17 +144,17 @@ namespace
assert(common.m_vertex_bone_weights.size() == common.m_vertices.size()); assert(common.m_vertex_bone_weights.size() == common.m_vertices.size());
XModelBone rootBone{ XModelBone rootBone{
"root", .name = "root",
std::nullopt, .parentIndex = std::nullopt,
{1.0f, 1.0f, 1.0f}, .scale = {1.0f, 1.0f, 1.0f},
{0.0f, 0.0f, 0.0f}, .globalOffset = {0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f}, .localOffset = {0.0f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}, .globalRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
{0.0f, 0.0f, 0.0f, 1.0f}, .localRotation = {.x = 0.0f, .y = 0.0f, .z = 0.0f, .w = 1.0f},
}; };
common.m_bones.emplace_back(rootBone); common.m_bones.emplace_back(rootBone);
XModelBoneWeight rootWeight{0, 1.0f}; XModelBoneWeight rootWeight{.boneIndex = 0, .weight = 1.0f};
common.m_bone_weight_data.weights.emplace_back(rootWeight); common.m_bone_weight_data.weights.emplace_back(rootWeight);
for (auto& vertexBoneWeights : common.m_vertex_bone_weights) for (auto& vertexBoneWeights : common.m_vertex_bone_weights)
@ -401,7 +399,7 @@ namespace
} }
static std::vector<std::optional<size_t>> static std::vector<std::optional<size_t>>
GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common) GetRigidBoneIndicesForTris(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
{ {
std::vector<std::optional<size_t>> rigidBoneIndexForTri; std::vector<std::optional<size_t>> rigidBoneIndexForTri;
rigidBoneIndexForTri.reserve(surface.triCount); rigidBoneIndexForTri.reserve(surface.triCount);
@ -422,7 +420,7 @@ namespace
return rigidBoneIndexForTri; return rigidBoneIndexForTri;
} }
static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common) static void ReorderRigidTrisByBoneIndex(const std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
{ {
const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common); const auto rigidBoneIndexForTri = GetRigidBoneIndicesForTris(vertexIndices, surface, common);
@ -512,7 +510,7 @@ namespace
// TODO // TODO
} }
static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, XSurface& surface, const XModelCommon& common) static void ReorderVerticesByWeightCount(std::vector<size_t>& vertexIndices, const XSurface& surface, const XModelCommon& common)
{ {
if (common.m_bone_weight_data.weights.empty()) if (common.m_bone_weight_data.weights.empty())
return; return;