From d4d9d016d16f6b919e25a63f5305d5e8665e9cc3 Mon Sep 17 00:00:00 2001 From: kimmi Date: Tue, 9 Sep 2008 22:32:04 +0000 Subject: [PATCH] BUGFIX: Correct handling of not stored texture coordinates git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@125 67173fc5-114c-0410-ac8e-9d2fd5bffc1f --- code/ObjFileImporter.cpp | 15 +++++++++------ code/ObjFileParser.cpp | 18 +++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/code/ObjFileImporter.cpp b/code/ObjFileImporter.cpp index fb798a144..b9afb6933 100644 --- a/code/ObjFileImporter.cpp +++ b/code/ObjFileImporter.cpp @@ -367,14 +367,17 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel, // Copy all texture coordinates if ( !pModel->m_TextureCoord.empty() ) { - const unsigned int tex = pSourceFace->m_pTexturCoords->at( vertexIndex ); - ai_assert( tex < pModel->m_TextureCoord.size() ); - for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) + if ( !pSourceFace->m_pTexturCoords->empty() ) { - if ( pMesh->mNumUVComponents[ i ] > 0 ) + const unsigned int tex = pSourceFace->m_pTexturCoords->at( vertexIndex ); + ai_assert( tex < pModel->m_TextureCoord.size() ); + for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++) { - aiVector2D coord2d = *pModel->m_TextureCoord[ tex ]; - pMesh->mTextureCoords[ i ][ newIndex ] = aiVector3D( coord2d.x, coord2d.y, 0.0 ); + if ( pMesh->mNumUVComponents[ i ] > 0 ) + { + aiVector2D coord2d = *pModel->m_TextureCoord[ tex ]; + pMesh->mTextureCoords[ i ][ newIndex ] = aiVector3D( coord2d.x, coord2d.y, 0.0 ); + } } } } diff --git a/code/ObjFileParser.cpp b/code/ObjFileParser.cpp index 11c75e763..aec92cf0a 100644 --- a/code/ObjFileParser.cpp +++ b/code/ObjFileParser.cpp @@ -252,25 +252,25 @@ void ObjFileParser::getFace() else { //OBJ USES 1 Base ARRAYS!!!! - const int iVal = atoi(pPtr); + const int iVal = atoi( pPtr ); int tmp = iVal; while ((tmp = tmp / 10)!=0) ++iStep; - if (0 != iVal) + if ( 0 != iVal ) { // Store parsed index - if (0 == iPos) + if ( 0 == iPos ) { - pIndices->push_back(iVal-1); + pIndices->push_back( iVal-1 ); } - else if (1 == iPos) + else if ( 1 == iPos ) { - pTexID->push_back(iVal-1); + pTexID->push_back( iVal-1 ); } - else if (2 == iPos) + else if ( 2 == iPos ) { - pNormalID->push_back(iVal-1); + pNormalID->push_back( iVal-1 ); } else { @@ -278,7 +278,7 @@ void ObjFileParser::getFace() } } } - for (int i=0; i