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:
authorAntonioya <blendergit@gmail.com>2019-06-12 16:51:51 +0300
committerAntonioya <blendergit@gmail.com>2019-06-12 16:52:03 +0300
commitd788f5231e81ae2be363f877d04ab93ddc396fa6 (patch)
tree3baba69a6faf8cd45abe0ba7d5719320066e680c /source/blender/blenkernel/intern/material.c
parent7a50d078fe4125788dfb084cd23a5164070fe69b (diff)
Fix T65741: Removing a GPencil Object's Material Slot deletes the strokes assigned to it
This was a design decision, but now we have decided to change it using the active material for the strokes using deleted material. If the material slot is empty a new material is created to keep the strokes visible.
Diffstat (limited to 'source/blender/blenkernel/intern/material.c')
-rw-r--r--source/blender/blenkernel/intern/material.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c
index 1e5a2d53bfa..e845271d802 100644
--- a/source/blender/blenkernel/intern/material.c
+++ b/source/blender/blenkernel/intern/material.c
@@ -361,9 +361,6 @@ static void material_data_index_remove_id(ID *id, short index)
case ID_MB:
/* meta-elems don't have materials atm */
break;
- case ID_GD:
- BKE_gpencil_material_index_remove((bGPdata *)id, index);
- break;
default:
break;
}
@@ -1050,12 +1047,20 @@ bool BKE_object_material_slot_remove(Main *bmain, Object *ob)
}
/* check indices from mesh */
- if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT, OB_GPENCIL)) {
+ if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
material_data_index_remove_id((ID *)ob->data, actcol - 1);
if (ob->runtime.curve_cache) {
BKE_displist_free(&ob->runtime.curve_cache->disp);
}
}
+ /* check indices from gpencil */
+ else if (ob->type == OB_GPENCIL) {
+ /* need one color */
+ if (ob->totcol == 0) {
+ BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob);
+ }
+ BKE_gpencil_material_index_reassign((bGPdata *)ob->data, ob->totcol, actcol - 1);
+ }
return true;
}