From d0fc51c57d65b83eacd828579021b76c9b0dbc62 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Sat, 27 May 2023 19:26:32 -0400 Subject: [PATCH] BFRES : Fix loading bone attributes from 4 byte format when 3 byte stride --- .../FileFormats/BFRES/BfresSwitch.cs | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs b/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs index 54228e84..1f07e891 100644 --- a/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs +++ b/File_Format_Library/FileFormats/BFRES/BfresSwitch.cs @@ -326,17 +326,25 @@ namespace FirstPlugin if (vec4w0.Length > 0) { - v.boneWeights.Add(vec4w0[i].X); - v.boneWeights.Add(vec4w0[i].Y); - v.boneWeights.Add(vec4w0[i].Z); - v.boneWeights.Add(vec4w0[i].W); + if (fshp.VertexSkinCount > 0) + v.boneWeights.Add(vec4w0[i].X); + if (fshp.VertexSkinCount > 1) + v.boneWeights.Add(vec4w0[i].Y); + if (fshp.VertexSkinCount > 2) + v.boneWeights.Add(vec4w0[i].Z); + if (fshp.VertexSkinCount > 3) + v.boneWeights.Add(vec4w0[i].W); } if (vec4i0.Length > 0) { - v.boneIds.Add((int)vec4i0[i].X); - v.boneIds.Add((int)vec4i0[i].Y); - v.boneIds.Add((int)vec4i0[i].Z); - v.boneIds.Add((int)vec4i0[i].W); + if (fshp.VertexSkinCount > 0) + v.boneIds.Add((int)vec4i0[i].X); + if (fshp.VertexSkinCount > 1) + v.boneIds.Add((int)vec4i0[i].Y); + if (fshp.VertexSkinCount > 2) + v.boneIds.Add((int)vec4i0[i].Z); + if (fshp.VertexSkinCount > 3) + v.boneIds.Add((int)vec4i0[i].W); } if (vec4t0.Length > 0)