[Bf-blender-cvs] [8007f7e74f5] master: Fix T103212: ignore OBJ UV indices if no UVs are present

Aras Pranckevicius noreply at git.blender.org
Sun Jan 1 18:14:32 CET 2023


Commit: 8007f7e74f5085693c5b5f83d3f9f19a173bab75
Author: Aras Pranckevicius
Date:   Sun Jan 1 19:14:37 2023 +0200
Branches: master
https://developer.blender.org/rB8007f7e74f5085693c5b5f83d3f9f19a173bab75

Fix T103212: ignore OBJ UV indices if no UVs are present

Similar to T98782 that was about normal indices: some files out there
are technically "wrong" since they refer to UV indices, without ever
defining any UVs. If the file does not have any UVs, simply ignore UV
indices in the OBJ face definitions. Fixes T103212.

===================================================================

M	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 7d5f023af4b..a46b3397891 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
@@ -222,7 +222,8 @@ static void geom_add_polygon(Geometry *geom,
     else {
       geom->track_vertex_index(corner.vert_index);
     }
-    if (got_uv) {
+    /* Ignore UV index, if the geometry does not have any UVs (T103212). */
+    if (got_uv && !global_vertices.uv_vertices.is_empty()) {
       corner.uv_vert_index += corner.uv_vert_index < 0 ? global_vertices.uv_vertices.size() : -1;
       if (corner.uv_vert_index < 0 || corner.uv_vert_index >= global_vertices.uv_vertices.size()) {
         fprintf(stderr,



More information about the Bf-blender-cvs mailing list