From 7cd1a66c8bc22a2c94460900f47c48d46be14bd1 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 20 Feb 2018 22:08:40 +0100 Subject: [PATCH] Use correct lookup. --- code/D3MFImporter.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/D3MFImporter.cpp b/code/D3MFImporter.cpp index 29e27371e..5c036bf76 100644 --- a/code/D3MFImporter.cpp +++ b/code/D3MFImporter.cpp @@ -205,10 +205,11 @@ private: const std::string nodeName( xmlReader->getNodeName() ); if(xmlReader->getNodeName() == D3MF::XmlTag::triangle) { faces.push_back(ReadTriangle()); - } else if ( nodeName == D3MF::XmlTag::pid ) { - const std::string matId( xmlReader->getAttributeValue( nodeName.c_str() ) ); - int matIdx( std::atoi( matId.c_str() ) ); - mesh->mMaterialIndex = matIdx; + const char *pidToken( xmlReader->getAttributeValue( D3MF::XmlTag::pid.c_str() ) ); + if ( nullptr != pidToken ) { + int matIdx( std::atoi( pidToken ) ); + mesh->mMaterialIndex = matIdx; + } } } @@ -234,6 +235,7 @@ private: void ReadBaseMaterials() { while ( ReadToEndElement( D3MF::XmlTag::basematerials ) ) { mMaterials.push_back( readMaterialDef() ); + xmlReader->read(); } } @@ -324,8 +326,7 @@ private: return false; } - bool ReadToEndElement(const std::string& closeTag) - { + bool ReadToEndElement(const std::string& closeTag) { while(xmlReader->read()) { if (xmlReader->getNodeType() == irr::io::EXN_ELEMENT) {