I am using the FBX SDK (2020.2, vs2019) for loading models in my game engine. In Debug config, everything works as expected. When building in Release config, the FbxImporter::Import(FbxScene*) function returns false with the status code: eFailure and error string: "Uninitialized filename"
My code for loading a scene:
FbxScene* fbx::ParseScene(const std::filesystem::path& filepath) { auto filenameStr = filepath.filename().string(); auto filepathStr = filepath.string(); ::FbxImporter* fbxImporter = ::FbxImporter::Create(s_Data.fbxManager, filenameStr.c_str()); APEX_CORE_ASSERT(fbxImporter->Initialize(filepathStr.c_str(), -1, s_Data.fbxManager->GetIOSettings()), fmt::format("FbxImporter Initialize failed for '{0}'! Error: {1}", filepath, fbxImporter->GetStatus().GetErrorString())); FbxScene* fbxScene = FbxScene::Create(s_Data.fbxManager, filenameStr.c_str()); if (!fbxImporter->Import(fbxScene)) { // <-- fails to import FbxStatus importStatus = fbxImporter->GetStatus(); APEX_CORE_ERROR("Could not load FBX scene! Error: {}", importStatus.GetErrorString()); // Could not load FBX scene! Error: Uninitialized filename } fbxImporter->Destroy(); if(fbxScene->GetGlobalSettings().GetSystemUnit() != FbxSystemUnit::m) { // Convert the scene to meters using the defined options. FbxSystemUnit::m.ConvertScene(fbxScene); } return fbxScene; }
The FbxManager was initialized as follows:
s_Data.fbxManager = FbxManager::Create(); APEX_CORE_ASSERT(s_Data.fbxManager, "FBX Manager could not be initialized!"); s_Data.fbxManager->SetIOSettings(FbxIOSettings::Create(s_Data.fbxManager, IOSROOT));
I'm using static linking with the following settings in Visual Studio:
Debug config:
Release config:
P.S. I tried the test with multiple different fbx models and got the same output.
Am I missing something?
Hi,
I find it very strange that your code would work with a debug build and fail with a release one. The only thing I can think of is that the string used for the 'filenameStr' is not a properly terminated UTF8 string and, in a debug build, some padding is added making it "work" while, in a release build, the memory is not padded and the string simply does not terminate properly.
Can't find what you're looking for? Ask the community or share your knowledge.