Skip to content

Commit

Permalink
Added texture coordinate range check
Browse files Browse the repository at this point in the history
  • Loading branch information
HeDo88TH committed Aug 5, 2022
1 parent 1f6c065 commit d59e0ba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Obj2Tiles.Library/Geometry/MeshUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ public static IMesh LoadMesh(string fileName, out string[] dependencies)
double.Parse(segs[3], CultureInfo.InvariantCulture)));
break;
case "vt" when segs.Length >= 3:
textureVertices.Add(new Vertex2(

var vtx = new Vertex2(
double.Parse(segs[1], CultureInfo.InvariantCulture),
double.Parse(segs[2], CultureInfo.InvariantCulture)));
double.Parse(segs[2], CultureInfo.InvariantCulture));

if (vtx.X < 0 || vtx.Y < 0 || vtx.X > 1 || vtx.Y > 1)
throw new Exception("Invalid texture coordinates: " + vtx);

textureVertices.Add(vtx);
break;
case "vn" when segs.Length == 3:
// Skipping normals
Expand Down

0 comments on commit d59e0ba

Please sign in to comment.