[Bf-blender-cvs] [1d2cb649f7d] greasepencil-object: GP: Fill: New mode, adaptive

Charlie Jolly noreply at git.blender.org
Tue Jan 15 16:08:54 CET 2019


Commit: 1d2cb649f7d8724e6d012a330315f38b1e35710d
Author: Charlie Jolly
Date:   Tue Jan 15 15:08:20 2019 +0000
Branches: greasepencil-object
https://developer.blender.org/rB1d2cb649f7d8724e6d012a330315f38b1e35710d

GP: Fill: New mode, adaptive

This is like both strokes and control mode but with narrower strokes.

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

M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/makesdna/DNA_brush_types.h
M	source/blender/makesrna/intern/rna_brush.c

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

diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index b671eaf4df0..36496ca3338 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1020,6 +1020,10 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
 		/* calculate thickness */
 		sthickness = gps->thickness + tgpw->lthick;
 
+		if (tgpw->is_adaptive_fill) {
+			sthickness = (short)max_ii(1, sthickness / 4 * 3);
+		}
+
 		if (sthickness <= 0) {
 			continue;
 		}
@@ -1413,12 +1417,13 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
 	tgpw.winx = winx;
 	tgpw.winy = winy;
 	tgpw.dflag = dflag;
+	tgpw.is_adaptive_fill = false;
 
 	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
 		/* calculate parent position */
 		ED_gpencil_parent_location(tgpw.depsgraph, ob, gpd, gpl, diff_mat);
 
-		short lthick = (tgpw.is_fill_tool) ? 1 : brush->size + gpl->line_change;
+		short lthick = brush->size + gpl->line_change;
 
 		/* don't draw layer if hidden */
 		if (gpl->flag & GP_LAYER_HIDE)
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 9b7c97c1839..b5e4e755697 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -255,7 +255,7 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
 			tgpw.t_gpf = gpf;
 
 			/* reduce thickness to avoid gaps */
-			tgpw.is_fill_tool = true;
+			tgpw.is_adaptive_fill = (tgpf->fill_draw_mode == GP_FILL_DMODE_ADAPTIVE) ? true : false ;
 			tgpw.lthick = gpl->line_change - 4;
 			tgpw.opacity = 1.0;
 			copy_v4_v4(tgpw.tintcolor, ink);
@@ -264,14 +264,15 @@ static void gp_draw_datablock(tGPDfill *tgpf, const float ink[4])
 
 			/* normal strokes */
 			if ((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) ||
+				(tgpf->fill_draw_mode == GP_FILL_DMODE_ADAPTIVE) ||
 			    (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH))
 			{
 				ED_gp_draw_fill(&tgpw);
-
 			}
 
 			/* 3D Lines with basic shapes and invisible lines */
 			if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) ||
+			    (tgpf->fill_draw_mode == GP_FILL_DMODE_ADAPTIVE) ||
 			    (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH))
 			{
 				gp_draw_basic_stroke(
@@ -302,8 +303,8 @@ static bool gp_render_offscreen(tGPDfill *tgpf)
 	/* resize ar */
 	tgpf->ar->winrct.xmin = 0;
 	tgpf->ar->winrct.ymin = 0;
-	tgpf->ar->winrct.xmax = (int)tgpf->ar->winx * tgpf->fill_factor - 1;
-	tgpf->ar->winrct.ymax = (int)tgpf->ar->winy * tgpf->fill_factor - 1;
+	tgpf->ar->winrct.xmax = (int)tgpf->ar->winx * tgpf->fill_factor;
+	tgpf->ar->winrct.ymax = (int)tgpf->ar->winy * tgpf->fill_factor;
 	tgpf->ar->winx = (short)abs(tgpf->ar->winrct.xmax - tgpf->ar->winrct.xmin);
 	tgpf->ar->winy = (short)abs(tgpf->ar->winrct.ymax - tgpf->ar->winrct.ymin);
 
@@ -455,7 +456,8 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
 				}
 			}
 			else {
-				t_a = true; /* edge of image*/
+				/* edge of image*/
+				t_a = true;
 				break;
 			}
 		}
