diff options
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_fill.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_fill.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index c8c57c8ffbf..a4b4b699e5e 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -1017,12 +1017,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf) gps->flag |= GP_STROKE_CYCLIC; gps->flag |= GP_STROKE_3DSPACE; - gps->mat_nr = BKE_gpencil_get_material_index(tgpf->ob, tgpf->mat) - 1; - if (gps->mat_nr < 0) { - BKE_object_material_slot_add(tgpf->bmain, tgpf->ob); - assign_material(tgpf->bmain, tgpf->ob, tgpf->mat, tgpf->ob->totcol, BKE_MAT_ASSIGN_USERPREF); - gps->mat_nr = tgpf->ob->totcol - 1; - } + gps->mat_nr = BKE_gpencil_handle_material(tgpf->bmain, tgpf->ob, tgpf->mat); /* allocate memory for storage points */ gps->totpoints = tgpf->sbuffer_size; @@ -1215,17 +1210,18 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) tgpf->fill_draw_mode = brush->gpencil_settings->fill_draw_mode; tgpf->fill_factor = (short)max_ii(1, min_ii((int)brush->gpencil_settings->fill_factor, 8)); + int totcol = tgpf->ob->totcol; + /* get color info */ - Material *ma = BKE_gpencil_get_material_from_brush(brush); - /* if no brush defaults, get material and color info */ - if ((ma == NULL) || (ma->gp_style == NULL)) { - ma = BKE_gpencil_material_ensure(bmain, tgpf->ob); - /* assign always the first material to the brush */ - brush->gpencil_settings->material = give_current_material(tgpf->ob, 1); - } + Material *ma = BKE_gpencil_current_input_brush_material(bmain, tgpf->ob, brush); tgpf->mat = ma; + /* check whether the material was newly added */ + if (totcol != tgpf->ob->totcol) { + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_PROPERTIES, NULL); + } + /* init undo */ gpencil_undo_init(tgpf->gpd); |