From bea52819190e54da2907e6c367b493db29f6f5c9 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Sun, 31 Jul 2022 18:10:48 +0300 Subject: Fix T100075: OBJ import: images loaded multiple times instead of being reused The new OBJ/MTL importer was creating a new image for any referenced texture, even if another material (or another property of the same material) already referenced the same texture. Make it use BKE_image_load_exists function just like Collada or USD importers do. Fixes T100075. Extended test coverage to count imported images; without the fix import_cubes_with_textures_rel would have incorrectly created 5 images instead of 4. --- source/blender/io/wavefront_obj/importer/obj_import_mtl.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source/blender/io/wavefront_obj/importer') 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 60e419728f3..f7685ba0b7b 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_mtl.cc @@ -65,7 +65,7 @@ static bool load_texture_image_at_path(Main *bmain, bNode *r_node, const std::string &path) { - Image *tex_image = BKE_image_load(bmain, path.c_str()); + Image *tex_image = BKE_image_load_exists(bmain, path.c_str()); if (!tex_image) { fprintf(stderr, "Cannot load image file: '%s'\n", path.c_str()); return false; -- cgit v1.2.3