Skip to content

Commit e07a835

Browse files
committed
Separate error message into warning and error. Breaks API, so bump to version 1.3.0
1 parent 1cdfd78 commit e07a835

File tree

7 files changed

+570
-380
lines changed

7 files changed

+570
-380
lines changed

examples/callback_api/main.cc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ int main(int argc, char **argv) {
129129
cb.object_cb = object_cb;
130130

131131
MyMesh mesh;
132+
std::string warn;
132133
std::string err;
133134
std::string filename = "../../models/cornell_box.obj";
134135
if (argc > 1) {
@@ -143,7 +144,11 @@ int main(int argc, char **argv) {
143144

144145
tinyobj::MaterialFileReader mtlReader("../../models/");
145146

146-
bool ret = tinyobj::LoadObjWithCallback(ifs, cb, &mesh, &mtlReader, &err);
147+
bool ret = tinyobj::LoadObjWithCallback(ifs, cb, &mesh, &mtlReader, &warn, &err);
148+
149+
if (!warn.empty()) {
150+
std::cout << "WARN: " << warn << std::endl;
151+
}
147152

148153
if (!err.empty()) {
149154
std::cerr << err << std::endl;

examples/obj_sticher/obj_sticher.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
//
22
// Stiches multiple .obj files into one .obj.
33
//
4+
#include "obj_writer.h"
45

5-
#define TINYOBJLOADER_IMPLEMENTATION
66
#include "../../tiny_obj_loader.h"
7-
#include "obj_writer.h"
87

98
#include <cassert>
109
#include <iostream>
@@ -134,8 +133,9 @@ int main(int argc, char **argv)
134133
for (int i = 0; i < num_objfiles; i++) {
135134
std::cout << "Loading " << argv[i+1] << " ... " << std::flush;
136135

136+
std::string warn;
137137
std::string err;
138-
bool ret = tinyobj::LoadObj(&attributes[i], &shapes[i], &materials[i], &err, argv[i+1]);
138+
bool ret = tinyobj::LoadObj(&attributes[i], &shapes[i], &materials[i], &warn, &err, argv[i+1]);
139139
if (!err.empty()) {
140140
std::cerr << err << std::endl;
141141
}

examples/viewer/viewer.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,13 @@ static bool LoadObjAndConvert(float bmin[3], float bmax[3],
308308
base_dir += "/";
309309
#endif
310310

311+
std::string warn;
311312
std::string err;
312-
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename,
313+
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, filename,
313314
base_dir.c_str());
315+
if (!warn.empty()) {
316+
std::cout << "WARN: " << warn << std::endl;
317+
}
314318
if (!err.empty()) {
315319
std::cerr << err << std::endl;
316320
}

examples/voxelize/main.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ bool Voxelize(const char* filename, float voxelsizex, float voxelsizey, float vo
99
tinyobj::attrib_t attrib;
1010
std::vector<tinyobj::shape_t> shapes;
1111
std::vector<tinyobj::material_t> materials;
12+
std::string warn;
1213
std::string err;
13-
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename);
14+
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, filename);
1415

1516
if (!err.empty()) {
1617
printf("err: %s\n", err.c_str());

loader_example.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,19 @@ static bool TestLoadObj(const char* filename, const char* basepath = NULL,
285285

286286
timerutil t;
287287
t.start();
288+
std::string warn;
288289
std::string err;
289-
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, filename,
290+
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, filename,
290291
basepath, triangulate);
291292
t.end();
292293
printf("Parsing time: %lu [msecs]\n", t.msec());
293294

295+
if (!warn.empty()) {
296+
std::cout << "WARN: " << warn << std::endl;
297+
}
298+
294299
if (!err.empty()) {
295-
std::cerr << err << std::endl;
300+
std::cerr << "ERR: " << err << std::endl;
296301
}
297302

298303
if (!ret) {
@@ -376,16 +381,12 @@ static bool TestStreamLoadObj() {
376381
virtual bool operator()(const std::string& matId,
377382
std::vector<material_t>* materials,
378383
std::map<std::string, int>* matMap,
384+
std::string* warn,
379385
std::string* err) {
386+
(void)err;
380387
(void)matId;
381-
std::string warning;
382-
LoadMtl(matMap, materials, &m_matSStream, &warning);
388+
LoadMtl(matMap, materials, &m_matSStream, warn);
383389

384-
if (!warning.empty()) {
385-
if (err) {
386-
(*err) += warning;
387-
}
388-
}
389390
return true;
390391
}
391392

@@ -397,8 +398,9 @@ static bool TestStreamLoadObj() {
397398
tinyobj::attrib_t attrib;
398399
std::vector<tinyobj::shape_t> shapes;
399400
std::vector<tinyobj::material_t> materials;
401+
std::string warn;
400402
std::string err;
401-
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, &objStream,
403+
bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &warn, &err, &objStream,
402404
&matSSReader);
403405

404406
if (!err.empty()) {

0 commit comments

Comments
 (0)