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_add_stroke.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_add_stroke.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_add_stroke.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/source/blender/editors/gpencil/gpencil_add_stroke.c b/source/blender/editors/gpencil/gpencil_add_stroke.c
index 8b261bf798b..c56cb94c58d 100644
--- a/source/blender/editors/gpencil/gpencil_add_stroke.c
+++ b/source/blender/editors/gpencil/gpencil_add_stroke.c
@@ -60,11 +60,10 @@ static int gp_stroke_material(
}
}
+ int idx;
+
/* create a new one */
- BKE_object_material_slot_add(bmain, ob);
- ma = BKE_material_add_gpencil(bmain, pct->name);
- assign_material(bmain, ob, ma, ob->totcol, BKE_MAT_ASSIGN_USERPREF);
- id_us_min(&ma->id);
+ ma = BKE_gpencil_handle_new_material(bmain, ob, pct->name, &idx);
copy_v4_v4(ma->gp_style->stroke_rgba, pct->line);
copy_v4_v4(ma->gp_style->fill_rgba, pct->fill);
@@ -73,7 +72,7 @@ static int gp_stroke_material(
ma->gp_style->flag |= GP_STYLE_FILL_SHOW;
}
- return BKE_gpencil_get_material_index(ob, ma) - 1;
+ return idx;
}
/* ***************************************************************** */
@@ -231,10 +230,6 @@ void ED_gpencil_create_stroke(bContext *C, Object *ob, float mat[4][4])
/* set first color as active and in brushes */
ob->actcol = color_black + 1;
- Material *ma = give_current_material(ob, ob->actcol);
- if (ma != NULL) {
- BKE_brush_update_material(bmain, ma, NULL);
- }
/* layers */
bGPDlayer *colors = BKE_gpencil_layer_addnew(gpd, "Colors", false);