From c7b6b5ea2fb13d8f50f1e41bf8767ea65cc904c8 Mon Sep 17 00:00:00 2001 From: Jared Duke Date: Tue, 18 Nov 2014 16:56:46 -0800 Subject: [PATCH] Support lowercase 'ns' and 'ni' obj material tokens Previously, the obj material parser would interpret all key tokens starting with 'n' as 'newmtl' tokens. However, there are other tokens that can start with 'n', namely 'ns' and 'ni' for material properties. Make the parser robust to such cases, despite their canonical forms being uppercase. Resolves #410. --- code/ObjFileMtlImporter.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/code/ObjFileMtlImporter.cpp b/code/ObjFileMtlImporter.cpp index 74466f2ba..56229b7b0 100644 --- a/code/ObjFileMtlImporter.cpp +++ b/code/ObjFileMtlImporter.cpp @@ -166,25 +166,27 @@ void ObjFileMtlImporter::load() } break; - case 'N': // Shineness + case 'N': + case 'n': { ++m_DataIt; - switch(*m_DataIt) + switch(*m_DataIt) { - case 's': + case 's': // Specular exponent ++m_DataIt; getFloatValue(m_pModel->m_pCurrentMaterial->shineness); break; - case 'i': //Index Of refraction + case 'i': // Index Of refraction ++m_DataIt; getFloatValue(m_pModel->m_pCurrentMaterial->ior); break; + case 'e': // New material + createMaterial(); + break; } m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); - break; } break; - case 'm': // Texture case 'b': // quick'n'dirty - for 'bump' sections @@ -194,13 +196,6 @@ void ObjFileMtlImporter::load() } break; - case 'n': // New material name - { - createMaterial(); - m_DataIt = skipLine( m_DataIt, m_DataItEnd, m_uiLine ); - } - break; - case 'i': // Illumination model { m_DataIt = getNextToken(m_DataIt, m_DataItEnd);