Fix Extend property of Lasso select tool in Mask editor not working
authorPhilipp Oeser <info@graphics-engineer.com>
Sun, 13 May 2018 08:46:00 +0000 (10:46 +0200)
committerPhilipp Oeser <info@graphics-engineer.com>
Thu, 24 May 2018 06:41:13 +0000 (08:41 +0200)
Reviewed By: campbellbarton

Differential Revision: https://developer.blender.org/D3361

source/blender/editors/mask/mask_select.c

index 7ffd82e262c2959a9ba1be1e77cd43ba4cee0f21..8559be67eceed609b796067aeb04e54df39f004e 100644 (file)
@@ -481,7 +481,7 @@ void MASK_OT_select_border(wmOperatorType *ot)
        WM_operator_properties_gesture_border_select(ot);
 }
 
-static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, short select)
+static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves, bool select, bool extend)
 {
        ScrArea *sa = CTX_wm_area(C);
        ARegion *ar = CTX_wm_region(C);
@@ -514,6 +514,10 @@ static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves
                                /* TODO: handles? */
                                /* TODO: uw? */
 
+                               if (MASKPOINT_ISSEL_ANY(point) && select && extend) {
+                                       continue;
+                               }
+
                                float screen_co[2];
 
                                /* point in screen coords */
@@ -526,9 +530,13 @@ static bool do_lasso_select_mask(bContext *C, const int mcords[][2], short moves
                                {
                                        BKE_mask_point_select_set(point, select);
                                        BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, select);
+                                       changed = true;
+                               }
+                               else if (select && !extend) {
+                                       BKE_mask_point_select_set(point, false);
+                                       BKE_mask_point_select_set_handle(point, MASK_WHICH_HANDLE_BOTH, false);
+                                       changed = true;
                                }
-
-                               changed = true;
                        }
                }
        }
@@ -548,10 +556,9 @@ static int clip_lasso_select_exec(bContext *C, wmOperator *op)
        const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot);
 
        if (mcords) {
-               short select;
-
-               select = !RNA_boolean_get(op->ptr, "deselect");
-               do_lasso_select_mask(C, mcords, mcords_tot, select);
+               const bool select = !RNA_boolean_get(op->ptr, "deselect");
+               const bool extend = RNA_boolean_get(op->ptr, "extend");
+               do_lasso_select_mask(C, mcords, mcords_tot, select, extend);
 
                MEM_freeN((void *)mcords);