diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc index 3c9d5663a43..aa89be9780c 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc @@ -86,6 +86,7 @@ void MeshFromGeometry::fixup_invalid_faces() /* Skip and remove faces that have fewer than 3 corners. */ mesh_geometry_.total_loops_ -= curr_face.corner_count_; mesh_geometry_.face_elements_.remove_and_reorder(face_idx); + --face_idx; continue; } @@ -128,6 +129,7 @@ void MeshFromGeometry::fixup_invalid_faces() /* Remove the invalid face. */ mesh_geometry_.total_loops_ -= curr_face.corner_count_; mesh_geometry_.face_elements_.remove_and_reorder(face_idx); + --face_idx; Vector> new_faces = fixup_invalid_polygon(global_vertices_.vertices, face_verts); diff --git a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc index b2ba10a7abd..62998a51d76 100644 --- a/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc +++ b/source/blender/io/wavefront_obj/tests/obj_importer_tests.cc @@ -486,6 +486,15 @@ TEST_F(obj_importer_test, import_faces_invalid_or_with_holes) import_and_check("faces_invalid_or_with_holes.obj", expect, std::size(expect), 0); } +TEST_F(obj_importer_test, import_invalid_faces) +{ + Expectation expect[] = { + {"OBCube", OB_MESH, 8, 12, 6, 24, float3(1, 1, -1), float3(-1, 1, 1)}, + {"OBTheMesh", OB_MESH, 5, 3, 1, 3, float3(-2, 0, -2), float3(0, 2, 0)}, + }; + import_and_check("invalid_faces.obj", expect, std::size(expect), 0); +} + TEST_F(obj_importer_test, import_invalid_indices) { Expectation expect[] = {