[Bf-blender-cvs] [2eb8779094a] greasepencil-object: Use Brush material for Fill brush

Antonio Vazquez noreply at git.blender.org
Sun May 6 11:25:33 CEST 2018


Commit: 2eb8779094a973a4025cda5c5791cfbc2b9799a6
Author: Antonio Vazquez
Date:   Sun May 6 11:25:22 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB2eb8779094a973a4025cda5c5791cfbc2b9799a6

Use Brush material for Fill brush

Now the color used is the assigned to the brush and not the active color in material slots.

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

M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/gpencil/gpencil_fill.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 0252384fb32..368798b215e 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1363,6 +1363,9 @@ class VIEW3D_PT_tools_grease_pencil_brush(Panel):
                 col.prop(brush, "line_width", text="Thickness")
                 col.prop(brush, "gpencil_fill_simplyfy_lvl", text="Simplify")
 
+                col = layout.row(align=True)
+                col.template_ID(brush, "material")
+
                 col = layout.column(align=True)
                 col.label(text="Boundary Draw Mode:")
                 row = col.row(align=True)
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 88b9266b85d..60c65652c2a 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -122,12 +122,14 @@ typedef struct tGPDfill {
 
 
  /* draw a given stroke using same thickness and color for all points */
-static void gp_draw_basic_stroke(Object *ob, bGPDstroke *gps, const float diff_mat[4][4], 
+static void gp_draw_basic_stroke(tGPDfill *tgpf, bGPDstroke *gps, const float diff_mat[4][4],
 								bool cyclic, float ink[4], int flag, float thershold)
 {
+	Object *ob = tgpf->ob;
 	bGPDspoint *points = gps->points;
-	
-	GpencilColorData *gpcolor = BKE_material_gpencil_settings_get(ob, gps->mat_nr + 1);
+
+	Material *ma = tgpf->mat;
+	GpencilColorData *gpcolor = ma->gpcolor;
 
 	int totpoints = gps->totpoints;
 	float fpt[3];
@@ -252,7 +254,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, float ink[4])
 			if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) || 
 				(tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) 
 			{
-				gp_draw_basic_stroke(tgpw.ob, gps, tgpw.diff_mat, gps->flag & GP_STROKE_CYCLIC, ink,
+				gp_draw_basic_stroke(tgpf, gps, tgpw.diff_mat, gps->flag & GP_STROKE_CYCLIC, ink,
 					tgpf->flag, tgpf->fill_threshold);
 			}
 		}
@@ -973,9 +975,6 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
 	tgpf->gpd = gpd;
 	tgpf->gpl = BKE_gpencil_layer_getactive(gpd);
 
-	/* get color info */
-	tgpf->mat = BKE_gpencil_color_ensure(bmain, tgpf->ob);
-
 	tgpf->lock_axis = ts->gp_sculpt.lock_axis;
 	
 	tgpf->oldkey = -1;
@@ -990,6 +989,17 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op))
 	tgpf->fill_threshold = brush->gp_fill_threshold;
 	tgpf->fill_simplylvl = brush->gp_fill_simplylvl;
 	tgpf->fill_draw_mode = brush->gp_fill_draw_mode;
+	
+	/* get color info */
+	Material *ma = BKE_gpencil_get_color_from_brush(brush);
+	/* if no brush defaults, get material and color info */
+	if ((ma == NULL) || (ma->gpcolor == NULL)) {
+		ma = BKE_gpencil_color_ensure(bmain, tgpf->ob);
+		/* assign always the first material to the brush */
+		brush->material = give_current_material(tgpf->ob, 1);
+	}
+
+	tgpf->mat = ma;
 
 	/* init undo */
 	gpencil_undo_init(tgpf->gpd);



More information about the Bf-blender-cvs mailing list