From 3f1590a26b91de7181fbb2ec279afa930eb64d8a Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Tue, 27 Mar 2018 20:00:48 -0700 Subject: [PATCH] Don't be tricksy if we're already done. The FBX SDK looks for our textures and often finds them. It helpfully tells us exactly where they are. Let's not throw that information away and demand that the textures only exist in precisely the folders we are aware of. --- src/Fbx2Raw.cpp | 3 +++ src/utils/File_Utils.cpp | 6 ++++++ src/utils/File_Utils.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/Fbx2Raw.cpp b/src/Fbx2Raw.cpp index 44c338f..ef925f7 100644 --- a/src/Fbx2Raw.cpp +++ b/src/Fbx2Raw.cpp @@ -1323,6 +1323,9 @@ static void ReadAnimations(RawModel &raw, FbxScene *pScene) static std::string GetInferredFileName(const std::string &fbxFileName, const std::string &directory, const std::vector &directoryFileList) { + if (FileUtils::FileExists(fbxFileName)) { + return fbxFileName; + } // Get the file name with file extension. const std::string fileName = StringUtils::GetFileNameString(StringUtils::GetCleanPathString(fbxFileName)); diff --git a/src/utils/File_Utils.cpp b/src/utils/File_Utils.cpp index c3ea1d6..30ad6bf 100644 --- a/src/utils/File_Utils.cpp +++ b/src/utils/File_Utils.cpp @@ -55,6 +55,12 @@ namespace FileUtils { return std::string(cwd); } + bool FileExists(const std::string &filePath) + { + std::ifstream stream(filePath); + return stream.good(); + } + bool FolderExists(const std::string &folderPath) { #if defined( __unix__ ) || defined( __APPLE__ ) diff --git a/src/utils/File_Utils.h b/src/utils/File_Utils.h index 92bf40a..54795ce 100644 --- a/src/utils/File_Utils.h +++ b/src/utils/File_Utils.h @@ -13,6 +13,7 @@ namespace FileUtils { std::string GetCurrentFolder(); + bool FileExists(const std::string &folderPath); bool FolderExists(const std::string &folderPath); bool MatchExtension(const char *fileExtension, const char *matchExtensions);