Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions tiny_obj_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ bool ParseTextureNameAndOption(std::string *texname, texture_option_t *texopt,
#include <cstring>
#include <fstream>
#include <limits>
#include <set>
#include <sstream>
#include <utility>

Expand Down Expand Up @@ -2445,6 +2446,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
std::string name;

// material
std::set<std::string> material_filenames;
std::map<std::string, int> material_map;
int material = -1;

Expand Down Expand Up @@ -2735,6 +2737,11 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
} else {
bool found = false;
for (size_t s = 0; s < filenames.size(); s++) {
if (material_filenames.count(filenames[s]) > 0) {
found = true;
continue;
}

std::string warn_mtl;
std::string err_mtl;
bool ok = (*readMatFn)(filenames[s].c_str(), materials,
Expand All @@ -2749,6 +2756,7 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,

if (ok) {
found = true;
material_filenames.insert(filenames[s]);
break;
}
}
Expand Down Expand Up @@ -2993,6 +3001,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
std::stringstream errss;

// material
std::set<std::string> material_filenames;
std::map<std::string, int> material_map;
int material_id = -1; // -1 = invalid

Expand Down Expand Up @@ -3138,6 +3147,11 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,
} else {
bool found = false;
for (size_t s = 0; s < filenames.size(); s++) {
if (material_filenames.count(filenames[s]) > 0) {
found = true;
continue;
}

std::string warn_mtl;
std::string err_mtl;
bool ok = (*readMatFn)(filenames[s].c_str(), &materials,
Expand All @@ -3153,6 +3167,7 @@ bool LoadObjWithCallback(std::istream &inStream, const callback_t &callback,

if (ok) {
found = true;
material_filenames.insert(filenames[s]);
break;
}
}
Expand Down