chore: fix linux build

This commit is contained in:
Jan 2024-04-01 20:48:39 +02:00
parent 0d96213f21
commit 1bc1c12244
No known key found for this signature in database
GPG Key ID: 44B581F78FF5C57C
4 changed files with 21 additions and 18 deletions

View File

@ -1,7 +1,7 @@
#include "AssetLoaderXModel.h"
#include "Game/T6/XModel/JsonXModelLoader.h"
#include "Game/T6/T6.h"
#include "Game/T6/XModel/JsonXModelLoader.h"
#include "Pool/GlobalAssetPool.h"
#include <cstring>

View File

@ -6,6 +6,7 @@
#include <format>
#include <iostream>
#include <nlohmann/json.hpp>
#include <vector>
using namespace nlohmann;
using namespace T6;
@ -109,7 +110,7 @@ namespace T6
std::set<XAssetInfoGeneric*> dependenciesSet;
const JsonLoader loader(stream, *memory, *manager, dependenciesSet);
dependencies.assign_range(dependenciesSet);
dependencies.assign(dependenciesSet.cbegin(), dependenciesSet.cend());
return loader.Load(xmodel);
}

View File

@ -22,7 +22,7 @@ std::optional<std::string> TextOutput::CreateBufferUri(const void* buffer, const
std::string output(base64BufferSize, '\0');
std::memcpy(output.data(), &GLTF_DATA_URI_PREFIX, URI_PREFIX_LENGTH);
std::memcpy(output.data(), GLTF_DATA_URI_PREFIX, URI_PREFIX_LENGTH);
unsigned long outLength = base64Length;
base64_encode(static_cast<const unsigned char*>(buffer), bufferSize, &output[URI_PREFIX_LENGTH], &outLength);

View File

@ -76,11 +76,6 @@ namespace
gltf.meshes->emplace_back(std::move(mesh));
}
static unsigned CreateNodeIndexFromBoneIndex(const unsigned boneIndex)
{
return boneIndex + NODE_FIRST_INDEX_BONES;
}
void CreateSkeletonNodes(JsonRoot& gltf) const
{
if (m_bones.empty())
@ -89,20 +84,22 @@ namespace
if (!gltf.nodes.has_value())
gltf.nodes.emplace();
for (const auto [boneIndex, bone] : std::views::enumerate(m_bones))
const auto boneCount = m_bones.size();
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
{
JsonNode boneNode;
const auto& bone = m_bones[boneIndex];
boneNode.name = bone.name;
boneNode.translation = std::to_array(bone.globalOffset);
boneNode.rotation = std::to_array({bone.globalRotation.m_x, bone.globalRotation.m_y, bone.globalRotation.m_z, bone.globalRotation.m_w});
const auto isParentOf = [this, boneIndex](const unsigned b)
std::vector<unsigned> children;
for (auto maybeChildIndex = 0u; maybeChildIndex < boneCount; maybeChildIndex++)
{
return m_bones[b].parentIndex == boneIndex;
};
auto children = std::ranges::iota_view(0u, m_bones.size()) | std::views::filter(isParentOf)
| std::views::transform(CreateNodeIndexFromBoneIndex) | std::ranges::to<std::vector<unsigned>>();
if (m_bones[maybeChildIndex].parentIndex == static_cast<int>(boneIndex))
children.emplace_back(boneIndex + NODE_FIRST_INDEX_BONES);
}
if (!children.empty())
boneNode.children = std::move(children);
@ -115,12 +112,17 @@ namespace
if (m_bones.empty())
return;
JsonSkin skin;
skin.joints =
std::ranges::iota_view(0u, m_bones.size()) | std::views::transform(CreateNodeIndexFromBoneIndex) | std::ranges::to<std::vector<unsigned>>();
if (!gltf.skins.has_value())
gltf.skins.emplace();
JsonSkin skin;
const auto boneCount = m_bones.size();
skin.joints.reserve(boneCount);
for (auto boneIndex = 0u; boneIndex < boneCount; boneIndex++)
skin.joints.emplace_back(boneIndex + NODE_FIRST_INDEX_BONES);
gltf.skins->emplace_back(std::move(skin));
}