Skip to content

Commit 4875c1a

Browse files
committed
Update v3.0.6.7
2 parents 903d33b + b6b6e57 commit 4875c1a

File tree

4 files changed

+50
-9
lines changed

4 files changed

+50
-9
lines changed

xivModdingFramework/Models/DataContainers/TTModel.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,8 @@ public static TTModel LoadFromFile(string filePath, Action<bool, string> logging
16421642
// Convert the model to FFXIV's internal weirdness.
16431643
ModelModifiers.MakeImportReady(model, loggingFunction);
16441644

1645+
ModelModifiers.CleanWeights(model, loggingFunction);
1646+
16451647
return model;
16461648
}
16471649

@@ -2907,17 +2909,39 @@ public static void CheckCommonUserErrors(TTModel model, Action<bool, string> log
29072909

29082910
bool anyAlpha = false;
29092911
bool anyColor = false;
2910-
bool anyColor2 = false;
2912+
bool fullWhiteColor2 = true;
29112913
bool anyWeirdUV1s = false;
29122914
bool anyWeirdUV2s = false;
2915+
bool anyWeirdUV3s = false;
2916+
2917+
var firstUv2 = p.Vertices[0].UV2;
2918+
var firstUv3 = p.Vertices[0].UV3;
29132919

29142920
foreach (var v in p.Vertices)
29152921
{
29162922
anyAlpha = anyAlpha || (v.VertexColor[3] > 0);
29172923
anyColor = anyColor || (v.VertexColor[0] > 0 || v.VertexColor[1] > 0 || v.VertexColor[2] > 0);
2918-
anyColor2 = anyColor2 || (v.VertexColor2[0] > 0 || v.VertexColor2[1] > 0 || v.VertexColor2[2] > 0 || v.VertexColor2[3] > 0);
2924+
2925+
if(fullWhiteColor2 == true &&
2926+
(v.VertexColor2[0] < 255
2927+
|| v.VertexColor2[1] < 255
2928+
|| v.VertexColor2[2] < 255))
2929+
{
2930+
fullWhiteColor2 = false;
2931+
}
2932+
29192933
anyWeirdUV1s = anyWeirdUV1s || (v.UV1.X > 2 || v.UV1.X < -2 || v.UV1.Y > 2 || v.UV1.Y < -2);
2920-
anyWeirdUV2s = anyWeirdUV2s || (v.UV2.X > 2 || v.UV2.X < -2 || v.UV2.Y > 2 || v.UV2.Y < -2);
2934+
anyWeirdUV2s = anyWeirdUV2s || ((v.UV2.X > 2 || v.UV2.X < -2 || v.UV2.Y > 2 || v.UV2.Y < -2) && v.UV2 != firstUv2);
2935+
anyWeirdUV3s = anyWeirdUV3s || ((v.UV3.X > 2 || v.UV3.X < -2 || v.UV3.Y > 2 || v.UV3.Y < -2) && v.UV3 != firstUv3);
2936+
2937+
if((v.UV2.X > 2 || v.UV2.X < -2 || v.UV2.Y > 2 || v.UV2.Y < -2))
2938+
{
2939+
Trace.WriteLine(v.UV2);
2940+
}
2941+
if ((v.UV2.X > 2 || v.UV2.X < -2 || v.UV2.Y > 2 || v.UV2.Y < -2))
2942+
{
2943+
Trace.WriteLine(v.UV2);
2944+
}
29212945
}
29222946

29232947
if (!anyAlpha)
@@ -2929,9 +2953,10 @@ public static void CheckCommonUserErrors(TTModel model, Action<bool, string> log
29292953
{
29302954
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has a fully black Vertex Color channel. This can have unexpected results on in-game rendering. Was this intended?");
29312955
}
2932-
if (!anyColor)
2956+
2957+
if (fullWhiteColor2)
29332958
{
2934-
// TODO: Do we care about this? Who knows.
2959+
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has a fully white Vertex Color 2 channel. This may turn the model into wiggly jiggly jello in game.");
29352960
}
29362961

29372962
if (anyWeirdUV1s)
@@ -2944,6 +2969,11 @@ public static void CheckCommonUserErrors(TTModel model, Action<bool, string> log
29442969
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has unusual UV2 data. This can have unexpected results on decal placement or opacity. Was this intended?");
29452970
}
29462971

2972+
if (anyWeirdUV3s)
2973+
{
2974+
loggingFunction(true, "Mesh: " + mIdx + " Part: " + pIdx + " has unusual UV3 data. This can have unexpected results on some shaders. Was this intended?");
2975+
}
2976+
29472977
pIdx++;
29482978
}
29492979
mIdx++;

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,7 +3972,6 @@ private static int WriteVertex(VertexByteData importData, Dictionary<VertexUsage
39723972
{
39733973
if (vertexInfoList[VertexUsageType.BoneIndex][0] == VertexDataType.UByte8)
39743974
{
3975-
ModelModifiers.CleanWeight(v, 8, loggingFunction);
39763975

39773976
// 8 Byte stye...
39783977
importData.VertexData0.Add(v.Weights[0]);
@@ -3994,7 +3993,6 @@ private static int WriteVertex(VertexByteData importData, Dictionary<VertexUsage
39943993
importData.VertexData0.Add(v.BoneIds[7]);
39953994
} else
39963995
{
3997-
ModelModifiers.CleanWeight(v, 4, loggingFunction);
39983996
// 4 byte style ...
39993997
importData.VertexData0.Add(v.Weights[0]);
40003998
importData.VertexData0.Add(v.Weights[1]);

xivModdingFramework/Models/Helpers/ModelModifiers.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,8 @@ public static async Task ApplyRacialDeform(TTModel model, XivRace targetRace, bo
13381338

13391339
// Now we're ready to animate...
13401340

1341+
var usageInfo = model.GetUsageInfo();
1342+
13411343
// For each mesh
13421344
foreach (var m in model.MeshGroups)
13431345
{
@@ -1576,6 +1578,9 @@ public static void CleanWeights(TTModel model, Action<bool, string> loggingFunct
15761578
{
15771579
return;
15781580
}
1581+
1582+
var usage = model.GetUsageInfo();
1583+
15791584
var mIdx = 0;
15801585
foreach (var m in model.MeshGroups)
15811586
{
@@ -1587,7 +1592,14 @@ public static void CleanWeights(TTModel model, Action<bool, string> loggingFunct
15871592
var vIdx = 0;
15881593
foreach (var v in p.Vertices)
15891594
{
1590-
var majorCorrection = CleanWeight(v, model.MdlVersion == 5 ? 4 : 8, loggingFunction);
1595+
bool majorCorrection = false;
1596+
if(usage.NeedsEightWeights)
1597+
{
1598+
majorCorrection = CleanWeight(v, 8, loggingFunction);
1599+
} else
1600+
{
1601+
majorCorrection = CleanWeight(v, 4, loggingFunction);
1602+
}
15911603
if (majorCorrection)
15921604
{
15931605
perPartMajorCorrections++;

xivModdingFramework/Textures/DataContainers/XivTex.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ public static XivTex FromUncompressedTex(BinaryReader br, int dataSize, long off
125125
tex.Height = header.Height;
126126

127127

128-
tex.Layers = header.Depth;
128+
// I HAVE NO IDEA WHAT I'M DOING WITH MULTILAYER DDS
129+
tex.Layers = header.ArraySize * header.Depth;
129130
tex.MipMapCount = header.MipCount;
130131

131132
// We can technically calculate this size based on the texture format and size information.

0 commit comments

Comments
 (0)