fix obj parser on Windows
This commit is contained in:
parent
a02d626c0a
commit
b6ceadcee7
@ -208,6 +208,14 @@ std::string_view BasicParser::readUntil(char c) {
|
||||
return source.substr(start, pos-start);
|
||||
}
|
||||
|
||||
std::string_view BasicParser::readUntilEOL() {
|
||||
int start = pos;
|
||||
while (hasNext() && source[pos] != '\r' && source[pos] != '\n') {
|
||||
pos++;
|
||||
}
|
||||
return source.substr(start, pos-start);
|
||||
}
|
||||
|
||||
std::string BasicParser::parseName() {
|
||||
char c = peek();
|
||||
if (!is_identifier_start(c)) {
|
||||
|
||||
@ -98,6 +98,7 @@ protected:
|
||||
|
||||
public:
|
||||
std::string_view readUntil(char c);
|
||||
std::string_view readUntilEOL();
|
||||
std::string parseName();
|
||||
bool hasNext();
|
||||
char peek();
|
||||
|
||||
@ -88,7 +88,7 @@ public:
|
||||
while (hasNext()) {
|
||||
if (peek() != '#' && parseName() == "usemtl") {
|
||||
skipWhitespace();
|
||||
texture = readUntil('\n');
|
||||
texture = readUntilEOL();
|
||||
break;
|
||||
}
|
||||
skipLine();
|
||||
@ -103,7 +103,7 @@ public:
|
||||
auto cmd = parseName();
|
||||
if (cmd == "usemtl") {
|
||||
skipWhitespace();
|
||||
texture = readUntil('\n');
|
||||
texture = readUntilEOL();
|
||||
mesh = &model->addMesh(texture);
|
||||
break;
|
||||
} else if (cmd == "f") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user