From 390452bd06f510c3c2933ab5915ef2add1b35fec Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 May 2019 20:32:45 +0200 Subject: [PATCH] Fix the build. --- code/FBXConverter.cpp | 8 ++++---- code/FBXConverter.h | 22 +++++++++++----------- code/FBXImporter.cpp | 6 +++++- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index bd8347408..f45129cae 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -76,7 +76,7 @@ namespace Assimp { #define CONVERT_FBX_TIME(time) static_cast(time) / 46186158000L - FBXConverter::FBXConverter(aiScene* out, const Document& doc, bool removeEmptyBones) + FBXConverter::FBXConverter(aiScene* out, const Document& doc, bool removeEmptyBones, FbxUnit unit ) : defaultMaterialIndex() , lights() , cameras() @@ -119,7 +119,7 @@ namespace Assimp { ConvertGlobalSettings(); TransferDataToScene(); - ConvertToUnitScale(doc.GlobalSettings().UnitScaleFactor()); + ConvertToUnitScale(unit); // if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE // to make sure the scene passes assimp's validation. FBX files @@ -3570,9 +3570,9 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa } // ------------------------------------------------------------------------------------------------ - void ConvertToAssimpScene(aiScene* out, const Document& doc, bool removeEmptyBones) + void ConvertToAssimpScene(aiScene* out, const Document& doc, bool removeEmptyBones, FbxUnit unit) { - FBXConverter converter(out, doc, removeEmptyBones); + FBXConverter converter(out, doc, removeEmptyBones, unit); } } // !FBX diff --git a/code/FBXConverter.h b/code/FBXConverter.h index dbbeee158..f75222d5b 100644 --- a/code/FBXConverter.h +++ b/code/FBXConverter.h @@ -76,13 +76,22 @@ namespace FBX { class Document; +enum class FbxUnit { + cm = 0, + m, + km, + NumUnits, + + Undefined +}; + /** * Convert a FBX #Document to #aiScene * @param out Empty scene to be populated * @param doc Parsed FBX document * @param removeEmptyBones Will remove bones, which do not have any references to vertices. */ -void ConvertToAssimpScene(aiScene* out, const Document& doc, bool removeEmptyBones ); +void ConvertToAssimpScene(aiScene* out, const Document& doc, bool removeEmptyBones, FbxUnit unit); /** Dummy class to encapsulate the conversion process */ class FBXConverter { @@ -113,7 +122,7 @@ public: }; public: - FBXConverter(aiScene* out, const Document& doc, bool removeEmptyBones ); + FBXConverter(aiScene* out, const Document& doc, bool removeEmptyBones, FbxUnit unit); ~FBXConverter(); private: @@ -415,15 +424,6 @@ private: void ConvertGlobalSettings(); - enum class FbxUnit { - cm = 0, - m, - km, - NumUnits, - - Undefined - }; - // ------------------------------------------------------------------------------------------------ // Will perform the conversion from a given unit to the requested unit. void ConvertToUnitScale(FbxUnit unit); diff --git a/code/FBXImporter.cpp b/code/FBXImporter.cpp index 339a9421a..988735a77 100644 --- a/code/FBXImporter.cpp +++ b/code/FBXImporter.cpp @@ -185,8 +185,12 @@ void FBXImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS // take the raw parse-tree and convert it to a FBX DOM Document doc(parser,settings); + FbxUnit unit(FbxUnit::cm); + if (settings.convertToMeters) { + unit = FbxUnit::m; + } // convert the FBX DOM to aiScene - ConvertToAssimpScene(pScene,doc, settings.removeEmptyBones); + ConvertToAssimpScene(pScene,doc, settings.removeEmptyBones, unit); std::for_each(tokens.begin(),tokens.end(),Util::delete_fun()); }