Browse Source

Merge pull request #2620 from RevoluPowered/feature/bug-fbx-application-scale-wrong

[WIP] Fix FBX units not being converted from CM to application scale
Kim Kulling 6 years ago
parent
commit
234b759cbc
2 changed files with 7 additions and 3 deletions
  1. 2 2
      code/FBX/FBXImporter.cpp
  2. 5 1
      code/FBX/FBXMeshGeometry.cpp

+ 2 - 2
code/FBX/FBXImporter.cpp

@@ -193,8 +193,8 @@ void FBXImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
         // convert the FBX DOM to aiScene
         // convert the FBX DOM to aiScene
         ConvertToAssimpScene(pScene, doc, settings.removeEmptyBones, unit);
         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<Token>());
         std::for_each(tokens.begin(),tokens.end(),Util::delete_fun<Token>());
     }
     }

+ 5 - 1
code/FBX/FBXMeshGeometry.cpp

@@ -610,8 +610,12 @@ void MeshGeometry::ReadVertexDataMaterials(std::vector<int>& materials_out, cons
     const std::string& ReferenceInformationType)
     const std::string& ReferenceInformationType)
 {
 {
     const size_t face_count = m_faces.size();
     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
     // materials are handled separately. First of all, they are assigned per-face
     // and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
     // and not per polyvert. Secondly, ReferenceInformationType=IndexToDirect
     // has a slightly different meaning for materials.
     // has a slightly different meaning for materials.