[Bf-blender-cvs] [e7bb7836ccc] master: Fix T81205: Grease pencil material slots don't auto-erase void slots above the first material
Antonio Vazquez
noreply at git.blender.org
Sat Sep 26 17:22:58 CEST 2020
Commit: e7bb7836ccc9f38d467ede9229df496857463f4d
Author: Antonio Vazquez
Date: Sat Sep 26 17:22:37 2020 +0200
Branches: master
https://developer.blender.org/rBe7bb7836ccc9f38d467ede9229df496857463f4d
Fix T81205: Grease pencil material slots don't auto-erase void slots above the first material
===================================================================
M source/blender/editors/gpencil/gpencil_edit.c
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index ac8085f0e53..b7bf1861ff3 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -4434,6 +4434,19 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op)
}
}
+ /* Remove unused slots. */
+ int actcol = ob_dst->actcol;
+ for (int slot = 1; slot <= ob_dst->totcol; slot++) {
+ while (slot <= ob_dst->totcol && !BKE_object_material_slot_used(ob_dst->data, slot)) {
+ ob_dst->actcol = slot;
+ BKE_object_material_slot_remove(bmain, ob_dst);
+ if (actcol >= slot) {
+ actcol--;
+ }
+ }
+ }
+ ob_dst->actcol = actcol;
+
DEG_id_tag_update(&gpd_src->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
DEG_id_tag_update(&gpd_dst->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
More information about the Bf-blender-cvs
mailing list