Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-03-25 19:02:42 +0300
committerAntonioya <blendergit@gmail.com>2019-03-25 19:06:07 +0300
commit7021bd527380b4d87cf48057f0039509326b03dd (patch)
tree55126437da17d736a789d236c8a98d199a1e6260 /source/blender/editors/gpencil/gpencil_fill.c
parent84240ebb3ebde58f6bfba256e49d37697fb6bc9f (diff)
GPencil: Only brushes with pinned materials have materials
Using GP_BRUSH_MATERIAL_PINNED to switch between active material and brush material, instead of updating all brushes on active material changes. This will allow brushes to have no material and therefore to not inflate the user count. This fix T62465. Patch contributed by @matc Reviewers: @brecht @antoniov @billreynish @mendio
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_fill.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_fill.c22
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);