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:
authorAntonio Vazquez <blendergit@gmail.com>2020-09-26 18:22:37 +0300
committerAntonio Vazquez <blendergit@gmail.com>2020-09-26 18:22:37 +0300
commite7bb7836ccc9f38d467ede9229df496857463f4d (patch)
tree69b149d5bfb60872e4f3d478a461c80a74330e35
parent0295e14f5f26dcaf557011b001e0ae314d3cc0ee (diff)
Fix T81205: Grease pencil material slots don't auto-erase void slots above the first material
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c13
1 files changed, 13 insertions, 0 deletions
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);