diff options
author | Antonioya <blendergit@gmail.com> | 2019-06-17 17:09:48 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-06-17 17:10:01 +0300 |
commit | b46c21364ada2c1559524e57a136a031c937ce0a (patch) | |
tree | 5ea542accee82664da0c2cecb0d5475e0d5a9e9f | |
parent | 3b8a14a3c072b01c833c18781612960fc9e78cc3 (diff) |
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.
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 8b74400e660..60e1869a212 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -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); } |