ObjImporter: Added better progress reporting during file import.

There are two stages to this:
1) Processing '\'s - this accounts for 1/3rd of the file import progress.
2) Parsing the file data - this accounts for the other 2/3rds.
This commit is contained in:
Andrew Parlane
2016-01-11 11:25:36 -04:00
parent bd268bd864
commit 1632f1fbb9
3 changed files with 44 additions and 4 deletions

View File

@@ -145,6 +145,13 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
modelName = pFile;
}
// This next stage takes ~ 1/3th of the total readFile task
// so should amount for 1/3th of the progress
// only update every 100KB or it'll be too slow
unsigned int progress = 0;
unsigned int progressCounter = 0;
const unsigned int updateProgressEveryBytes = 100 * 1024;
const unsigned int progressTotal = (3*m_Buffer.size()/updateProgressEveryBytes);
// process all '\'
std::vector<char> ::iterator iter = m_Buffer.begin();
while (iter != m_Buffer.end())
@@ -159,10 +166,19 @@ void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene,
}
else
++iter;
if (++progressCounter >= updateProgressEveryBytes)
{
m_progress->UpdateFileRead(++progress, progressTotal);
progressCounter = 0;
}
}
// 1/3rd progress
m_progress->UpdateFileRead(1, 3);
// parse the file into a temporary representation
ObjFileParser parser(m_Buffer, modelName, pIOHandler);
ObjFileParser parser(m_Buffer, modelName, pIOHandler, m_progress);
// And create the proper return structures out of it
CreateDataFromImport(parser.GetModel(), pScene);