Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAras Pranckevicius <aras@nesnausk.org>2022-05-05 14:57:40 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-05-05 14:59:46 +0300
commit1830a3dfb5a1b5028c934d3dcc790da1d9ea67d0 (patch)
tree62ad54071f11c73bfec0d6e7063e511fc29994ce
parent756710800c0fd8cc2919ed338a2a897aace535d5 (diff)
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
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc5
1 files changed, 2 insertions, 3 deletions
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<std::unique_ptr<Geometry>> &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<std::unique_ptr<Geometry>> &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;
}