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-09-01 20:38:56 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-09-01 20:38:56 +0300
commitf366d197db24cf611866a8d847b4022a6a46504e (patch)
treeea79b5c35d6103fcacaba7d8006a43ffee61adbb /source/blender/io/wavefront_obj/importer
parentad4dcfe2273790584743abd83dacb57ce99d16a6 (diff)
Fix T100737: OBJ/USD import: imported object has no active material, material has 2 users
Fixes issues in importers written in C++ (T100737): - Materials had one reference count too much. Affected Collada, Alembic, USD, OBJ importers, looks like "since forever". - Active material index was not properly set on imported meshes. Regression since 3.3 (D15145). Affected Alembic, USD, OBJ. Note: now it sets the first material as the active one, whereas previously the last one was set as active. First one sounds more "intuitive" to me. Reviewed By: Bastien Montagne Differential Revision: https://developer.blender.org/D15831
Diffstat (limited to 'source/blender/io/wavefront_obj/importer')
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_mesh.cc5
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index a570b374231..6b19d6573af 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -296,6 +296,8 @@ static Material *get_or_create_material(Main *bmain,
const MTLMaterial &mtl = *materials.lookup_or_add(name, std::make_unique<MTLMaterial>());
Material *mat = BKE_material_add(bmain, name.c_str());
+ id_us_min(&mat->id);
+
ShaderNodetreeWrap mat_wrap{bmain, mtl, mat, relative_paths};
mat->use_nodes = true;
mat->nodetree = mat_wrap.get_nodetree();
@@ -319,6 +321,9 @@ void MeshFromGeometry::create_materials(Main *bmain,
}
BKE_object_material_assign_single_obdata(bmain, obj, mat, obj->totcol + 1);
}
+ if (obj->totcol > 0) {
+ obj->actcol = 1;
+ }
}
void MeshFromGeometry::create_normals(Mesh *mesh)