File tree Expand file tree Collapse file tree 2 files changed +37
-2
lines changed
xivModdingFramework/Models Expand file tree Collapse file tree 2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -1160,6 +1160,39 @@ private Dictionary<string, SkeletonData> ResolveBoneHeirarchy()
1160
1160
return skelDict ;
1161
1161
}
1162
1162
1163
+
1164
+ /// <summary>
1165
+ /// Performs a basic sanity check on an incoming TTModel
1166
+ /// Returns true if there were no errors or errors that were resolvable.
1167
+ /// Returns false if the model was deemed insane.
1168
+ /// </summary>
1169
+ /// <param name="model"></param>
1170
+ /// <param name="loggingFunction"></param>
1171
+ /// <returns></returns>
1172
+ public static bool SanityCheck ( TTModel model , Action < bool , string > loggingFunction = null )
1173
+ {
1174
+ if ( loggingFunction == null )
1175
+ {
1176
+ loggingFunction = ModelModifiers . NoOp ;
1177
+ }
1178
+
1179
+ if ( model . MeshGroups . Count == 0 )
1180
+ {
1181
+ loggingFunction ( true , "Model has no data. - Model must have at least one valid Mesh Group." ) ;
1182
+ return false ;
1183
+ }
1184
+
1185
+
1186
+ var Group0Valid = model . MeshGroups [ 0 ] . Parts . Any ( x => x . Vertices . Count > 0 ) ;
1187
+ if ( ! Group0Valid )
1188
+ {
1189
+ loggingFunction ( true , "Mesh Group 0 has no valid parts - Model must have at least one vertex in Mesh Group 0." ) ;
1190
+ return false ;
1191
+ }
1192
+
1193
+ return true ;
1194
+ }
1195
+
1163
1196
#endregion
1164
1197
}
1165
1198
}
Original file line number Diff line number Diff line change @@ -1910,10 +1910,12 @@ await Task.Run(async () =>
1910
1910
}
1911
1911
#endregion
1912
1912
1913
- if ( ttModel . MeshGroups . Count == 0 )
1913
+ var sane = TTModel . SanityCheck ( ttModel , loggingFunction ) ;
1914
+ if ( ! sane )
1914
1915
{
1915
- throw new InvalidDataException ( "The imported model has no data ." ) ;
1916
+ throw new InvalidDataException ( "Model was deemed invalid ." ) ;
1916
1917
}
1918
+
1917
1919
// At this point we now have a fully populated TTModel entry.
1918
1920
// Time to pull in the Model Modifier for any extra steps before we pass
1919
1921
// it to the raw MDL creation function.
You can’t perform that action at this time.
0 commit comments