diff options
author | Antonio Vazquez <blendergit@gmail.com> | 2019-08-30 15:19:07 +0300 |
---|---|---|
committer | Antonio Vazquez <blendergit@gmail.com> | 2019-08-30 15:26:39 +0300 |
commit | d5d3dc418912863b172ef9f79f9991bb9d46bea8 (patch) | |
tree | d3aeb45c89025a1c5c0cabdf6ca4d3746115b848 /source/blender/blenkernel/intern/gpencil.c | |
parent | 4608220c9b3c0adfdab3cd6994d29c0ced748794 (diff) |
GPencil: Use default material when slot material is empty
When a material slot is empty, the default material is used.
The default color used is Gray to get a good contrast in dense scenes with dark and white background.
Reviewers: brecht, dfelinto, mendio, pepeland
Differential Revision: https://developer.blender.org/D5625
Diffstat (limited to 'source/blender/blenkernel/intern/gpencil.c')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index d4bf76ea44a..456bc0c88f9 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1161,38 +1161,34 @@ Material *BKE_gpencil_object_material_ensure_from_active_input_brush(Main *bmain brush->gpencil_settings->flag &= ~GP_BRUSH_MATERIAL_PINNED; } } - return BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob); + return BKE_gpencil_object_material_ensure_from_active_input_material(ob); } /** * Guaranteed to return a material assigned to object. Returns never NULL. * Only use this for materials unrelated to user input. */ -Material *BKE_gpencil_object_material_ensure_from_active_input_material(Main *bmain, Object *ob) +Material *BKE_gpencil_object_material_ensure_from_active_input_material(Object *ob) { Material *ma = give_current_material(ob, ob->actcol); if (ma) { return ma; } - /* If the slot is empty, remove because will be added again, - * if not, we will get an 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); + + return &defgpencil_material; } /* Get active color, and add all default settings if we don't find anything */ -Material *BKE_gpencil_object_material_ensure_active(Main *bmain, Object *ob) +Material *BKE_gpencil_object_material_ensure_active(Object *ob) { Material *ma = NULL; /* sanity checks */ - if (ELEM(NULL, bmain, ob)) { + if (ob == NULL) { return NULL; } - ma = BKE_gpencil_object_material_ensure_from_active_input_material(bmain, ob); + ma = BKE_gpencil_object_material_ensure_from_active_input_material(ob); if (ma->gp_style == NULL) { BKE_material_init_gpencil_settings(ma); } @@ -2008,6 +2004,7 @@ void BKE_gpencil_material_index_reassign(bGPdata *gpd, int totcol, int index) /* reassign strokes */ if ((gps->mat_nr > index) || (gps->mat_nr > totcol - 1)) { gps->mat_nr--; + CLAMP_MIN(gps->mat_nr, 0); } } } |