fix 'unexpected end' while parsing .obj
This commit is contained in:
parent
7fc1c37258
commit
b7751cf053
@ -10,20 +10,21 @@ class ObjParser : BasicParser<char> {
|
||||
std::vector<glm::vec2> uvs {{0, 0}};
|
||||
std::vector<glm::vec3> normals {{0, 1, 0}};
|
||||
|
||||
// TODO: refactor
|
||||
void parseFace(Mesh& mesh) {
|
||||
std::vector<Vertex> vertices;
|
||||
while (hasNext()) {
|
||||
auto c = peekInLine();
|
||||
if (c == '\n') {
|
||||
break;
|
||||
} else {
|
||||
} else if (hasNext()) {
|
||||
uint indices[3] {};
|
||||
uint i = 0;
|
||||
do {
|
||||
char next = peekInLine();
|
||||
if (is_digit(next)) {
|
||||
indices[i] = parseSimpleInt(10);
|
||||
if (peekInLine() == '/') {
|
||||
if (hasNext() && peekInLine() == '/') {
|
||||
pos++;
|
||||
}
|
||||
} else if (next == '/') {
|
||||
@ -31,13 +32,13 @@ class ObjParser : BasicParser<char> {
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (peekInLine() != '\n' && ++i < 3);
|
||||
} while (hasNext() && peekInLine() != '\n' && ++i < 3);
|
||||
|
||||
vertices.push_back(Vertex {
|
||||
coords[indices[0]], uvs[indices[1]], normals[indices[2]]});
|
||||
}
|
||||
}
|
||||
if (peekInLine() != '\n' && hasNext()) {
|
||||
if (hasNext() && peekInLine() != '\n') {
|
||||
skipLine();
|
||||
}
|
||||
if (vertices.size() >= 3) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user