Show line number for some warning and error message.
This commit is contained in:
@@ -385,7 +385,7 @@ static bool TestStreamLoadObj() {
|
|||||||
std::string* err) {
|
std::string* err) {
|
||||||
(void)err;
|
(void)err;
|
||||||
(void)matId;
|
(void)matId;
|
||||||
LoadMtl(matMap, materials, &m_matSStream, warn);
|
LoadMtl(matMap, materials, &m_matSStream, warn, err);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1325,9 +1325,11 @@ void LoadMtl(std::map<std::string, int> *material_map,
|
|||||||
|
|
||||||
std::stringstream warn_ss;
|
std::stringstream warn_ss;
|
||||||
|
|
||||||
|
size_t line_no = 0;
|
||||||
std::string linebuf;
|
std::string linebuf;
|
||||||
while (inStream->peek() != -1) {
|
while (inStream->peek() != -1) {
|
||||||
safeGetline(*inStream, linebuf);
|
safeGetline(*inStream, linebuf);
|
||||||
|
line_no++;
|
||||||
|
|
||||||
// Trim trailing whitespace.
|
// Trim trailing whitespace.
|
||||||
if (linebuf.size() > 0) {
|
if (linebuf.size() > 0) {
|
||||||
@@ -1467,7 +1469,8 @@ void LoadMtl(std::map<std::string, int> *material_map,
|
|||||||
|
|
||||||
if (has_tr) {
|
if (has_tr) {
|
||||||
warn_ss << "Both `d` and `Tr` parameters defined for \""
|
warn_ss << "Both `d` and `Tr` parameters defined for \""
|
||||||
<< material.name << "\". Use the value of `d` for dissolve."
|
<< material.name << "\". Use the value of `d` for dissolve (line "
|
||||||
|
<< line_no << " in .mtl.)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
}
|
}
|
||||||
has_d = true;
|
has_d = true;
|
||||||
@@ -1478,7 +1481,8 @@ void LoadMtl(std::map<std::string, int> *material_map,
|
|||||||
if (has_d) {
|
if (has_d) {
|
||||||
// `d` wins. Ignore `Tr` value.
|
// `d` wins. Ignore `Tr` value.
|
||||||
warn_ss << "Both `d` and `Tr` parameters defined for \""
|
warn_ss << "Both `d` and `Tr` parameters defined for \""
|
||||||
<< material.name << "\". Use the value of `d` for dissolve."
|
<< material.name << "\". Use the value of `d` for dissolve (line "
|
||||||
|
<< line_no << " in .mtl.)"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
} else {
|
} else {
|
||||||
// We invert value of Tr(assume Tr is in range [0, 1])
|
// We invert value of Tr(assume Tr is in range [0, 1])
|
||||||
@@ -1929,7 +1933,9 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
static_cast<int>(vn.size() / 3),
|
static_cast<int>(vn.size() / 3),
|
||||||
static_cast<int>(vt.size() / 2), &vi)) {
|
static_cast<int>(vt.size() / 2), &vi)) {
|
||||||
if (err) {
|
if (err) {
|
||||||
(*err) = "Failed parse `f' line(e.g. zero value for face index).\n";
|
std::stringstream ss;
|
||||||
|
ss << "Failed parse `f' line(e.g. zero value for face index. line " << line_num << ".)\n";
|
||||||
|
(*err) += ss.str();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1988,9 +1994,11 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
|
|
||||||
if (filenames.empty()) {
|
if (filenames.empty()) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
(*warn) +=
|
std::stringstream ss;
|
||||||
"Looks like empty filename for mtllib. Use default "
|
ss << "Looks like empty filename for mtllib. Use default "
|
||||||
"material. \n";
|
"material (line " << line_num << ".)\n";
|
||||||
|
|
||||||
|
(*warn) += ss.str();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
@@ -2197,21 +2205,21 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
|
|||||||
if (greatest_v_idx >= static_cast<int>(v.size() / 3)) {
|
if (greatest_v_idx >= static_cast<int>(v.size() / 3)) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Vertex indices out of bounds.\n" << std::endl;
|
ss << "Vertex indices out of bounds (line " << line_num << ".)\n" << std::endl;
|
||||||
(*warn) += ss.str();
|
(*warn) += ss.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (greatest_vn_idx >= static_cast<int>(vn.size() / 3)) {
|
if (greatest_vn_idx >= static_cast<int>(vn.size() / 3)) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Vertex normal indices out of bounds.\n" << std::endl;
|
ss << "Vertex normal indices out of bounds (line " << line_num << ".)\n" << std::endl;
|
||||||
(*warn) += ss.str();
|
(*warn) += ss.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (greatest_vt_idx >= static_cast<int>(vt.size() / 2)) {
|
if (greatest_vt_idx >= static_cast<int>(vt.size() / 2)) {
|
||||||
if (warn) {
|
if (warn) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Vertex texcoord indices out of bounds.\n" << std::endl;
|
ss << "Vertex texcoord indices out of bounds (line " << line_num << ".)\n" << std::endl;
|
||||||
(*warn) += ss.str();
|
(*warn) += ss.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user