Commit: c29fccbccc9575eb5a8d5a02a5a06264cb5fbc75
Author: Antonio Vazquez
Date:   Sat Jan 13 12:50:55 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rBc29fccbccc9575eb5a8d5a02a5a06264cb5fbc75

New no fill strokes for fill boundaries

This special strokes can only be generated using a fill brush and pressing Alt 
key.

This type of strokes are required to draw fast boundary with the fill color for 
opened areas to use the automatic fill later.

The color of these strokes will be the fill color and not the stroke color.

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

M       source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M       source/blender/editors/gpencil/gpencil_ops.c
M       source/blender/editors/gpencil/gpencil_paint.c
M       source/blender/makesdna/DNA_gpencil_types.h
M       source/blender/makesrna/intern/rna_gpencil.c

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

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 9026f2c7d1c..b3877fd8fdb 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -548,8 +548,15 @@ static void gpencil_add_stroke_shgroup(GpencilBatchCache 
*cache, DRWShadingGroup
 
        /* set color using palette, tint color and opacity */
        if (!onion) {
-               interp_v3_v3v3(tcolor, gps->palcolor->rgb, tintcolor, 
tintcolor[3]);
-               tcolor[3] = gps->palcolor->rgb[3] * opacity;
+               /* if special stroke, use fill color as stroke color */
+               if (gps->flag & GP_STROKE_NOFILL) {
+                       interp_v3_v3v3(tcolor, gps->palcolor->fill, tintcolor, 
tintcolor[3]);
+                       tcolor[3] = gps->palcolor->fill[3] * opacity;
+               }
+               else {
+                       interp_v3_v3v3(tcolor, gps->palcolor->rgb, tintcolor, 
tintcolor[3]);
+                       tcolor[3] = gps->palcolor->rgb[3] * opacity;
+               }
                copy_v4_v4(ink, tcolor);
        }
        else {
@@ -751,7 +758,8 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, 
GPENCIL_e_data *e_dat
                        int id = stl->storage->shgroup_id;
                        if ((gps->totpoints > 1) && ((gps->palcolor->flag & 
PAC_COLOR_DOT) == 0)) {
                                if ((gps->totpoints > 2) && 
(!GP_SIMPLIFY_FILL(ts, playing)) && 
-                                       ((gps->palcolor->fill[3] > 
GPENCIL_ALPHA_OPACITY_THRESH) || (gps->palcolor->fill_style > 0)))
+                                       ((gps->palcolor->fill[3] > 
GPENCIL_ALPHA_OPACITY_THRESH) || (gps->palcolor->fill_style > 0)) &&
+                                       ((gps->flag & GP_STROKE_NOFILL) == 0))
                                {
                                        stl->shgroups[id].shgrps_fill = 
DRW_gpencil_shgroup_fill_create(e_data, vedata, psl->stroke_pass, 
e_data->gpencil_fill_sh, gpd, gps->palcolor, id);
                                }
@@ -855,7 +863,9 @@ void DRW_gpencil_populate_buffer_strokes(GPENCIL_e_data 
*e_data, void *vedata, T
 
                                
DRW_shgroup_call_add(stl->g_data->shgrps_drawing_stroke, 
stl->g_data->batch_buffer_stroke, stl->storage->unit_matrix);
 
-                               if ((gpd->sbuffer_size >= 3) && (gpd->sfill[3] 
> GPENCIL_ALPHA_OPACITY_THRESH)) {
+                               if ((gpd->sbuffer_size >= 3) && (gpd->sfill[3] 
> GPENCIL_ALPHA_OPACITY_THRESH) && 
+                                       ((gpd->sbuffer_sflag & 
GP_STROKE_NOFILL) == 0)) 
+                               {
                                        /* if not solid, fill is simulated with 
solid color */
                                        if (gpd->bfill_style > 0) {
                                                gpd->sfill[3] = 0.5f;
diff --git a/source/blender/editors/gpencil/gpencil_ops.c 
b/source/blender/editors/gpencil/gpencil_ops.c
index a61f39458fc..0088c9dd847 100644
--- a/source/blender/editors/gpencil/gpencil_ops.c
+++ b/source/blender/editors/gpencil/gpencil_ops.c
@@ -443,6 +443,25 @@ static void ed_keymap_gpencil_painting_draw(wmKeyConfig 
*keyconf)
        kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, 
KM_PRESS, KM_SHIFT, 0);
        RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW_POLY);
        RNA_boolean_set(kmi->ptr, "wait_for_input", false);
+
+       /* erase */
+       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, 
KM_PRESS, KM_ALT, 0);
+       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
+       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
+
+       /* Tablet Mappings for Drawing ------------------ */
+       /* For now, only support direct drawing using the eraser, as most users 
using a tablet
+       * may still want to use that as their primary pointing device!
+       */
+#if 0
+       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_STYLUS, 
KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
+       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
+#endif
+
+       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_ERASER, 
KM_PRESS, 0, 0);
+       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
+       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
 }
 
 /* keys for draw with a fill brush */
@@ -460,12 +479,21 @@ static void ed_keymap_gpencil_painting_fill(wmKeyConfig 
*keyconf)
        kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_fill", LEFTMOUSE, 
KM_PRESS, KM_SHIFT, 0);
        RNA_boolean_set(kmi->ptr, "on_back", true);
 
