Skip to content

Commit fb1c193

Browse files
committed
- Bump Version Number
- Update shape data to match base model even when using default shape data.
1 parent 2ae4673 commit fb1c193

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

xivModdingFramework/Models/DataContainers/TTModel.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,36 @@ public class TTMeshPart
121121

122122
public Dictionary<string, TTShapePart> ShapeParts = new Dictionary<string, TTShapePart>();
123123

124+
125+
/// <summary>
126+
/// Updates all shapes in this part to any updated UV/Normal/etc. data from the base model.
127+
/// </summary>
128+
public void UpdateShapeData()
129+
{
130+
foreach(var shpKv in ShapeParts)
131+
{
132+
var shp = shpKv.Value;
133+
134+
foreach(var rKv in shp.VertexReplacements)
135+
{
136+
var baseVert = Vertices[rKv.Key];
137+
var shapeVert = shp.Vertices[rKv.Value];
138+
139+
shapeVert.Normal = baseVert.Normal;
140+
shapeVert.Tangent = baseVert.Tangent;
141+
shapeVert.Binormal = baseVert.Binormal;
142+
shapeVert.Handedness = baseVert.Handedness;
143+
shapeVert.UV1 = baseVert.UV1;
144+
shapeVert.UV2 = baseVert.UV2;
145+
146+
Array.Copy(baseVert.VertexColor, shapeVert.VertexColor, 4);
147+
Array.Copy(baseVert.BoneIds, shapeVert.BoneIds, 4);
148+
Array.Copy(baseVert.Weights, shapeVert.Weights, 4);
149+
150+
}
151+
}
152+
}
153+
124154
}
125155

126156
/// <summary>
@@ -385,6 +415,17 @@ public int GetIndexAt(int id)
385415

386416
}
387417

418+
/// <summary>
419+
/// Updates all shapes in this mesh group to any updated UV/Normal/etc. data from the base model.
420+
/// </summary>
421+
public void UpdateShapeData()
422+
{
423+
foreach (var p in Parts)
424+
{
425+
p.UpdateShapeData();
426+
}
427+
}
428+
388429
/// <summary>
389430
/// When stacked together, this is the list of points which the Triangle Index pointer would start for each part.
390431
/// </summary>
@@ -1945,6 +1986,18 @@ public static TTModel FromRaw(XivMdl rawMdl, Action<bool, string> loggingFunctio
19451986
return ttModel;
19461987
}
19471988

1989+
1990+
/// <summary>
1991+
/// Updates all shapes in this model to any updated UV/Normal/etc. data from the base model.
1992+
/// </summary>
1993+
public void UpdateShapeData()
1994+
{
1995+
foreach(var m in MeshGroups)
1996+
{
1997+
m.UpdateShapeData();
1998+
}
1999+
}
2000+
19482001
#endregion
19492002

19502003
#region Internal Helper Functions

xivModdingFramework/Models/Helpers/ModelModifiers.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +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();
137140
}
138141

139142
if(AutoScale)

0 commit comments

Comments
 (0)