This commit is contained in:
Gareth Morgan 2020-04-22 02:27:40 -04:00 committed by GitHub
commit b7601616a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

2
.gitignore vendored
View File

@ -5,3 +5,5 @@ npm/fbx2gltf/node_modules/
npm/tests/node_modules/
npm/tests/test/*.js
npm/tests/test/*.js.map
build
sdk

View File

@ -32,6 +32,14 @@
#include "materials/RoughnessMetallicMaterials.hpp"
#include "materials/TraditionalMaterials.hpp"
#ifdef _WIN32
#define SLASH_CHAR '\\'
#define ALTERNATIVE_SLASH_CHAR '/'
#else
#define SLASH_CHAR '/'
#define ALTERNATIVE_SLASH_CHAR '\\'
#endif
float scaleFactor;
static std::string NativeToUTF8(const std::string& str) {
@ -1032,6 +1040,16 @@ static std::string FindFbxTexture(
return FileUtils::GetAbsolutePath(fileLocation);
}
}
//Replace slashes with alternative platform version (e.g. '/' instead of '\\')
std::string textureFileNameAltSlash = textureFileName;
std::replace( textureFileNameAltSlash.begin(), textureFileNameAltSlash.end(), ALTERNATIVE_SLASH_CHAR, SLASH_CHAR);
// finally look with alternative slashes
for (int ii = 0; ii < folders.size(); ii++) {
const auto& fileLocation = FindFileLoosely(textureFileNameAltSlash, folders[ii], folderContents[ii]);
if (!fileLocation.empty()) {
return FileUtils::GetAbsolutePath(fileLocation);
}
}
return "";
}