Merge pull request #4403 from JaroslavPribyl/fix/obj_with_bspline_crash
Fix parsing OBJ with free-form curve/surface body statementspull/4432/head
commit
40d896ccc1
|
@ -117,6 +117,7 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
|
||||||
unsigned int processed = 0;
|
unsigned int processed = 0;
|
||||||
size_t lastFilePos(0);
|
size_t lastFilePos(0);
|
||||||
|
|
||||||
|
bool insideCstype = false;
|
||||||
std::vector<char> buffer;
|
std::vector<char> buffer;
|
||||||
while (streamBuffer.getNextDataLine(buffer, '\\')) {
|
while (streamBuffer.getNextDataLine(buffer, '\\')) {
|
||||||
m_DataIt = buffer.begin();
|
m_DataIt = buffer.begin();
|
||||||
|
@ -131,6 +132,18 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
|
||||||
m_progress->UpdateFileRead(processed, progressTotal);
|
m_progress->UpdateFileRead(processed, progressTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// handle cstype section end (http://paulbourke.net/dataformats/obj/)
|
||||||
|
if (insideCstype) {
|
||||||
|
switch (*m_DataIt) {
|
||||||
|
case 'e': {
|
||||||
|
std::string name;
|
||||||
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
||||||
|
insideCstype = name != "end";
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
goto pf_skip_line;
|
||||||
|
}
|
||||||
|
|
||||||
// parse line
|
// parse line
|
||||||
switch (*m_DataIt) {
|
switch (*m_DataIt) {
|
||||||
case 'v': // Parse a vertex texture coordinate
|
case 'v': // Parse a vertex texture coordinate
|
||||||
|
@ -219,6 +232,14 @@ void ObjFileParser::parseFile(IOStreamBuffer<char> &streamBuffer) {
|
||||||
getObjectName();
|
getObjectName();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case 'c': // handle cstype section start
|
||||||
|
{
|
||||||
|
std::string name;
|
||||||
|
getNameNoSpace(m_DataIt, m_DataItEnd, name);
|
||||||
|
insideCstype = name == "cstype";
|
||||||
|
goto pf_skip_line;
|
||||||
|
} break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
pf_skip_line:
|
pf_skip_line:
|
||||||
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
m_DataIt = skipLine<DataArrayIt>(m_DataIt, m_DataItEnd, m_uiLine);
|
||||||
|
|
Loading…
Reference in New Issue