Fix T62384: Grease pencil blank material slot

Now, when you add an slot and then draw, the automatic created material will use the empty slot, instead to add a new slot and leave a empty one.

This fix only works if you add only an empty slot. We could remove any empty slot in the middle, but as this has no impact  in the drawing or file, it does not worth the CPU time to review every time the material list. Anyway, the user can press delete button to remove any empty slot.

If we see this is a big problem in the future, we can reopen the bug and add this cleaning function.
This commit is contained in:
Antonio Vazquez 2019-06-17 16:09:48 +02:00
parent 3b8a14a3c0
commit b46c21364a
Notes: blender-bot 2023-06-12 00:52:52 +02:00
Referenced by issue #62384, Grease pencil blank material slot
1 changed files with 5 additions and 0 deletions

View File

@ -1172,6 +1172,11 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_material(Main *bm
if (ma) {
return ma;
}
/* If the slot is empty, remove because will be added again,
* if not, we will get and empty slot. */
if ((ob->totcol > 0) && (ob->actcol == ob->totcol)) {
BKE_object_material_slot_remove(bmain, ob);
}
return BKE_gpencil_object_material_new(bmain, ob, "Material", NULL);
}