fix strange parsing bug. not sure how the parser was working previously
This commit is contained in:
14
src/body.cpp
14
src/body.cpp
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user