diff --git a/qglview/loader_obj.cpp b/qglview/loader_obj.cpp index 586f360..15493ca 100644 --- a/qglview/loader_obj.cpp +++ b/qglview/loader_obj.cpp @@ -214,11 +214,12 @@ GLObjectBase * loadFromOBJFile(const QString & filepath, float scale) { QVector vertices, normals, texcoords; QVector materials; GLObjectBase * root = new GLObjectBase(), * co = nullptr; - QString name; + QString name, line, pline; root->setName(QFileInfo(f).baseName()); int cnt = 0; while (!stream.atEnd()) { - QString line = stream.readLine().trimmed(); + pline = line; + line = stream.readLine().trimmed(); if (line.startsWith("mtllib")) { materials = readMTL(filepath, line.mid(6).trimmed()); continue; @@ -236,6 +237,7 @@ GLObjectBase * loadFromOBJFile(const QString & filepath, float scale) { continue; } if (line.startsWith("g ") || line.startsWith("o ")) { + if (pline.mid(1) == line.mid(1)) continue; name = line.mid(1).trimmed(); if (co != nullptr) { LoaderOBJ::initOBJMesh(co, vertices, normals, texcoords);