[Bf-blender-cvs] [9dab54562bf] greasepencil-object: Use Brush material for drawing instead of Active slot

Antonio Vazquez noreply at git.blender.org
Fri May 4 17:20:02 CEST 2018


Commit: 9dab54562bf5b653723f23a8d8d160e2d59510b5
Author: Antonio Vazquez
Date:   Fri May 4 16:53:49 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB9dab54562bf5b653723f23a8d8d160e2d59510b5

Use Brush material for drawing instead of Active slot

Instead to use the active material in the list of materials, now always use the material assigned to Brush.

If the brush hasn't a material assigned, then the current slot is assigned as the brush material and it will be used in the next drawings of this brush.

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

M	release/scripts/addons
M	release/scripts/addons_contrib
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c

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

diff --git a/release/scripts/addons b/release/scripts/addons
index 4b91309b122..371960484a3 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit 4b91309b122bcdcddd1854b1137407b2c4f55c7e
+Subproject commit 371960484a38fc64e0a2635170a41a0d8ab2f6bd
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index cd57934bd04..a8515cfdfe9 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit cd57934bd04c174fc3402888d01a74e6e6653b2f
+Subproject commit a8515cfdfe9a98127b592f36fcbe51b7e23b969a
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 957c58b4171..4b287d73ff5 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -634,15 +634,16 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data *e_data, void *vedata, T
 
 	float obscale = (ob->size[0] + ob->size[1] + ob->size[2]) / 3.0f;
 
-	/* if the brush has a default material defined, use these and not current defaults */
+	/* use the brush material */
 	Material *ma = BKE_gpencil_get_color_from_brush(brush);
 	if (ma != NULL) {
 		gpcolor = ma->gpcolor;
 	}
+	/* this is not common, but avoid any special situations when brush could be without material */
 	if (gpcolor == NULL) {
 		gpcolor = BKE_material_gpencil_settings_get(ob, ob->actcol);
 	}
-	
+
 	/* drawing strokes */
 	/* Check if may need to draw the active stroke cache, only if this layer is the active layer
 	 * that is being edited. (Stroke buffer is currently stored in gp-data)
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 16fddb076d0..3cb2714ff28 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1563,23 +1563,27 @@ static void gp_init_colors(tGPsdata *p)
 	Material *ma = NULL;
 	GpencilColorData *gpcolor = NULL;
 	
-	/* if the brush has a material defined, use this one and not current defaults */
+	/* use brush material */
 	ma = BKE_gpencil_get_color_from_brush(brush);
 
 	/* if no brush defaults, get material and color info
 	 * NOTE: Ensures that everything we need will exist...
 	 */
-	if ((ma == NULL) || (ma->gpcolor == NULL)){
+	if ((ma == NULL) || (ma->gpcolor == NULL)) {
 		p->material = BKE_gpencil_color_ensure(p->bmain, p->ob);
+		/* assign the material to the brush */
+		brush->material = p->material;
 	}
 	else {
 		p->material = ma;
-		/* check if the material is already on object material slots and add it if missing */
-		if (BKE_object_material_slot_find_index(p->ob, p->material) == 0) {
-			BKE_object_material_slot_add(p->ob);
-			assign_material(p->ob, ma, p->ob->totcol, BKE_MAT_ASSIGN_EXISTING);
-		}
 	}
+
+	/* check if the material is already on object material slots and add it if missing */
+	if (BKE_object_material_slot_find_index(p->ob, p->material) == 0) {
+		BKE_object_material_slot_add(p->ob);
+		assign_material(p->ob, ma, p->ob->totcol, BKE_MAT_ASSIGN_EXISTING);
+	}
+
 	/* assign color information to temp tGPsdata */
 	gpcolor = p->material->gpcolor;
 	if (gpcolor) {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 6acc9bc1a62..66525f44c1d 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -1381,15 +1381,9 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	GP_EditBrush_Data *brush = NULL;
 	Brush *paintbrush = NULL;
-	int *last_mouse_position = customdata;
-
-	/* get current color */
-	Material *ma = BKE_gpencil_get_color_from_brush(CTX_data_active_gpencil_brush(C));
+	Material *ma = NULL;
 	GpencilColorData *gpcolor = NULL;
-	if (ma == NULL) {
-		ma = BKE_gpencil_color_ensure(bmain, ob);
-	}
-	gpcolor = ma->gpcolor;
+	int *last_mouse_position = customdata;
 
 	if ((gpd) && (gpd->flag & GP_DATA_STROKE_WEIGHTMODE)) {
 		brush = &gset->brush[gset->weighttype];
@@ -1431,6 +1425,15 @@ static void gp_brush_drawcursor(bContext *C, int x, int y, void *customdata)
 				return;
 			}
 
+			/* get current drawing color */
+			ma = BKE_gpencil_get_color_from_brush(paintbrush);
+			if (ma == NULL) {
+				ma = BKE_gpencil_color_ensure(bmain, ob);
+				/* assign the material to the brush */
+				paintbrush->material = ma;
+			}
+			gpcolor = ma->gpcolor;
+
 			/* after some testing, display the size of the brush is not practical because 
 			 * is too disruptive and the size of cursor does not change with zoom factor.
 			 * The decision was to use a fix size, instead of paintbrush->thickness value.



More information about the Bf-blender-cvs mailing list