|
@@ -200,6 +200,8 @@ void ObjFileParser::copyNextWord(char *pBuffer, size_t length)
|
|
break;
|
|
break;
|
|
++m_DataIt;
|
|
++m_DataIt;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ ai_assert(index < length);
|
|
pBuffer[index] = '\0';
|
|
pBuffer[index] = '\0';
|
|
}
|
|
}
|
|
|
|
|
|
@@ -207,16 +209,30 @@ void ObjFileParser::copyNextWord(char *pBuffer, size_t length)
|
|
// Copy the next line into a temporary buffer
|
|
// Copy the next line into a temporary buffer
|
|
void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
|
|
void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
|
|
{
|
|
{
|
|
- size_t index = 0;
|
|
|
|
- while (m_DataIt != m_DataItEnd)
|
|
|
|
|
|
+ size_t index = 0u;
|
|
|
|
+
|
|
|
|
+ // some OBJ files have line continuations using \ (such as in C++ et al)
|
|
|
|
+ bool continuation = false;
|
|
|
|
+ for (;m_DataIt != m_DataItEnd && index < length-1; ++m_DataIt)
|
|
{
|
|
{
|
|
- if (*m_DataIt == '\n' || *m_DataIt == '\r' || index == length-1)
|
|
|
|
|
|
+ const char c = *m_DataIt;
|
|
|
|
+ if (c == '\\') {
|
|
|
|
+ continuation = true;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (c == '\n' || c == '\r') {
|
|
|
|
+ if(continuation) {
|
|
|
|
+ pBuffer[ index++ ] = ' ';
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
|
|
+ }
|
|
|
|
|
|
- pBuffer[ index ] = *m_DataIt;
|
|
|
|
- ++index;
|
|
|
|
- ++m_DataIt;
|
|
|
|
|
|
+ continuation = false;
|
|
|
|
+ pBuffer[ index++ ] = c;
|
|
}
|
|
}
|
|
|
|
+ ai_assert(index < length);
|
|
pBuffer[ index ] = '\0';
|
|
pBuffer[ index ] = '\0';
|
|
}
|
|
}
|
|
|
|
|