Closes https://github.com/assimp/assimp/issues/777: fix invalid skipping
of line during face defintion parsing.
This commit is contained in:
@@ -114,35 +114,34 @@ const aiImporterDesc* ObjFileImporter::GetInfo () const
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Obj-file import implementation
|
||||
void ObjFileImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||
{
|
||||
void ObjFileImporter::InternReadFile( const std::string &file, aiScene* pScene, IOSystem* pIOHandler) {
|
||||
// Read file into memory
|
||||
const std::string mode = "rb";
|
||||
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, mode));
|
||||
if( !file.get() ) {
|
||||
throw DeadlyImportError( "Failed to open file " + pFile + "." );
|
||||
static const std::string mode = "rb";
|
||||
boost::scoped_ptr<IOStream> fileStream( pIOHandler->Open( file, mode));
|
||||
if( !fileStream.get() ) {
|
||||
throw DeadlyImportError( "Failed to open file " + file + "." );
|
||||
}
|
||||
|
||||
// Get the file-size and validate it, throwing an exception when fails
|
||||
size_t fileSize = file->FileSize();
|
||||
size_t fileSize = fileStream->FileSize();
|
||||
if( fileSize < ObjMinSize ) {
|
||||
throw DeadlyImportError( "OBJ-file is too small.");
|
||||
}
|
||||
|
||||
// Allocate buffer and read file into it
|
||||
TextFileToBuffer(file.get(),m_Buffer);
|
||||
TextFileToBuffer( fileStream.get(),m_Buffer);
|
||||
|
||||
// Get the model name
|
||||
std::string modelName, folderName;
|
||||
std::string::size_type pos = pFile.find_last_of( "\\/" );
|
||||
std::string::size_type pos = file.find_last_of( "\\/" );
|
||||
if ( pos != std::string::npos ) {
|
||||
modelName = pFile.substr(pos+1, pFile.size() - pos - 1);
|
||||
folderName = pFile.substr( 0, pos );
|
||||
modelName = file.substr(pos+1, file.size() - pos - 1);
|
||||
folderName = file.substr( 0, pos );
|
||||
if ( !folderName.empty() ) {
|
||||
pIOHandler->PushDirectory( folderName );
|
||||
}
|
||||
} else {
|
||||
modelName = pFile;
|
||||
modelName = file;
|
||||
}
|
||||
|
||||
// This next stage takes ~ 1/3th of the total readFile task
|
||||
|
||||
Reference in New Issue
Block a user