Merge pull request #1231 from samitc/master

fix line breakes in obj files
pull/1232/head
Kim Kulling 2017-04-11 19:14:00 +02:00 committed by GitHub
commit cfe4ee0202
1 changed files with 25 additions and 2 deletions

View File

@ -97,7 +97,30 @@ ObjFileParser::~ObjFileParser() {
ObjFile::Model *ObjFileParser::GetModel() const {
return m_pModel;
}
void ignoreNewLines(IOStreamBuffer<char> &streamBuffer, std::vector<char> &buffer)
{
std::vector<char> buf(buffer);
auto copyPosition = buffer.begin();
auto curPosition = buf.cbegin();
do
{
while (*curPosition != '\n'&&*curPosition != '\\')
{
++curPosition;
}
if (*curPosition == '\\')
{
copyPosition = std::copy(buf.cbegin(), curPosition, copyPosition);
*(copyPosition++) = ' ';
do
{
streamBuffer.getNextLine(buf);
} while (buf[0] == '\n');
curPosition = buf.cbegin();
}
} while (*curPosition != '\n');
std::copy(buf.cbegin(), curPosition, copyPosition);
}
// -------------------------------------------------------------------
// File parsing method.
void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
@ -123,7 +146,7 @@ void ObjFileParser::parseFile( IOStreamBuffer<char> &streamBuffer ) {
progressCounter++;
m_progress->UpdateFileRead( progressOffset + processed * 2, progressTotal );
}
ignoreNewLines(streamBuffer, buffer);
// parse line
switch (*m_DataIt) {
case 'v': // Parse a vertex texture coordinate