-       /* if press alternative key, the brush now it's for drawing */  
+       /* if press alternative key, the brush now it's for drawing areas */    
        kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, 
KM_PRESS, KM_CTRL, 0);
        RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
        RNA_boolean_set(kmi->ptr, "wait_for_input", false);
        /* disable straight lines with Ctrl because there is a conflict of 
keymaps */
        RNA_boolean_set(kmi->ptr, "no_straight", true);
+
+       /* if press alternative key, the brush now it's for drawing lines */
+       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, 
KM_PRESS, KM_ALT, 0);
+       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
+       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
+       /* disable straight lines with Ctrl because there is a conflict of 
keymaps */
+       RNA_boolean_set(kmi->ptr, "no_straight", true);
+       /* enable special stroke with no fill flag */
+       RNA_boolean_set(kmi->ptr, "no_fill", true);
 }
 
 /* Stroke Painting Keymap - Only when paintmode is enabled */
@@ -477,25 +505,6 @@ static void ed_keymap_gpencil_painting(wmKeyConfig 
*keyconf)
        /* set poll callback - so that this keymap only gets enabled when 
stroke paintmode is enabled */
        keymap->poll = gp_stroke_paintmode_poll;
 
-       /* erase */
-       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", LEFTMOUSE, 
KM_PRESS, KM_ALT, 0);
-       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
-       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
-       /* Tablet Mappings for Drawing ------------------ */
-       /* For now, only support direct drawing using the eraser, as most users 
using a tablet
-       * may still want to use that as their primary pointing device!
-       */
-#if 0
-       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_STYLUS, 
KM_PRESS, 0, 0);
-       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_DRAW);
-       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-#endif
-
-       kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_draw", TABLET_ERASER, 
KM_PRESS, 0, 0);
-       RNA_enum_set(kmi->ptr, "mode", GP_PAINTMODE_ERASER);
-       RNA_boolean_set(kmi->ptr, "wait_for_input", false);
-
        /* Exit PaintMode */
        kmi = WM_keymap_add_item(keymap, "GPENCIL_OT_editmode_toggle", TABKEY, 
KM_PRESS, 0, 0);
        RNA_int_set(kmi->ptr, "back", 1);
diff --git a/source/blender/editors/gpencil/gpencil_paint.c 
b/source/blender/editors/gpencil/gpencil_paint.c
index 5c752520c27..6c0a2726e6f 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1655,7 +1655,7 @@ static void gp_session_cleanup(tGPsdata *p)
 }
 
 /* init new stroke */
-static void gp_paint_initstroke(tGPsdata *p, eGPencil_PaintModes paintmode)
+static void gp_paint_initstroke(wmOperator *op, tGPsdata *p, 
eGPencil_PaintModes paintmode)
 {
        Scene *scene = p->scene;
        ToolSettings *ts = scene->toolsettings;
@@ -1772,11 +1772,17 @@ static void gp_paint_initstroke(tGPsdata *p, 
eGPencil_PaintModes paintmode)
                        }
                }
        }
