GPencil: Move polygon to back only if something was drawn
authorAntonioya <blendergit@gmail.com>
Mon, 8 Aug 2016 09:21:44 +0000 (11:21 +0200)
committerAntonioya <blendergit@gmail.com>
Mon, 8 Aug 2016 09:26:28 +0000 (11:26 +0200)
If the user enable polygon draw and press ESC before drawing something,
the last stroke must not be moved back.

source/blender/editors/gpencil/gpencil_paint.c

index 4e521b5909c9a76590efef0eed5edc2ad76256d3..3afdd5772fc9b04655548d63f41e9c46c249264a 100644 (file)
@@ -2367,7 +2367,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
                /* printf("\t\tGP - end of paint op + end of stroke\n"); */
                /* if drawing polygon and enable on back, must move stroke */
                if ((p->scene->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                       gpencil_move_polygon_stroke_to_back(C);
+                       if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+                               gpencil_move_polygon_stroke_to_back(C);
+                       }
                }
                p->status = GP_STATUS_DONE;
                estate = OPERATOR_FINISHED;
@@ -2427,7 +2429,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
                                /* printf("\t\tGP - end of stroke + op\n"); */
                                /* if drawing polygon and enable on back, must move stroke */
                                if ((p->scene->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                                       gpencil_move_polygon_stroke_to_back(C);
+                                       if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+                                               gpencil_move_polygon_stroke_to_back(C);
+                                       }
                                }
                                p->status = GP_STATUS_DONE;
                                estate = OPERATOR_FINISHED;
@@ -2511,7 +2515,9 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
                                 */
                                /* if drawing polygon and enable on back, must move stroke */
                                if ((p->scene->toolsettings->gpencil_flags & GP_TOOL_FLAG_PAINT_ONBACK) && (p->paintmode == GP_PAINTMODE_DRAW_POLY)) {
-                                       gpencil_move_polygon_stroke_to_back(C);
+                                       if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+                                               gpencil_move_polygon_stroke_to_back(C);
+                                       }
                                }
                                p->status = GP_STATUS_DONE;
                                estate = OPERATOR_FINISHED;