Skip to content

Commit

Permalink
Merge pull request assimp#789 from assimp/revert-771-obj_load_forever…
Browse files Browse the repository at this point in the history
…_fix

Revert "Fix issue: OBJ import takes forever (assimp#759) (attempt 2)"
  • Loading branch information
kimkulling committed Feb 7, 2016
2 parents c084a47 + 37a3976 commit 2466ae6
Show file tree
Hide file tree
Showing 4 changed files with 245 additions and 178 deletions.
32 changes: 32 additions & 0 deletions code/ObjFileImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,38 @@ 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())
{
if (*iter == '\\')
{
// remove '\'
iter = m_Buffer.erase(iter);
// remove next character
while (*iter == '\r' || *iter == '\n')
iter = m_Buffer.erase(iter);
}
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, m_progress);

Expand Down
Loading

0 comments on commit 2466ae6

Please sign in to comment.