From 77faf04aa3bece8a6025e4e1519d58fb41aa6670 Mon Sep 17 00:00:00 2001 From: Nathan Morse Date: Fri, 20 Jun 2014 16:06:04 -0700 Subject: [PATCH] OBJ Exporter: No "g" lines with empty names In the OBJ spec ( http://www.martinreddy.net/gfx/3d/OBJ.spec ), in the section labeled "Grouping" -> "Syntax", the structure of the "g" group statement is defined. Though this statement allows multiple names on a single line, it is unclear whether there must be at least one name on the line. However, the examples don't show any "g" group statements with no names. So, let's be conservative and not write out a "g" group statement that doesn't have a name. These empty "g" statements were prompting an error message from the three.js OBJ loader code. --- code/ObjExporter.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/ObjExporter.cpp b/code/ObjExporter.cpp index ff9fa4b25..282726bb1 100644 --- a/code/ObjExporter.cpp +++ b/code/ObjExporter.cpp @@ -228,7 +228,9 @@ void ObjExporter :: WriteGeometryFile() // now write all mesh instances BOOST_FOREACH(const MeshInstance& m, meshes) { mOutput << "# Mesh \'" << m.name << "\' with " << m.faces.size() << " faces" << endl; - mOutput << "g " << m.name << endl; + if (!m.name.empty()) { + mOutput << "g " << m.name << endl; + } mOutput << "usemtl " << m.matname << endl; BOOST_FOREACH(const Face& f, m.faces) {