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
path: root/source
diff options
context:
space:
mode:
authorAras Pranckevicius <aras@nesnausk.org>2022-06-14 10:23:28 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-06-26 12:55:16 +0300
commitb6c5763b8eaec697a714a070409cdc5109a67ba5 (patch)
tree4c431b950cb1c9dd6d5a604221bdc3629d017505 /source
parent2287b98e7ea07048126cecdabb050511f3417bb5 (diff)
Fix T98782: ignore OBJ face normal indices if no normals are present
Some OBJ files out there (see T98782) have face definitions that contain vertex normal indices, but the files themselves don't contain any vertex normals. The code was doing a "hey, that's an invalid index" and skipping these faces. But the old python importer was silently ignoring these normal indices, so do the same here. Reviewed By: Howard Trickey Differential Revision: https://developer.blender.org/D15177
Diffstat (limited to 'source')
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc7
1 files changed, 5 insertions, 2 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 5720aadf39c..94d723cacf5 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
@@ -151,7 +151,7 @@ static void geom_add_polygon(Geometry *geom,
if (!line.is_empty() && line[0] == '/') {
line = line.drop_prefix(1);
line = parse_int(line, INT32_MAX, corner.vertex_normal_index, false);
- got_normal = corner.uv_vert_index != INT32_MAX;
+ got_normal = corner.vertex_normal_index != INT32_MAX;
}
}
/* Always keep stored indices non-negative and zero-based. */
@@ -174,7 +174,10 @@ static void geom_add_polygon(Geometry *geom,
face_valid = false;
}
}
- if (got_normal) {
+ /* Ignore corner normal index, if the geometry does not have any normals.
+ * Some obj files out there do have face definitions that refer to normal indices,
+ * without any normals being present (T98782). */
+ if (got_normal && geom->has_vertex_normals_) {
corner.vertex_normal_index += corner.vertex_normal_index < 0 ?
global_vertices.vertex_normals.size() :
-1;