[Bf-blender-cvs] [8c59b93505b] blender-v3.3-release: obj: Also find .mtl images by their basename, if all else fails (T77801)

Aras Pranckevicius noreply at git.blender.org
Wed Aug 10 17:05:43 CEST 2022


Commit: 8c59b93505b3066c3fd8aac121d08395eb197307
Author: Aras Pranckevicius
Date:   Wed Aug 10 18:03:27 2022 +0300
Branches: blender-v3.3-release
https://developer.blender.org/rB8c59b93505b3066c3fd8aac121d08395eb197307

obj: Also find .mtl images by their basename, if all else fails (T77801)

While T77801 itself is working as expected in the new C++ obj
importer, the repro file there uses absolute paths to material images,
yet the images themselves are right there in the current folder.

The old python based importer did find them, since it was doing a
really complex image search. My understanding is that while C++
importer was developed, it was decided to not do that -- however
just the "basename file in the mtl directory" sounds simple enough
and gets the repro case file work correctly.

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

M	source/blender/io/wavefront_obj/importer/obj_import_mtl.cc

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

diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
index 0023d1159c5..27bb5aa0d71 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc
@@ -134,6 +134,14 @@ static Image *load_texture_image(Main *bmain,
       return image;
     }
   }
+  /* Try taking just the basename from input path. */
+  std::string base_path{tex_map.mtl_dir_path + BLI_path_basename(tex_map.image_path.c_str())};
+  if (base_path != tex_path) {
+    image = load_image_at_path(bmain, base_path, relative_paths);
+    if (image != nullptr) {
+      return image;
+    }
+  }
 
   image = create_placeholder_image(bmain, tex_path);
   return image;



More information about the Bf-blender-cvs mailing list