Changed: Use VSCode auto-formatter.

This commit is contained in:
Foxar
2020-12-17 14:45:57 +01:00
parent 91e8f791b0
commit 37703e69d0
+25 -28
View File
@@ -72,14 +72,14 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
else if (strcmp(lineHeader, "f") == 0) else if (strcmp(lineHeader, "f") == 0)
{ {
int* x; int *x;
fpos_t start; fpos_t start;
fgetpos(file,&start); fgetpos(file, &start);
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 */
case 9: case 9:
@@ -88,7 +88,6 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
&vertexIndex[0], &coordIndex[0], &normalIndex[0], &vertexIndex[0], &coordIndex[0], &normalIndex[0],
&vertexIndex[1], &coordIndex[1], &normalIndex[1], &vertexIndex[1], &coordIndex[1], &normalIndex[1],
&vertexIndex[2], &coordIndex[2], &normalIndex[2]); &vertexIndex[2], &coordIndex[2], &normalIndex[2]);
} }
break; break;
/* Loaded only two digits (V, VT) succesfuly. Not setting VN. */ /* Loaded only two digits (V, VT) succesfuly. Not setting VN. */
@@ -98,45 +97,46 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
&vertexIndex[0], &coordIndex[0], &vertexIndex[0], &coordIndex[0],
&vertexIndex[1], &coordIndex[1], &vertexIndex[1], &coordIndex[1],
&vertexIndex[2], &coordIndex[2]); &vertexIndex[2], &coordIndex[2]);
} }
break; break;
/* Only V set. Checking for existance of VT or VN. */ /* Only V set. Checking for existance of VT or VN. */
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
{ {
/* Failed, checking configuration V//VN */ /* Failed, checking configuration V//VN */
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d",x,x,x,x,x,x); newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", x, x, x, x, x, x);
fsetpos(file,&start); fsetpos(file, &start);
if(newerMatches==6){ if (newerMatches == 6)
{
/* Configuration confirmed. */ /* Configuration confirmed. */
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", newerMatches = fscanf(file, "%d//%d %d//%d %d//%d",
&vertexIndex[0], &normalIndex[0], &vertexIndex[0], &normalIndex[0],
&vertexIndex[1], &normalIndex[1], &vertexIndex[1], &normalIndex[1],
&vertexIndex[2], &normalIndex[2]); &vertexIndex[2], &normalIndex[2]);
} }
else{ else
{
/*Unknown configuration.*/ /*Unknown configuration.*/
PRINT_ERR("Unknown .obj face for .obj file!"); PRINT_ERR("Unknown .obj face for .obj file!");
printf("Obj file mentioned: \"%s\"\n",path); printf("Obj file mentioned: \"%s\"\n", path);
} }
} }
} }
default: default:
PRINT_ERR("Unknown faces format in .obj file!"); PRINT_ERR("Unknown faces format in .obj file!");
printf(" \"%s\"\n",path); printf(" \"%s\"\n", path);
break; break;
} }
/* if(ferror(file)) /* if(ferror(file))
PRINT_ERR("Failed to load .obj file \"%s\"."); PRINT_ERR("Failed to load .obj file \"%s\".");
else else
{ {
@@ -147,7 +147,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
//if(fscanf //if(fscanf
}*/ }*/
switch(matches) switch (matches)
{ {
case 9: case 9:
{ {
@@ -179,13 +179,13 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
} }
case 1: case 1:
{ {
if(newerMatches==3) if (newerMatches == 3)
{ {
o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1); o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1);
o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1); o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1);
o_result->getMaterial(materialsI).setVertexFace(faceI + 2, vertexIndex[2] - 1); o_result->getMaterial(materialsI).setVertexFace(faceI + 2, vertexIndex[2] - 1);
} }
else if(newerMatches==6) else if (newerMatches == 6)
{ {
o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1); o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1);
o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1); o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1);
@@ -194,17 +194,14 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1); o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
} }
break; break;
} }
} }
} }
} }
else else
break; break;
} }
o_result->calculateBoundingBoxes(); o_result->calculateBoundingBoxes();
fclose(file); fclose(file);