Browse Source

Update FBXMeshGeometry.cpp (#5624)

Some FBXs do not have "Materials" information, which can cause parsing errors

Co-authored-by: Kim Kulling <[email protected]>
ycn2022 1 year ago
parent
commit
0afd366dcb
1 changed files with 6 additions and 4 deletions
  1. 6 4
      code/AssetLib/FBX/FBXMeshGeometry.cpp

+ 6 - 4
code/AssetLib/FBX/FBXMeshGeometry.cpp

@@ -644,10 +644,12 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
         return;
     }
 
-    // materials are handled separately. First of all, they are assigned per-face
-    // and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
-    // has a slightly different meaning for materials.
-    ParseVectorDataArray(materials_out,GetRequiredElement(source,"Materials"));
+    if (source["Materials"]) {
+        // materials are handled separately. First of all, they are assigned per-face
+        // and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
+        // has a slightly different meaning for materials.
+        ParseVectorDataArray(materials_out, GetRequiredElement(source, "Materials"));
+    }
 
     if (MappingInformationType == "AllSame") {
         // easy - same material for all faces