diff options
author | Antonioya <blendergit@gmail.com> | 2019-01-11 21:15:23 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2019-01-11 21:21:56 +0300 |
commit | bb9c9d0eaaab836b8f20ab7b2228795f607b823a (patch) | |
tree | 8fd6ebad4084c66e6d1a49849ed6b9dbbc126d22 /source/blender/editors/gpencil/gpencil_primitive.c | |
parent | 6dbfd7f6d6bc9bea9556861eba682a3126b5ed40 (diff) |
GP: New Cutter, Constraints and Segment selection
This commit groups a set of new tools that were tested in grease pencil object branch before moving to master. We decide to do all the development in a separated branch because it could break master during days or weeks before the new tools were ready to deploy.
The commit includes:
- New Cutter tool to trim strokes and help cleaning up drawings.
- New set of constraints and guides to draw different types of shapes. All the credits for this development goes to Charlie Jolly (@charlie), thanks for your help!
- Segment selection mode to select strokes between intersections.
- New operator to change strokes cap mode.
- New option to display only keyframed frames. This option is very important when fill strokes with color.
- Multiple small fixes and tweaks.
Thanks to @pepeland and @mendio for their ideas, tests, reviews and support.
Note: Still pending the final icons for Cutter in Toolbar and Segment Selection in Topbar. @billreynish could help us here?
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 61 |
1 files changed, 42 insertions, 19 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 6849e876bf5..ba49afd0680 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -18,7 +18,7 @@ * The Original Code is Copyright (C) 2017, Blender Foundation * This is a new part of Blender * - * Contributor(s): Antonio Vazquez + * Contributor(s): Antonio Vazquez, Charlie Jolly * * ***** END GPL LICENSE BLOCK ***** * @@ -248,6 +248,15 @@ static void gp_primitive_update_cps(tGPDprimitive *tgpi) } } +/* Helper to reflect point */ +static void gp_reflect_point_v2_v2v2v2(float va[2], const float p[2], const float a[2], const float b[2]) +{ + float point[2]; + closest_to_line_v2(point, p, a, b); + va[0] = point[0] - (p[0] - point[0]); + va[1] = point[1] - (p[1] - point[1]); +} + /* Poll callback for primitive operators */ static bool gpencil_primitive_add_poll(bContext *C) { @@ -677,7 +686,8 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* compute screen-space coordinates for points */ tGPspoint *points2D = tgpi->points; - switch (tgpi->type) { + if (tgpi->tot_edges > 1) { + switch (tgpi->type) { case GP_STROKE_BOX: gp_primitive_rectangle(tgpi, points2D); break; @@ -694,6 +704,7 @@ static void gp_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) gp_primitive_bezier(tgpi, points2D); default: break; + } } /* convert screen-coordinates to 3D coordinates */ @@ -1321,7 +1332,7 @@ static void gpencil_primitive_edit_event_handling(bContext *C, wmOperator *op, w { if ((event->val == KM_PRESS) && (tgpi->curve) && - (tgpi->orign_type == GP_STROKE_ARC)) + (ELEM(tgpi->orign_type, GP_STROKE_ARC) )) { tgpi->flip ^= 1; gp_primitive_update_cps(tgpi); @@ -1432,22 +1443,22 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e if (tgpi->flag == IN_MOVE) { switch (event->type) { - case MOUSEMOVE: - gpencil_primitive_move(tgpi, false); - gpencil_primitive_update(C, op, tgpi); - break; - case ESCKEY: - case LEFTMOUSE: - zero_v2(tgpi->move); + case MOUSEMOVE: + gpencil_primitive_move(tgpi, false); + gpencil_primitive_update(C, op, tgpi); + break; + case ESCKEY: + case LEFTMOUSE: + zero_v2(tgpi->move); + tgpi->flag = IN_CURVE_EDIT; + break; + case RIGHTMOUSE: + if (event->val == KM_RELEASE) { tgpi->flag = IN_CURVE_EDIT; - break; - case RIGHTMOUSE: - if (event->val == KM_RELEASE) { - tgpi->flag = IN_CURVE_EDIT; - gpencil_primitive_move(tgpi, true); - gpencil_primitive_update(C, op, tgpi); - } - break; + gpencil_primitive_move(tgpi, true); + gpencil_primitive_update(C, op, tgpi); + } + break; } copy_v2_v2(tgpi->mvalo, tgpi->mval); return OPERATOR_RUNNING_MODAL; @@ -1543,7 +1554,19 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e /* done! */ return OPERATOR_FINISHED; } - case RIGHTMOUSE: /* cancel */ + case RIGHTMOUSE: + { + /* exception to cancel current stroke when we have previous strokes in buffer */ + if (tgpi->tot_stored_edges > 0) { + tgpi->flag = IDLE; + tgpi->tot_edges = 0; + gp_primitive_update_strokes(C, tgpi); + gpencil_primitive_interaction_end(C, op, win, tgpi); + /* done! */ + return OPERATOR_FINISHED; + } + ATTR_FALLTHROUGH; + } case ESCKEY: { /* return to normal cursor and header status */ |