@@ -1325,9 +1325,11 @@ void LoadMtl(std::map<std::string, int> *material_map,
1325
1325
1326
1326
std::stringstream warn_ss;
1327
1327
1328
+ size_t line_no = 0 ;
1328
1329
std::string linebuf;
1329
1330
while (inStream->peek () != -1 ) {
1330
1331
safeGetline (*inStream, linebuf);
1332
+ line_no++;
1331
1333
1332
1334
// Trim trailing whitespace.
1333
1335
if (linebuf.size () > 0 ) {
@@ -1467,7 +1469,8 @@ void LoadMtl(std::map<std::string, int> *material_map,
1467
1469
1468
1470
if (has_tr) {
1469
1471
warn_ss << " Both `d` and `Tr` parameters defined for \" "
1470
- << material.name << " \" . Use the value of `d` for dissolve."
1472
+ << material.name << " \" . Use the value of `d` for dissolve (line "
1473
+ << line_no << " in .mtl.)"
1471
1474
<< std::endl;
1472
1475
}
1473
1476
has_d = true ;
@@ -1478,7 +1481,8 @@ void LoadMtl(std::map<std::string, int> *material_map,
1478
1481
if (has_d) {
1479
1482
// `d` wins. Ignore `Tr` value.
1480
1483
warn_ss << " Both `d` and `Tr` parameters defined for \" "
1481
- << material.name << " \" . Use the value of `d` for dissolve."
1484
+ << material.name << " \" . Use the value of `d` for dissolve (line "
1485
+ << line_no << " in .mtl.)"
1482
1486
<< std::endl;
1483
1487
} else {
1484
1488
// 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,
1929
1933
static_cast <int >(vn.size () / 3 ),
1930
1934
static_cast <int >(vt.size () / 2 ), &vi)) {
1931
1935
if (err) {
1932
- (*err) = " Failed parse `f' line(e.g. zero value for face index).\n " ;
1936
+ std::stringstream ss;
1937
+ ss << " Failed parse `f' line(e.g. zero value for face index. line " << line_num << " .)\n " ;
1938
+ (*err) += ss.str ();
1933
1939
}
1934
1940
return false ;
1935
1941
}
@@ -1988,9 +1994,11 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
1988
1994
1989
1995
if (filenames.empty ()) {
1990
1996
if (warn) {
1991
- (*warn) +=
1992
- " Looks like empty filename for mtllib. Use default "
1993
- " material. \n " ;
1997
+ std::stringstream ss;
1998
+ ss << " Looks like empty filename for mtllib. Use default "
1999
+ " material (line " << line_num << " .)\n " ;
2000
+
2001
+ (*warn) += ss.str ();
1994
2002
}
1995
2003
} else {
1996
2004
bool found = false ;
@@ -2197,21 +2205,21 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
2197
2205
if (greatest_v_idx >= static_cast <int >(v.size () / 3 )) {
2198
2206
if (warn) {
2199
2207
std::stringstream ss;
2200
- ss << " Vertex indices out of bounds. \n " << std::endl;
2208
+ ss << " Vertex indices out of bounds (line " << line_num << " .) \n " << std::endl;
2201
2209
(*warn) += ss.str ();
2202
2210
}
2203
2211
}
2204
2212
if (greatest_vn_idx >= static_cast <int >(vn.size () / 3 )) {
2205
2213
if (warn) {
2206
2214
std::stringstream ss;
2207
- ss << " Vertex normal indices out of bounds. \n " << std::endl;
2215
+ ss << " Vertex normal indices out of bounds (line " << line_num << " .) \n " << std::endl;
2208
2216
(*warn) += ss.str ();
2209
2217
}
2210
2218
}
2211
2219
if (greatest_vt_idx >= static_cast <int >(vt.size () / 2 )) {
2212
2220
if (warn) {
2213
2221
std::stringstream ss;
2214
- ss << " Vertex texcoord indices out of bounds. \n " << std::endl;
2222
+ ss << " Vertex texcoord indices out of bounds (line " << line_num << " .) \n " << std::endl;
2215
2223
(*warn) += ss.str ();
2216
2224
}
2217
2225
}
0 commit comments