Commit: b46c21364ada2c1559524e57a136a031c937ce0a
Author: Antonioya
Date:   Mon Jun 17 16:09:48 2019 +0200
Branches: master
https://developer.blender.org/rBb46c21364ada2c1559524e57a136a031c937ce0a

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.

===================================================================

M       source/blender/blenkernel/intern/gpencil.c

===================================================================

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);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to