From 0afd366dcb789de062b1f2bcbc2ea8e6413b936e Mon Sep 17 00:00:00 2001 From: ycn2022 <124049705+ycn2022@users.noreply.github.com> Date: Fri, 21 Jun 2024 03:26:04 +0800 Subject: [PATCH] Update FBXMeshGeometry.cpp (#5624) Some FBXs do not have "Materials" information, which can cause parsing errors Co-authored-by: Kim Kulling --- code/AssetLib/FBX/FBXMeshGeometry.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/FBX/FBXMeshGeometry.cpp b/code/AssetLib/FBX/FBXMeshGeometry.cpp index 3b706727a8..67488f53ab 100644 --- a/code/AssetLib/FBX/FBXMeshGeometry.cpp +++ b/code/AssetLib/FBX/FBXMeshGeometry.cpp @@ -644,10 +644,12 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector& 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