FIX: Material files with blanks in the filename can be loaded.
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@169 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
This commit is contained in:
@@ -59,7 +59,7 @@ ObjFileMtlImporter::ObjFileMtlImporter( std::vector<char> &buffer,
|
||||
m_pModel( pModel ),
|
||||
m_uiLine( 0 )
|
||||
{
|
||||
ai_assert ( NULL != m_pModel );
|
||||
ai_assert( NULL != m_pModel );
|
||||
if ( NULL == m_pModel->m_pDefaultMaterial )
|
||||
{
|
||||
m_pModel->m_pDefaultMaterial = new ObjFile::Material();
|
||||
@@ -152,7 +152,6 @@ void ObjFileMtlImporter::load()
|
||||
|
||||
case 'm': // Texture
|
||||
{
|
||||
|
||||
getTexture();
|
||||
m_DataIt = skipLine<DataArrayIt>( m_DataIt, m_DataItEnd, m_uiLine );
|
||||
}
|
||||
|
||||
@@ -44,10 +44,11 @@ ObjFileParser::ObjFileParser(std::vector<char> &Data,
|
||||
// -------------------------------------------------------------------
|
||||
ObjFileParser::~ObjFileParser()
|
||||
{
|
||||
// empty
|
||||
if(m_pModel->m_pDefaultMaterial) delete m_pModel->m_pDefaultMaterial;
|
||||
if(m_pModel) delete m_pModel;
|
||||
|
||||
delete m_pModel->m_pDefaultMaterial;
|
||||
m_pModel->m_pDefaultMaterial = NULL;
|
||||
|
||||
delete m_pModel;
|
||||
m_pModel = NULL;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
@@ -395,7 +396,7 @@ void ObjFileParser::getMaterialLib()
|
||||
return;
|
||||
|
||||
char *pStart = &(*m_DataIt);
|
||||
while (!isSpace(*m_DataIt))
|
||||
while (!isNewLine(*m_DataIt))
|
||||
m_DataIt++;
|
||||
|
||||
// Check for existence
|
||||
|
||||
@@ -57,6 +57,15 @@ inline bool isSpace(char token)
|
||||
token == '\t');
|
||||
}
|
||||
|
||||
/** @brief Returns true, fi token id a new line marking token.
|
||||
* @param token Token to search in
|
||||
* @return true, if token is a newline token.
|
||||
*/
|
||||
inline bool isNewLine( char token )
|
||||
{
|
||||
return ( token == '\n' || token == '\f' || token == '\r' );
|
||||
}
|
||||
|
||||
/** @brief Returns next word separated by a space
|
||||
* @param pBuffer Pointer to data buffer
|
||||
* @param pEnd Pointer to end of buffer
|
||||
|
||||
Reference in New Issue
Block a user