mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-04-21 08:35:43 +00:00
chore: fix linux build
This commit is contained in:
parent
0d96213f21
commit
1bc1c12244
@ -1,7 +1,7 @@
|
|||||||
#include "AssetLoaderXModel.h"
|
#include "AssetLoaderXModel.h"
|
||||||
|
|
||||||
#include "Game/T6/XModel/JsonXModelLoader.h"
|
|
||||||
#include "Game/T6/T6.h"
|
#include "Game/T6/T6.h"
|
||||||
|
#include "Game/T6/XModel/JsonXModelLoader.h"
|
||||||
#include "Pool/GlobalAssetPool.h"
|
#include "Pool/GlobalAssetPool.h"
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <format>
|
#include <format>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
using namespace nlohmann;
|
using namespace nlohmann;
|
||||||
using namespace T6;
|
using namespace T6;
|
||||||
@ -109,7 +110,7 @@ namespace T6
|
|||||||
std::set<XAssetInfoGeneric*> dependenciesSet;
|
std::set<XAssetInfoGeneric*> dependenciesSet;
|
||||||
const JsonLoader loader(stream, *memory, *manager, dependenciesSet);
|
const JsonLoader loader(stream, *memory, *manager, dependenciesSet);
|
||||||
|
|
||||||
dependencies.assign_range(dependenciesSet);
|
dependencies.assign(dependenciesSet.cbegin(), dependenciesSet.cend());
|
||||||
|
|
||||||
return loader.Load(xmodel);
|
return loader.Load(xmodel);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ std::optional<std::string> TextOutput::CreateBufferUri(const void* buffer, const
|
|||||||
|
|
||||||
std::string output(base64BufferSize, '\0');
|
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;
|
unsigned long outLength = base64Length;
|
||||||
base64_encode(static_cast<const unsigned char*>(buffer), bufferSize, &output[URI_PREFIX_LENGTH], &outLength);
|
base64_encode(static_cast<const unsigned char*>(buffer), bufferSize, &output[URI_PREFIX_LENGTH], &outLength);
|
||||||
|
@ -76,11 +76,6 @@ namespace
|
|||||||
gltf.meshes->emplace_back(std::move(mesh));
|
gltf.meshes->emplace_back(std::move(mesh));
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned CreateNodeIndexFromBoneIndex(const unsigned boneIndex)
|
|
||||||
{
|
|
||||||
return boneIndex + NODE_FIRST_INDEX_BONES;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CreateSkeletonNodes(JsonRoot& gltf) const
|
void CreateSkeletonNodes(JsonRoot& gltf) const
|
||||||
{
|
{
|
||||||
if (m_bones.empty())
|
if (m_bones.empty())
|
||||||
@ -89,20 +84,22 @@ namespace
|
|||||||
if (!gltf.nodes.has_value())
|
if (!gltf.nodes.has_value())
|
||||||
gltf.nodes.emplace();
|
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;
|
JsonNode boneNode;
|
||||||
|
const auto& bone = m_bones[boneIndex];
|
||||||
|
|
||||||
boneNode.name = bone.name;
|
boneNode.name = bone.name;
|
||||||
boneNode.translation = std::to_array(bone.globalOffset);
|
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});
|
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;
|
if (m_bones[maybeChildIndex].parentIndex == static_cast<int>(boneIndex))
|
||||||
};
|
children.emplace_back(boneIndex + NODE_FIRST_INDEX_BONES);
|
||||||
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 (!children.empty())
|
if (!children.empty())
|
||||||
boneNode.children = std::move(children);
|
boneNode.children = std::move(children);
|
||||||
|
|
||||||
@ -115,12 +112,17 @@ namespace
|
|||||||
if (m_bones.empty())
|
if (m_bones.empty())
|
||||||
return;
|
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())
|
if (!gltf.skins.has_value())
|
||||||
gltf.skins.emplace();
|
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));
|
gltf.skins->emplace_back(std::move(skin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user