1
0
mirror of synced 2024-11-27 17:00:50 +01:00

BFRES : Fix long lasting bug where tangents load/create wrong from 1 skin count or less.

This commit is contained in:
KillzXGaming 2023-10-26 20:20:58 -04:00
parent 3b24eb253b
commit d50379879f
3 changed files with 15 additions and 0 deletions

View File

@ -290,6 +290,8 @@ namespace Bfres.Structs
{
vertices[v].pos = Vector3.TransformPosition(vertices[v].pos, SingleBind);
vertices[v].nrm = Vector3.TransformNormal(vertices[v].nrm, SingleBind);
vertices[v].tan.Xyz = Vector3.TransformNormal(vertices[v].tan.Xyz, SingleBind);
vertices[v].bitan.Xyz = Vector3.TransformNormal(vertices[v].bitan.Xyz, SingleBind);
}
else if (VertexSkinCount == 1)
{
@ -301,6 +303,8 @@ namespace Bfres.Structs
vertices[v].pos = Vector3.TransformPosition(vertices[v].pos, SingleBindLocal);
vertices[v].nrm = Vector3.TransformNormal(vertices[v].nrm, SingleBindLocal);
vertices[v].tan.Xyz = Vector3.TransformNormal(vertices[v].tan.Xyz, SingleBindLocal);
vertices[v].bitan.Xyz = Vector3.TransformNormal(vertices[v].bitan.Xyz, SingleBindLocal);
}
}
@ -2076,6 +2080,8 @@ namespace Bfres.Structs
vtx.pos = TransformLocal(vtx.pos, boneId, VertexSkinCount == 1);
vtx.nrm = TransformLocal(vtx.nrm, boneId, VertexSkinCount == 1, false);
vtx.tan.Xyz = TransformLocal(vtx.tan.Xyz, boneId, VertexSkinCount == 1, false);
vtx.bitan.Xyz = TransformLocal(vtx.bitan.Xyz, boneId, VertexSkinCount == 1, false);
}
verts.Add(new Syroot.Maths.Vector4F(vtx.pos.X, vtx.pos.Y, vtx.pos.Z, 1.0f));

View File

@ -394,6 +394,8 @@ namespace FirstPlugin
Matrix4 sb = model.Skeleton.bones[boneIndex].Transform;
v.pos = Vector3.TransformPosition(v.pos, sb);
v.nrm = Vector3.TransformNormal(v.nrm, sb);
v.tan.Xyz = Vector3.TransformNormal(v.tan.Xyz, sb);
v.bitan.Xyz = Vector3.TransformNormal(v.bitan.Xyz, sb);
}
}
if (fshp.VertexSkinCount == 0)
@ -403,6 +405,8 @@ namespace FirstPlugin
Matrix4 NoBindFix = model.Skeleton.bones[boneIndex].Transform;
v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
v.tan.Xyz = Vector3.TransformNormal(v.tan.Xyz, NoBindFix);
v.bitan.Xyz = Vector3.TransformNormal(v.bitan.Xyz, NoBindFix);
}
fshp.vertices.Add(v);
}

View File

@ -307,7 +307,10 @@ namespace FirstPlugin
Matrix4 sb = model.Skeleton.bones[boneIndex].Transform;
v.pos = Vector3.TransformPosition(v.pos, sb);
v.nrm = Vector3.TransformNormal(v.nrm, sb);
v.tan.Xyz = Vector3.TransformNormal(v.tan.Xyz, sb);
v.bitan.Xyz = Vector3.TransformNormal(v.bitan.Xyz, sb);
}
}
if (fshp.VertexSkinCount == 0)
{
@ -319,6 +322,8 @@ namespace FirstPlugin
Matrix4 NoBindFix = model.Skeleton.bones[boneIndex].Transform;
v.pos = Vector3.TransformPosition(v.pos, NoBindFix);
v.nrm = Vector3.TransformNormal(v.nrm, NoBindFix);
v.tan.Xyz = Vector3.TransformNormal(v.tan.Xyz, NoBindFix);
v.bitan.Xyz = Vector3.TransformNormal(v.bitan.Xyz, NoBindFix);
}
}
catch //Matrix failed. Print the coordinate data of the bone