-       
+
+       /* set special fill stroke mode */
+       if (RNA_boolean_get(op->ptr, "no_fill") == true) {
+               p->gpd->sbuffer_sflag |= GP_STROKE_NOFILL;
+               /* replace stroke color with fill color */
+               copy_v4_v4(p->gpd->scolor, p->gpd->sfill);
+       }
+
        /* set 'initial run' flag, which is only used to denote when a new 
stroke is starting */
        p->flags |= GP_PAINTFLAG_FIRSTRUN;
        
-       
        /* when drawing in the camera view, in 2D space, set the subrect */
        p->subrect = NULL;
        if ((*p->align_flag & GP_PROJECT_VIEWSPACE) == 0) {
@@ -2041,7 +2047,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, 
const wmEvent *event)
        }
        
        /* init painting data */
-       gp_paint_initstroke(p, paintmode);
+       gp_paint_initstroke(op, p, paintmode);
        if (p->status == GP_STATUS_ERROR) {
                gpencil_draw_exit(C, op);
                return 0;
@@ -2141,7 +2147,7 @@ static void gpencil_draw_apply(wmOperator *op, tGPsdata 
*p)
                        /* finish off old stroke */
                        gp_paint_strokeend(p);
                        /* And start a new one!!! Else, projection errors! */
-                       gp_paint_initstroke(p, p->paintmode);
+                       gp_paint_initstroke(op, p, p->paintmode);
                        
                        /* start a new stroke, starting from previous point */
                        /* XXX Must manually reset inittime... */
@@ -2344,7 +2350,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
                        if ((p->flags & GP_PAINTFLAG_FIRSTRUN) == 0) {
                                /* TODO: both of these ops can set 
error-status, but we probably don't need to worry */
                                gp_paint_strokeend(p);
-                               gp_paint_initstroke(p, p->paintmode);
+                               gp_paint_initstroke(op, p, p->paintmode);
                        }
                }
                
@@ -2487,7 +2493,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, 
wmOperator *op)
         *      it'd be nice to allow changing paint-mode when in 
sketching-sessions */
        
        if (gp_session_initdata(C, p))
-               gp_paint_initstroke(p, p->paintmode);
+               gp_paint_initstroke(op, p, p->paintmode);
        
        if (p->status != GP_STATUS_ERROR) {
                p->status = GP_STATUS_PAINTING;
@@ -2913,4 +2919,7 @@ void GPENCIL_OT_draw(wmOperatorType *ot)
 
        prop = RNA_def_boolean(ot->srna, "no_straight", false, "No Straight 
lines", "Disable Ctrl key for straight lines");
        RNA_def_property_flag(prop, PROP_SKIP_SAVE);
+
+       prop = RNA_def_boolean(ot->srna, "no_fill", false, "No Fill Areas", 
"Disable fill to use stroke as fill boundary");
+       RNA_def_property_flag(prop, PROP_SKIP_SAVE);
 }
diff --git a/source/blender/makesdna/DNA_gpencil_types.h 
b/source/blender/makesdna/DNA_gpencil_types.h
index 5e53f9b7c05..81706d5f5b5 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -273,6 +273,8 @@ typedef enum eGPDstroke_Flag {
        GP_STROKE_RECALC_COLOR = (1 << 5),
        /* Flag used to indicate that stroke is closed and draw edge between 
last and first point */
        GP_STROKE_CYCLIC = (1 << 7),
+       /* Flag used to indicate that stroke is used for fill close and must 
use fill color for stroke and no fill area */
+       GP_STROKE_NOFILL = (1 << 8),
        /* only for use with stroke-buffer (while drawing eraser) */
        GP_STROKE_ERASER                = (1 << 15)
 } eGPDstroke_Flag;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c 
b/source/blender/makesrna/intern/rna_gpencil.c
index 8d6e093dae7..23192c2991b 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -970,6 +970,13 @@ static void rna_def_gpencil_stroke(BlenderR

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to