1
0
mirror of synced 2024-11-30 18:24:39 +01:00

DAE : Fix issues exporting models with only bone indices and no weights.

This commit is contained in:
KillzXGaming 2021-12-10 20:53:47 -05:00
parent 6e64dbc131
commit c6287f2631

View File

@ -387,8 +387,8 @@ namespace Toolbox.Library
if (b > mesh.VertexSkinCount - 1)
continue;
if (vertex.boneWeights.Count > b)
{
//Skip 0 weights
if (vertex.boneWeights.Count > b) {
if (vertex.boneWeights[b] == 0)
continue;
}
@ -399,20 +399,26 @@ namespace Toolbox.Library
else
index = (int)vertex.boneIds[b];
if (index != -1 && index < skeleton?.bones.Count)
//Only map for valid weights/indices
bool hasValidIndex = index != -1 && index < skeleton?.bones.Count;
bool hasValidWeight = vertex.boneWeights.Count > b;
if (hasValidIndex)
bIndices.Add(index);
if (vertex.boneWeights.Count > b)
if (hasValidWeight && hasValidIndex)
bWeights.Add(vertex.boneWeights[b]);
else
bWeights.Add(0);
}
//Rigid bodies with no direct bone indices
if (bIndices.Count == 0 && mesh.BoneIndex != -1) {
HasBoneIds = true;
bIndices.Add(mesh.BoneIndex);
bWeights.Add(1);
}
//Bone indices with no weights directly mapped
if (bWeights.Count == 0 && bIndices.Count > 0)
{
bWeights.Add(1.0f);
}
BoneIndices.Add(bIndices.ToArray());
BoneWeights.Add(bWeights.ToArray());