@@ -470,7 +472,8 @@ static bool is_leak_narrow(ImBuf *ibuf, const int maxpixel, int limit, int index
 				}
 			}
 			else {
-				t_b = true; /* edge of image*/
+				/* edge of image*/
+				t_b = true;
 				break;
 			}
 		}
@@ -576,22 +579,22 @@ static void gpencil_boundaryfill_area(tGPDfill *tgpf)
 					}
 				}
 				/* pixel right */
-				if (v + 1 < maxpixel) {
+				if (v + 1 <= maxpixel) {
 					index = v + 1;
 					if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_HORZ)) {
 						BLI_stack_push(stack, &index);
 					}
 				}
 				/* pixel top */
-				if (v + tgpf->sizex < maxpixel) {
-					index = v + tgpf->sizex;
+				if (v + ibuf->x <= maxpixel) {
+					index = v + ibuf->x;
 					if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_VERT)) {
 						BLI_stack_push(stack, &index);
 					}
 				}
 				/* pixel bottom */
-				if (v - tgpf->sizex >= 0) {
-					index = v - tgpf->sizex;
+				if (v - ibuf->x >= 0) {
+					index = v - ibuf->x;
 					if (!is_leak_narrow(ibuf, maxpixel, tgpf->fill_leak, v, LEAK_VERT)) {
 						BLI_stack_push(stack, &index);
 					}
@@ -621,7 +624,7 @@ static void gpencil_clean_borders(tGPDfill *tgpf)
 	int pixel = 0;
 
 	/* horizontal lines */
-	for (idx = 0; idx < ibuf->x - 1; idx++) {
+	for (idx = 0; idx < ibuf->x; idx++) {
 		/* bottom line */
 		set_pixel(ibuf, idx, fill_col);
 		/* top line */
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 810d7a5fb86..5c577e6d2cf 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -99,7 +99,7 @@ typedef struct tGPDdraw {
 	float tintcolor[4];                 /* tint color */
 	bool onion;                         /* onion flag */
 	bool custonion;                     /* use custom onion colors */
-	bool is_fill_tool;                  /* use fill tool */
+	bool is_adaptive_fill;              /* use fill tool */
 	float diff_mat[4][4];               /* matrix */
 } tGPDdraw;
 
diff --git a/source/blender/makesdna/DNA_brush_types.h b/source/blender/makesdna/DNA_brush_types.h
index c5b8b6aeebd..b32c86d87cc 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -164,6 +164,7 @@ typedef enum eGP_FillDrawModes {
 	GP_FILL_DMODE_BOTH = 0,
 	GP_FILL_DMODE_STROKE = 1,
 	GP_FILL_DMODE_CONTROL = 2,
+	GP_FILL_DMODE_ADAPTIVE = 3,
 } eGP_FillDrawModes;
 
 /* BrushGpencilSettings->gp_eraser_mode */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 55086cc6570..071f2d77a3c 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -135,6 +135,7 @@ static EnumPropertyItem rna_enum_gpencil_fill_draw_modes_items[] = {
 	{GP_FILL_DMODE_STROKE, "STROKE", 0, "Strokes", "Use visible strokes as fill boundary limits"},
 	{GP_FILL_DMODE_CONTROL, "CONTROL", 0, "Control", "Use internal control lines as fill boundary limits"},
 	{GP_FILL_DMODE_BOTH, "BOTH", 0, "Both", "Use visible strokes and control lines as fill boundary limits"},
+	{GP_FILL_DMODE_ADAPTIVE, "ADAPTIVE", 0, "Adaptive", "Use thin strokes and control lines as fill boundary limits"},
 	{0, NULL, 0, NULL, NULL}
 };



More information about the Bf-blender-cvs mailing list