1
0
mirror of synced 2024-11-12 02:00:50 +01:00

Limit boneids and weight data based on vertex skin count to prevent explosions

This commit is contained in:
KillzXGaming 2020-01-27 19:12:33 -05:00
parent 056fdb3e1a
commit 4c72e33f0f

View File

@ -1684,7 +1684,7 @@ namespace Bfres.Structs
int MaxWeight = 255;
for (int i = 0; i < 4; i++)
{
if (vtx.boneWeights.Count < i + 1)
if (VertexSkinCount < i + 1)
{
weightsA[i] = 0;
MaxWeight = 0;
@ -1707,13 +1707,13 @@ namespace Bfres.Structs
}
}
if (vtx.boneIds.Count >= 1)
if (vtx.boneIds.Count >= 1 && VertexSkinCount >= 1)
indicesA[0] = vtx.boneIds[0];
if (vtx.boneIds.Count >= 2)
if (vtx.boneIds.Count >= 2 && VertexSkinCount >= 2)
indicesA[1] = vtx.boneIds[1];
if (vtx.boneIds.Count >= 3)
if (vtx.boneIds.Count >= 3 && VertexSkinCount >= 3)
indicesA[2] = vtx.boneIds[2];
if (vtx.boneIds.Count >= 4)
if (vtx.boneIds.Count >= 4 && VertexSkinCount >= 4)
indicesA[3] = vtx.boneIds[3];
weights.Add(new Syroot.Maths.Vector4F(weightsA[0], weightsA[1], weightsA[2], weightsA[3]));