Merge pull request #179 from mlimper/master

Fixed #177
This commit is contained in:
Syoyo Fujita
2018-07-09 19:29:07 +09:00
committed by GitHub
2 changed files with 12 additions and 7 deletions

View File

@@ -769,13 +769,19 @@ TEST_CASE("invalid-face-definition", "[face]") {
}
TEST_CASE("Empty mtl basedir", "[Issue177]") {
// Win32 spesific?
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "issue-177.obj");
// A case where the user explicitly provides an empty string
// Win32 specific?
const char * userBaseDir = "";
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "issue-177.obj", userBaseDir);
// if mtl loading fails, we get an error message (WARN) here
ret &= err.empty();
if (!err.empty()) {
std::cerr << "[Issue177] " << err << std::endl;

View File

@@ -1736,9 +1736,8 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
return false;
}
std::string baseDir;
if (mtl_basedir) {
baseDir = mtl_basedir;
std::string baseDir = mtl_basedir ? mtl_basedir : "";
if (!baseDir.empty()) {
#ifndef _WIN32
const char dirsep = '/';
#else