chore: adjust XModelCommon numeric types

This commit is contained in:
Jan
2024-06-06 19:44:21 +02:00
parent 66c2adacaa
commit d45f0ffab7
8 changed files with 82 additions and 81 deletions

View File

@ -46,10 +46,10 @@ protected:
for (const auto& bone : xmodel.m_bones)
{
m_stream << "BONE " << boneNum << " ";
if (bone.parentIndex < 0)
m_stream << "-1";
if (bone.parentIndex)
m_stream << *bone.parentIndex;
else
m_stream << bone.parentIndex;
m_stream << "-1";
m_stream << " \"" << bone.name << "\"\n";
boneNum++;

View File

@ -227,9 +227,9 @@ namespace
Eigen::Vector3f translation(bone.globalOffset[0], bone.globalOffset[2], -bone.globalOffset[1]);
Eigen::Quaternionf rotation(bone.globalRotation.w, bone.globalRotation.x, bone.globalRotation.z, -bone.globalRotation.y);
if (bone.parentIndex >= 0)
if (bone.parentIndex)
{
const auto& parentBone = xmodel.m_bones[bone.parentIndex];
const auto& parentBone = xmodel.m_bones[*bone.parentIndex];
const auto inverseParentRotation =
Eigen::Quaternionf(parentBone.globalRotation.w, parentBone.globalRotation.x, parentBone.globalRotation.z, -parentBone.globalRotation.y)
.normalized()
@ -249,7 +249,7 @@ namespace
std::vector<unsigned> children;
for (auto maybeChildIndex = 0u; maybeChildIndex < boneCount; maybeChildIndex++)
{
if (xmodel.m_bones[maybeChildIndex].parentIndex == static_cast<int>(boneIndex))
if (xmodel.m_bones[maybeChildIndex].parentIndex && *xmodel.m_bones[maybeChildIndex].parentIndex == boneIndex)
children.emplace_back(maybeChildIndex + m_first_bone_node);
}
if (!children.empty())