Skip to content

Commit

Permalink
Fault tolerance for model inconsitency
Browse files Browse the repository at this point in the history
  • Loading branch information
net-cscience-raphael committed Jul 1, 2024
1 parent 42242c7 commit 26bd3ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Mesh(float[] positions, float[] normals, float[] tangents, float[] bitang

// Calculate face normals
// ic increments by 3 because a face is defined by 3 vertices
for (var ic = 0; ic < this.idx.length; ic += 3) {
for (var ic = 0; ic < this.idx.length-2; ic += 3) {
if (normals == null || normals.length == 0) {
// Add zero vector if there are no vertex normals
this.facenormals.add(new Vector3f(0f, 0f, 0f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ public Model getNext() {
try {
model = ModelLoader.loadModel(this.inputFile.toString(), this.inputFile.toString());
} catch (NumberFormatException e) {
LOGGER.error("Could not decode OBJ file {} because one of the tokens could not be converted to a valid number.", this.inputFile.toString());
LOGGER.error("Could not decode file {} because one of the tokens could not be converted to a valid number.", this.inputFile.toString());
model = null;
} catch (ArrayIndexOutOfBoundsException e) {
LOGGER.error("Could not decode OBJ file {} because one of the faces points to invalid vertex indices.", this.inputFile.toString());
LOGGER.error("Could not decode file {} because one of the faces points to invalid vertex indices.", this.inputFile.toString());
model = null;
} catch (TextureLoadException e) {
LOGGER.error("Could not decode OBJ file {} because one of the faces points to invalid vertex indices.", this.inputFile.toString());
LOGGER.error("Could not decode file {} because one of the faces points to invalid vertex indices.", this.inputFile.toString());
model = null;
} catch (Exception e) {
LOGGER.error("Could not decode OBJ file {} because an unexpected error occurred.", this.inputFile.toString(), e);
LOGGER.error("Could not decode file {} because an unexpected error occurred.", this.inputFile.toString(), e);
model = null;

} finally {
Expand Down

0 comments on commit 26bd3ff

Please sign in to comment.