Skip to content

Commit 60bc6cd

Browse files
committed
Update v2.3.4.13
2 parents d00a7f5 + 3b4a896 commit 60bc6cd

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

xivModdingFramework/Models/FileTypes/Mdl.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,9 +1730,16 @@ public async Task<List<string>> GetReferencedMaterialPaths(string mdlPath, int m
17301730
else if(useCached && root != null)
17311731
{
17321732
var metadata = await ItemMetadata.GetFromCachedIndex(root, index);
1733-
foreach (var entry in metadata.ImcEntries)
1733+
if (metadata.ImcEntries.Count == 0 || !Imc.UsesImc(root))
17341734
{
1735-
materialVariants.Add(entry.MaterialSet);
1735+
materialVariants.Add(1);
1736+
}
1737+
else
1738+
{
1739+
foreach (var entry in metadata.ImcEntries)
1740+
{
1741+
materialVariants.Add(entry.MaterialSet);
1742+
}
17361743
}
17371744
}
17381745
else
@@ -3071,6 +3078,10 @@ internal async Task<byte[]> MakeNewMdlFile(TTModel ttModel, XivMdl ogMdl, Action
30713078
var meshNum = p.MeshId;
30723079
foreach (var r in p.IndexReplacements)
30733080
{
3081+
if(r.Value > ushort.MaxValue)
3082+
{
3083+
throw new InvalidDataException("Mesh Group " + meshNum + " has too many total vertices/triangle indices.\nRemove some vertices/faces/shapes or split them across multiple mesh groups.");
3084+
}
30743085
meshShapeDataBlock.AddRange(BitConverter.GetBytes((ushort)r.Key));
30753086
meshShapeDataBlock.AddRange(BitConverter.GetBytes((ushort)r.Value));
30763087
}

xivModdingFramework/Models/Helpers/ModelModifiers.cs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,9 @@ public void Apply(TTModel ttModel, XivMdl currentMdl = null, XivMdl originalMdl
134134
}
135135
ModelModifiers.ClearShapeData(ttModel, loggingFunction);
136136
ModelModifiers.MergeShapeData(ttModel, originalMdl, loggingFunction);
137-
138-
// Let's at least update the base shape data to match our base model.
139-
ttModel.UpdateShapeData();
140137
}
141138

142-
if(AutoScale)
139+
if (AutoScale)
143140
{
144141
if (originalMdl == null)
145142
{
@@ -149,6 +146,9 @@ public void Apply(TTModel ttModel, XivMdl currentMdl = null, XivMdl originalMdl
149146
var oldModel = TTModel.FromRaw(originalMdl);
150147
ModelModifiers.AutoScaleModel(ttModel, oldModel, 0.3, loggingFunction);
151148
}
149+
150+
// Ensure shape data is updated with our various changes.
151+
ttModel.UpdateShapeData();
152152
}
153153
}
154154

@@ -1325,22 +1325,14 @@ public static void MakeImportReady(TTModel model, Action<bool, string> loggingFu
13251325
{
13261326
loggingFunction(true, "Group: " + mIdx + " Part: " + pIdx + " :: " + perPartMajorCorrections.ToString() + " Vertices had major corrections made to their weight data.");
13271327
}
1328-
1329-
foreach(var shpKv in p.ShapeParts)
1330-
{
1331-
foreach(var v in shpKv.Value.Vertices)
1332-
{
1333-
v.UV1[1] *= -1;
1334-
v.UV2[1] *= -1;
1335-
}
1336-
}
1337-
13381328
pIdx++;
13391329
}
13401330
mIdx++;
13411331
}
13421332

13431333

1334+
// Update the base shape data to match our base model.
1335+
model.UpdateShapeData();
13441336
}
13451337

13461338
/// <summary>
@@ -1365,16 +1357,11 @@ public static void MakeExportReady(TTModel model, Action<bool, string> loggingFu
13651357
v.UV1[1] *= -1;
13661358
v.UV2[1] *= -1;
13671359
}
1368-
foreach (var shpKv in p.ShapeParts)
1369-
{
1370-
foreach (var v in shpKv.Value.Vertices)
1371-
{
1372-
v.UV1[1] *= -1;
1373-
v.UV2[1] *= -1;
1374-
}
1375-
}
13761360
}
13771361
}
1362+
1363+
// Update the base shape data to match our base model.
1364+
model.UpdateShapeData();
13781365
}
13791366

13801367
/// <summary>

0 commit comments

Comments
 (0)