[Bf-blender-cvs] [bf940653ab1] greasepencil-object: GPencil: Remove unused materials after converting mesh
Antonio Vazquez
noreply at git.blender.org
Tue Mar 31 22:02:59 CEST 2020
Commit: bf940653ab1751fd86e93193c06adb9576e3ccd1
Author: Antonio Vazquez
Date: Tue Mar 31 22:00:46 2020 +0200
Branches: greasepencil-object
https://developer.blender.org/rBbf940653ab1751fd86e93193c06adb9576e3ccd1
GPencil: Remove unused materials after converting mesh
===================================================================
M source/blender/editors/object/object_add.c
===================================================================
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 2d66c3977d2..4055ed9caa0 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -2357,6 +2357,21 @@ static int convert_exec(bContext *C, wmOperator *op)
BKE_gpencil_convert_mesh(
bmain, depsgraph, scene, gpencil_ob, ob, angle, thickness, offset, use_seams, use_faces);
gpencilConverted = true;
+
+ /* Remove unused materials. */
+ int actcol = gpencil_ob->actcol;
+ for (int slot = 1; slot <= gpencil_ob->totcol; slot++) {
+ while (slot <= gpencil_ob->totcol &&
+ !BKE_object_material_slot_used(gpencil_ob->data, slot)) {
+ gpencil_ob->actcol = slot;
+ BKE_object_material_slot_remove(CTX_data_main(C), gpencil_ob);
+
+ if (actcol >= slot) {
+ actcol--;
+ }
+ }
+ }
+ gpencil_ob->actcol = actcol;
}
else if (ob->type == OB_MESH) {
ob->flag |= OB_DONE;
More information about the Bf-blender-cvs
mailing list