FIX: Obj loader failed to read models with strange UV coordinates (see https://sourceforge.net/forum/forum.php?thread_id=2869243&forum_id=817653).

Added the model that was reported as crashing to the regression test suite.


git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@306 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
aramis_acg
2009-01-19 00:40:48 +00:00
parent d41f570dc0
commit 561943e75c
3 changed files with 6128 additions and 10 deletions

View File

@@ -319,17 +319,18 @@ void ObjFileImporter::createVertexArray(const ObjFile::Model* pModel,
pMesh->mNormals = new aiVector3D[ pMesh->mNumVertices ];
// Allocate buffer for texture coordinates
if ( !pModel->m_TextureCoord.empty() )
if ( !pModel->m_TextureCoord.empty() && pObjMesh->m_uiUVCoordinates[0] )
{
for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ )
{
const unsigned int num_uv = pObjMesh->m_uiUVCoordinates[ i ];
if ( num_uv > 0 )
{
pMesh->mNumUVComponents[ i ] = num_uv;
pMesh->mTextureCoords[ i ] = new aiVector3D[ num_uv ];
}
}
// FIXME (@Kimmi): cleanup, I don't see the intention behind this
// for ( size_t i=0; i < AI_MAX_NUMBER_OF_TEXTURECOORDS; i++ )
// {
// const unsigned int num_uv = pObjMesh->m_uiUVCoordinates[ i ];
// if ( num_uv > 0 )
// {
pMesh->mNumUVComponents[ 0 ] = 2;
pMesh->mTextureCoords[ 0 ] = new aiVector3D[ pMesh->mNumVertices ];
// }
// }
}
// Copy vertices, normals and textures into aiMesh instance