From 1830a3dfb5a1b5028c934d3dcc790da1d9ea67d0 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Thu, 5 May 2022 14:57:40 +0300 Subject: Fix T97863: new OBJ importer issues with extra whitespace after "f" keywords While possible extra whitespace after all OBJ/MTL keywords was properly skipped, it was not done for the "f" (face definition) keyword. While at it, also support indented keywords, i.e. extra whitespace at the beginning of the line. There's a tiny bit of performance drop while importing (e.g. importing blender 3.0 splash scene: 53.38sec -> 54.21sec on my machine). But correctness is more important. Reviewed By: Howard Trickey Differential Revision: https://developer.blender.org/D14854 --- source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc') diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index f57828725a0..d14401224ed 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -128,6 +128,7 @@ static void geom_add_polygon(Geometry *geom, curr_face.start_index_ = orig_corners_size; bool face_valid = true; + line = drop_whitespace(line); while (!line.is_empty() && face_valid) { PolyCorner corner; bool got_uv = false, got_normal = false; @@ -399,6 +400,7 @@ void OBJParser::parse(Vector> &r_all_geometries, StringRef buffer_str{buffer.data(), (int64_t)last_nl}; while (!buffer_str.is_empty()) { StringRef line = read_next_line(buffer_str); + line = drop_whitespace(line); ++line_number; if (line.is_empty()) { continue; @@ -484,9 +486,6 @@ void OBJParser::parse(Vector> &r_all_geometries, else if (line.startswith("end")) { /* End of curve definition, nothing else to do. */ } - else if (line.front() <= ' ') { - /* Just whitespace, skip. */ - } else { std::cout << "OBJ element not recognized: '" << line << "'" << std::endl; } -- cgit v1.2.3