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.
This commit is contained in:
Par Winzell 2018-03-27 20:00:48 -07:00
parent e992aac1d9
commit 3f1590a26b
3 changed files with 10 additions and 0 deletions

View File

@ -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<std::string> &directoryFileList) static std::string GetInferredFileName(const std::string &fbxFileName, const std::string &directory, const std::vector<std::string> &directoryFileList)
{ {
if (FileUtils::FileExists(fbxFileName)) {
return fbxFileName;
}
// Get the file name with file extension. // Get the file name with file extension.
const std::string fileName = StringUtils::GetFileNameString(StringUtils::GetCleanPathString(fbxFileName)); const std::string fileName = StringUtils::GetFileNameString(StringUtils::GetCleanPathString(fbxFileName));

View File

@ -55,6 +55,12 @@ namespace FileUtils {
return std::string(cwd); return std::string(cwd);
} }
bool FileExists(const std::string &filePath)
{
std::ifstream stream(filePath);
return stream.good();
}
bool FolderExists(const std::string &folderPath) bool FolderExists(const std::string &folderPath)
{ {
#if defined( __unix__ ) || defined( __APPLE__ ) #if defined( __unix__ ) || defined( __APPLE__ )

View File

@ -13,6 +13,7 @@
namespace FileUtils { namespace FileUtils {
std::string GetCurrentFolder(); std::string GetCurrentFolder();
bool FileExists(const std::string &folderPath);
bool FolderExists(const std::string &folderPath); bool FolderExists(const std::string &folderPath);
bool MatchExtension(const char *fileExtension, const char *matchExtensions); bool MatchExtension(const char *fileExtension, const char *matchExtensions);