aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyoyo Fujita <syoyo@lighttransport.com>2017-09-12 02:18:27 +0900
committerSyoyo Fujita <syoyo@lighttransport.com>2017-09-12 02:18:27 +0900
commit1065d7cfb26e11f84eb20b283991f8549e0a412b (patch)
treeed7675b2cb248aaaaebab2379882acf5a21a7c4b
parent303043f9ecee48f74b3cc843045f56511ad3da42 (diff)
downloadtinyobjloader-1065d7cfb26e11f84eb20b283991f8549e0a412b.tar.gz
Change to add a shape when shape.mesh.indices.size() > 0 once `g` tag appears. Fixes #138.
-rw-r--r--tests/tester.cc20
-rw-r--r--tiny_obj_loader.h5
2 files changed, 24 insertions, 1 deletions
diff --git a/tests/tester.cc b/tests/tester.cc
index a76359a..d4070c9 100644
--- a/tests/tester.cc
+++ b/tests/tester.cc
@@ -605,6 +605,26 @@ TEST_CASE("map_Bump", "[bump]") {
REQUIRE(materials[0].bump_texname.compare("bump.jpg") == 0);
}
+TEST_CASE("g_ignored", "[Issue138]") {
+ tinyobj::attrib_t attrib;
+ std::vector<tinyobj::shape_t> shapes;
+ std::vector<tinyobj::material_t> materials;
+
+ std::string err;
+ bool ret = tinyobj::LoadObj(&attrib, &shapes, &materials, &err, "../models/issue-138.obj", gMtlBasePath);
+
+ if (!err.empty()) {
+ std::cerr << err << std::endl;
+ }
+
+ PrintInfo(attrib, shapes, materials);
+
+ REQUIRE(true == ret);
+ REQUIRE(2 == shapes.size());
+ REQUIRE(2 == materials.size());
+
+}
+
#if 0
int
main(
diff --git a/tiny_obj_loader.h b/tiny_obj_loader.h
index 34cd85e..4e2f6b5 100644
--- a/tiny_obj_loader.h
+++ b/tiny_obj_loader.h
@@ -23,6 +23,7 @@ THE SOFTWARE.
*/
//
+// version 1.0.8 : Fix parsing `g` tag just after `usemtl`(#138)
// version 1.0.7 : Support multiple tex options(#126)
// version 1.0.6 : Add TINYOBJLOADER_USE_DOUBLE option(#124)
// version 1.0.5 : Ignore `Tr` when `d` exists in MTL(#43)
@@ -1621,7 +1622,9 @@ bool LoadObj(attrib_t *attrib, std::vector<shape_t> *shapes,
// flush previous face group.
bool ret = exportFaceGroupToShape(&shape, faceGroup, tags, material, name,
triangulate);
- if (ret) {
+ (void)ret; // return value not used.
+
+ if (shape.mesh.indices.size() > 0) {
shapes->push_back(shape);
}