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

View File

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