FIX:mtl name use utf-8 encoding
jira: none Change-Id: I9a90344ac97f44445d3330c6734fac1372a1350e
This commit is contained in:
parent
d0e91b5164
commit
6360fb80be
|
@ -8,6 +8,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <boost/log/trivial.hpp>
|
#include <boost/log/trivial.hpp>
|
||||||
|
#include <boost/locale.hpp>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define DIR_SEPARATOR '\\'
|
#define DIR_SEPARATOR '\\'
|
||||||
|
@ -45,16 +46,20 @@ bool load_obj(const char *path, TriangleMesh *meshptr, ObjInfo& obj_info, std::s
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
exist_mtl = true;
|
exist_mtl = true;
|
||||||
bool mtl_name_is_path = false;
|
bool mtl_name_is_path = false;
|
||||||
boost::filesystem::path mtl_abs_path(mtl_name);
|
std::wstring wide_mtl_name = boost::locale::conv::to_utf<wchar_t>(mtl_name, "UTF-8");
|
||||||
|
if (boost::istarts_with(wide_mtl_name,"./")){
|
||||||
|
boost::replace_first(wide_mtl_name, "./", "");
|
||||||
|
}
|
||||||
|
boost::filesystem::path mtl_abs_path(wide_mtl_name);
|
||||||
if (boost::filesystem::exists(mtl_abs_path)) {
|
if (boost::filesystem::exists(mtl_abs_path)) {
|
||||||
mtl_name_is_path = true;
|
mtl_name_is_path = true;
|
||||||
}
|
}
|
||||||
boost::filesystem::path mtl_path;
|
boost::filesystem::path mtl_path;
|
||||||
if (!mtl_name_is_path) {
|
if (!mtl_name_is_path) {
|
||||||
boost::filesystem::path full_path(path);
|
boost::filesystem::path full_path(path);
|
||||||
std::string dir = full_path.parent_path().string();
|
auto dir = full_path.parent_path().wstring();
|
||||||
auto mtl_file = dir + "/" + mtl_name;
|
auto mtl_file = dir + L"/" + wide_mtl_name;
|
||||||
boost::filesystem::path temp_mtl_path(mtl_file);
|
boost::filesystem::path temp_mtl_path(mtl_file);
|
||||||
mtl_path = temp_mtl_path;
|
mtl_path = temp_mtl_path;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue