HACK: Temporarily disabled support for padding bone matrices when insufficient matrices are detected

This commit is contained in:
Kah Wei 2023-02-01 11:30:23 +08:00
parent 4aa032833c
commit 5abcf49271
2 changed files with 25 additions and 16 deletions

View File

@ -68,10 +68,10 @@ namespace SHADE
ReadMeshData(file, asset.meshHeaders, asset.meshes);
ReadAnimData(file, asset.animHeaders, asset.anims);
for (auto& mesh : asset.meshes)
/*for (auto& mesh : asset.meshes)
{
mesh->BoneCount = asset.rig.nodeDataCollection.size();
}
}*/
// Not eof yet, animation exists
if (file.peek() != EOF)

View File

@ -608,25 +608,34 @@ namespace SHADE
boneMatrixIndices.emplace_back(static_cast<uint32_t>(boneMatrixData.size()));
auto animator = SHComponentManager::GetComponent_s<SHAnimatorComponent>(rendId);
auto mesh = renderable->GetMesh();
const int BONE_COUNT = static_cast<int>(mesh->BoneCount);
int extraMatricesToAdd = BONE_COUNT;
if (animator)
{
// Add matrices
const auto& MATRICES = animator->GetBoneMatrices();
if (MATRICES.size() <= BONE_COUNT)
{
boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
extraMatricesToAdd = std::max({0, BONE_COUNT - static_cast<int>(MATRICES.size())});
}
boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
}
// If we need to patch up with more matrices, add it
if (extraMatricesToAdd > 0)
{
boneMatrixData.insert(boneMatrixData.end(), extraMatricesToAdd, SHMatrix::Identity);
}
//auto mesh = renderable->GetMesh();
//const int BONE_COUNT = static_cast<int>(mesh->BoneCount);
//int extraMatricesToAdd = BONE_COUNT;
//if (animator)
//{
// const auto& MATRICES = animator->GetBoneMatrices();
// boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
// // Add matrices
// const auto& MATRICES = animator->GetBoneMatrices();
// if (MATRICES.size() <= BONE_COUNT)
// {
// boneMatrixData.insert(boneMatrixData.end(), MATRICES.cbegin(), MATRICES.cend());
// extraMatricesToAdd = std::max({0, BONE_COUNT - static_cast<int>(MATRICES.size())});
// }
//}
//// If we need to patch up with more matrices, add it
//if (extraMatricesToAdd > 0)
//{
// boneMatrixData.insert(boneMatrixData.end(), extraMatricesToAdd, SHMatrix::Identity);
//}
}
}
}