1
0
mirror of synced 2024-11-28 17:30:57 +01:00

More fixes to skin count limiter

This commit is contained in:
KillzXGaming 2019-05-27 20:48:06 -04:00
parent 0d7dfb734b
commit 623098b3b5
4 changed files with 21 additions and 7 deletions

View File

@ -611,12 +611,17 @@ namespace Bfres.Structs
List<FSHP> Matches = shapes.Where(p => String.Equals(p.Name,
csvModel.objects[i].ObjectName, StringComparison.CurrentCulture)).ToList();
if (Matches != null)
if (Matches != null && Matches.Count > 0)
{
//Match the skin count setting if names match
//Only one match should be found as shapes can't have duped names
csvModel.objects[i].VertexSkinCount = ((FSHP)Matches[0]).VertexSkinCount;
}
else
{
//Else just match the first object
csvModel.objects[i].VertexSkinCount = shapes[0].VertexSkinCount;
}
}
}
@ -727,12 +732,17 @@ namespace Bfres.Structs
List<FSHP> Matches = shapes.Where(p => String.Equals(p.Name,
assimp.objects[i].ObjectName, StringComparison.CurrentCulture)).ToList();
if (Matches != null)
if (Matches != null && Matches.Count > 0)
{
//Match the skin count setting if names match
//Only one match should be found as shapes can't have duped names
assimp.objects[i].VertexSkinCount = ((FSHP)Matches[0]).VertexSkinCount;
}
else
{
//Else just match the first object
assimp.objects[i].VertexSkinCount = shapes[0].VertexSkinCount;
}
}
}
@ -1018,7 +1028,7 @@ namespace Bfres.Structs
progressBar.Task = $"Creating Index list. Mesh: {obj.ObjectName}";
progressBar.Refresh();
shape.CreateIndexList(obj, this);
shape.CreateIndexList(obj, this, ForceSkinInfluence, ForceSkinInfluenceMax);
progressBar.Task = $"Applying Settings. Mesh: {obj.ObjectName}";
progressBar.Refresh();
@ -1036,7 +1046,7 @@ namespace Bfres.Structs
if (settings.LimitSkinCount)
shape.VertexSkinCount = obj.GetMaxSkinInfluenceCount();
if (shape.VertexSkinCount == 1)
if (shape.VertexSkinCount == 1 && shape.BoneIndices.Count > 0)
{
int boneIndex = shape.BoneIndices[0];
shape.BoneIndex = boneIndex;

View File

@ -726,7 +726,7 @@ namespace Bfres.Structs
UpdateVertexData();
}
}
public void CreateIndexList(STGenericObject ob, FMDL mdl = null)
public void CreateIndexList(STGenericObject ob, FMDL mdl = null, bool ForceSkinLimt = false, int LimitAmount = 4)
{
BoneIndices = new List<ushort>();
@ -742,6 +742,9 @@ namespace Bfres.Structs
}
}
if (ForceSkinLimt && LimitAmount > 0)
BoneIndices.Add((ushort)0);
foreach (STBone bone in mdl.Skeleton.bones)
{
foreach (string bnam in boneNames)
@ -751,7 +754,8 @@ namespace Bfres.Structs
int index = boneNames.IndexOf(bone.Text);
STConsole.WriteLine($"Adding bone to shape index list! {bone.Text} {index}");
BoneIndices.Add((ushort)index);
if (!BoneIndices.Contains((ushort)index))
BoneIndices.Add((ushort)index);
}
}
}
@ -839,7 +843,7 @@ namespace Bfres.Structs
{
for (int i = 0; i < ForcedSkinAmount; i++)
{
if (v.boneIds.Count < ForcedSkinAmount)
if (v.boneIds.Count < ob.VertexSkinCount)
{
v.boneIds.Add(0);
v.boneWeights.Add(1);