From d56198774e2ea38c293056d5f63bd10fd6e2fa9c Mon Sep 17 00:00:00 2001 From: Gordon MacPherson Date: Mon, 26 Aug 2019 20:37:49 +0100 Subject: [PATCH 1/2] Fix FBX units not being converted from CM to application scale --- code/FBX/FBXImporter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/FBX/FBXImporter.cpp b/code/FBX/FBXImporter.cpp index 6a851b9ee..09694a38f 100644 --- a/code/FBX/FBXImporter.cpp +++ b/code/FBX/FBXImporter.cpp @@ -193,8 +193,8 @@ void FBXImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // convert the FBX DOM to aiScene ConvertToAssimpScene(pScene, doc, settings.removeEmptyBones, unit); - // Set file scale relative to meters - SetFileScale( doc.GlobalSettings().UnitScaleFactor() ); + // units is relative to CM :) we need it in meters for assimp + SetFileScale( doc.GlobalSettings().UnitScaleFactor() * 0.01f); std::for_each(tokens.begin(),tokens.end(),Util::delete_fun()); } From c50a4d8adef556fb8e9830436e5c55915eb37ab8 Mon Sep 17 00:00:00 2001 From: Gordon MacPherson Date: Mon, 26 Aug 2019 22:39:20 +0100 Subject: [PATCH 2/2] Fix segfault caused by FBX file with missing face #2614 --- code/FBX/FBXMeshGeometry.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/code/FBX/FBXMeshGeometry.cpp b/code/FBX/FBXMeshGeometry.cpp index e60fc25e2..169bf0029 100644 --- a/code/FBX/FBXMeshGeometry.cpp +++ b/code/FBX/FBXMeshGeometry.cpp @@ -610,8 +610,12 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector& materials_out, cons const std::string& ReferenceInformationType) { const size_t face_count = m_faces.size(); - ai_assert(face_count); + if(face_count == 0) + { + 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.