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:
authorBastien Montagne <bastien@blender.org>2021-11-03 20:16:16 +0300
committerBastien Montagne <bastien@blender.org>2021-11-03 20:16:16 +0300
commit7aaedc09c72ebeb6e6f753681264b7b723f87c2c (patch)
tree856bf3b899e2d35aeffa2f8fc9c46e543be1be37 /source/blender
parente10caf6fe3c23def05d35c5a5bad58165cfa77fd (diff)
parentc29f9e14e4180af0fbba83d66e08c9852da7fa9c (diff)
Merge branch 'blender-v3.0-release'
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/intern/material.c12
-rw-r--r--source/blender/blenkernel/intern/object.c8
2 files changed, 13 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 5f726defb1a..3a4e39812ab 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -899,7 +899,17 @@ void BKE_object_materials_test(Main *bmain, Object *ob, ID *id)
return;
}
- BKE_object_material_resize(bmain, ob, *totcol, false);
+ if ((ob->id.tag & LIB_TAG_MISSING) == 0 && (id->tag & LIB_TAG_MISSING) != 0) {
+ /* Exception: In case the object is a valid data, but its obdata is an empty place-holder,
+ * use object's material slots amount as reference.
+ * This avoids loosing materials in a local object when its linked obdata gets missing.
+ * See T92780. */
+ BKE_id_material_resize(bmain, id, (short)ob->totcol, false);
+ }
+ else {
+ /* Normal case: the use the obdata amount of materials slots to update the object's one. */
+ BKE_object_material_resize(bmain, ob, *totcol, false);
+ }
}
void BKE_objects_materials_test_all(Main *bmain, ID *id)
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index 4eecb2b6cf7..b5d39921f26 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -869,6 +869,7 @@ static void object_blend_read_lib(BlendLibReader *reader, ID *id)
{
Object *ob = (Object *)id;
+ Main *bmain = BLO_read_lib_get_main(reader);
BlendFileReadReport *reports = BLO_read_lib_reports(reader);
/* XXX deprecated - old animation system <<< */
@@ -965,12 +966,7 @@ static void object_blend_read_lib(BlendLibReader *reader, ID *id)
/* When the object is local and the data is library its possible
* the material list size gets out of sync. T22663. */
if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
- const short *totcol_data = BKE_object_material_len_p(ob);
- /* Only expand so as not to lose any object materials that might be set. */
- if (totcol_data && (*totcol_data > ob->totcol)) {
- // printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data);
- BKE_object_material_resize(BLO_read_lib_get_main(reader), ob, *totcol_data, false);
- }
+ BKE_object_materials_test(bmain, ob, ob->data);
}
BLO_read_id_address(reader, ob->id.lib, &ob->gpd);