Fixed loading errors when loading models without Normals or UVMaps, by modifying the fscanf format, and adding a missing break statement.

This commit is contained in:
Foxar
2021-04-19 10:07:38 +02:00
parent 611d4f76be
commit 7b3a28065b
+5 -3
View File
@@ -76,7 +76,6 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", x, x, x, x, x, x, x, x, x); int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", x, x, x, x, x, x, x, x, x);
fsetpos(file, &start); fsetpos(file, &start);
int newerMatches = 0; int newerMatches = 0;
switch (matches) switch (matches)
{ {
/** Vs, VTs and VNs all set */ /** Vs, VTs and VNs all set */
@@ -101,12 +100,12 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
case 1: case 1:
{ {
/** Check for existance of V/// configuration.. */ /** Check for existance of V/// configuration.. */
newerMatches = fscanf(file, "%d/// %d/// %d///\n", x, x, x); newerMatches = fscanf(file, "%d// %d// %d//\n", x, x, x);
fsetpos(file, &start); fsetpos(file, &start);
if (newerMatches == 3) if (newerMatches == 3)
{ {
/** Configuration confirmed. */ /** Configuration confirmed. */
fscanf(file, "%d/// %d/// %d///\n", &vertexIndex[0], &vertexIndex[1], &vertexIndex[2]); fscanf(file, "%d// %d// %d//\n", &vertexIndex[0], &vertexIndex[1], &vertexIndex[2]);
} }
else else
{ {
@@ -129,10 +128,13 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
} }
break; break;
} }
break;
default: default:
{
PRINT_ERR("Unknown faces format in .obj file!"); PRINT_ERR("Unknown faces format in .obj file!");
break; break;
} }
}
if (matches == 9 || matches == 2 || matches == 1) if (matches == 9 || matches == 2 || matches == 1)
{ {