fix strange parsing bug. not sure how the parser was working previously

This commit is contained in:
2025-08-18 16:27:45 -05:00
parent 718cca3ad7
commit 8b5fac0f3f
2 changed files with 7 additions and 8 deletions

View File

@@ -37,10 +37,6 @@ bool load_body(body* out_body, const char* obj_filepath) {
int start = 0; int start = 0;
for (int i = 1; i < source.len; i++) { for (int i = 1; i < source.len; i++) {
if (source[i] == '\n') {
state = ParserState::PREFIX;
continue;
}
switch (state) { switch (state) {
case ParserState::PREFIX: case ParserState::PREFIX:
if (source[i - 1] == 'v' && source[i] == ' ') { if (source[i - 1] == 'v' && source[i] == ' ') {
@@ -52,8 +48,8 @@ bool load_body(body* out_body, const char* obj_filepath) {
} }
break; break;
case ParserState::VERTEX: case ParserState::VERTEX:
if (source[i] == ' ' || source[i] == '\r' || source[i] == '\n') { if (iswspace(source[i])) {
verts[vert_i] = atof(&source[start])/1.5; verts[vert_i] = atof(&source[start]);
vert_i++; vert_i++;
start = i + 1; start = i + 1;
} }
@@ -66,11 +62,15 @@ bool load_body(body* out_body, const char* obj_filepath) {
} }
break; break;
case ParserState::FACE_SKIP: case ParserState::FACE_SKIP:
if (source[i] == ' ') { if (iswspace(source[i])) {
state = ParserState::FACE; state = ParserState::FACE;
start = i + 1; start = i + 1;
} }
} }
if (source[i] == '\n') {
state = ParserState::PREFIX;
continue;
}
} }
// Need a good validation check here. This is a stand in. // Need a good validation check here. This is a stand in.

View File

@@ -155,7 +155,6 @@ int main() {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
float time; float time;
glm::mat4 projection_t glm::mat4 projection_t
= glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1300.0f); = glm::perspective(glm::radians(60.0f), (float)width / (float)height, 0.1f, 1300.0f);