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

[WIP] Fix FBX units not being converted from CM to application scale
pull/2621/head^2
Kim Kulling 2019-08-27 16:23:39 +02:00 committed by GitHub
commit 234b759cbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -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 // units is relative to CM :) we need it in meters for assimp
SetFileScale( doc.GlobalSettings().UnitScaleFactor() ); 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>());
} }

View File

@ -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.