From 36c82fe5b05bfb15bc3b999d521b9ca26367992e Mon Sep 17 00:00:00 2001 From: Tyson Grant Nottingham Date: Mon, 21 Jul 2014 23:03:08 -0700 Subject: [PATCH] Allow several spaces between numbers in OBJ files. --- code/ObjFileParser.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index f2e65db71..e9a1dd9ef 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -113,8 +113,8 @@ void ObjFileParser::parseFile() getVector3(m_pModel->m_Vertices); } else if (*m_DataIt == 't') { // read in texture coordinate ( 2D or 3D ) - ++m_DataIt; - getVector( m_pModel->m_TextureCoord ); + ++m_DataIt; + getVector( m_pModel->m_TextureCoord ); } else if (*m_DataIt == 'n') { // Read in normal vector definition ++m_DataIt; @@ -234,11 +234,17 @@ void ObjFileParser::copyNextLine(char *pBuffer, size_t length) void ObjFileParser::getVector( std::vector &point3d_array ) { size_t numComponents( 0 ); DataArrayIt tmp( m_DataIt ); - while( !IsLineEnd( *tmp ) ) { - if( *tmp == ' ' ) { - ++numComponents; + while( true ) { + while( isspace(*tmp) && !IsLineEnd(*tmp) ) { + tmp++; } - tmp++; + if( IsLineEnd(*tmp) ) { + break; + } + while( !isspace(*tmp) ) { + tmp++; + } + ++numComponents; } float x, y, z; if( 2 == numComponents ) {