[Bf-blender-cvs] [69aee563dba] tracking_tools: Masking: Slide origin with draw_mask tool

Sebastian Koenig noreply at git.blender.org
Tue Jul 20 11:16:24 CEST 2021


Commit: 69aee563dbaadb4d0c2cd179d332c397fc2a1efe
Author: Sebastian Koenig
Date:   Tue Jul 20 10:05:13 2021 +0200
Branches: tracking_tools
https://developer.blender.org/rB69aee563dbaadb4d0c2cd179d332c397fc2a1efe

Masking: Slide origin with draw_mask tool

The mask tool creates a curve point when leftclicking. When clicking
near an existing point it switches to select and move instead. The same
happens now when clicking near the origin point so it is now possible to move the
entire mask again with LMB.
Patch by Sergey, thanks a lot!

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

M	source/blender/editors/mask/mask_add.c
M	source/blender/editors/mask/mask_intern.h
M	source/blender/editors/mask/mask_ops.c

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

diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 65a9b416f65..cc19e0017d4 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -541,8 +541,25 @@ static int add_vertex_exec(bContext *C, wmOperator *op)
     properties.toggle = false;
 
     if (ED_mask_select_mouse_pick(C, co, &properties)) {
+      ED_mask_view_lock_state_restore_no_jump(C, &lock_state);
       return OPERATOR_FINISHED;
     }
+
+    MaskLayer *mask_layer_under_mouse;
+    MaskSpline *spline_under_mouse;
+    if (ED_mask_spline_under_mouse_get(
+            C, mask, co, &mask_layer_under_mouse, &spline_under_mouse)) {
+      if (mask_layer_under_mouse == mask_layer) {
+        mask_layer->act_spline = spline_under_mouse;
+
+        DEG_id_tag_update(&mask->id, ID_RECALC_SELECT);
+        WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask);
+
+        ED_mask_view_lock_state_restore_no_jump(C, &lock_state);
+
+        return OPERATOR_FINISHED;
+      }
+    }
   }
 
   /* TODO: having an active point but no active spline is possible, why? */
diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h
index 4842982e489..49053ad06df 100644
--- a/source/blender/editors/mask/mask_intern.h
+++ b/source/blender/editors/mask/mask_intern.h
@@ -40,6 +40,11 @@ void MASK_OT_primitive_square_add(struct wmOperatorType *ot);
 /* mask_ops.c */
 struct Mask *ED_mask_new(struct bContext *C, const char *name);
 struct MaskLayer *ED_mask_layer_ensure(struct bContext *C, bool *r_added_mask);
+bool ED_mask_spline_under_mouse_get(const struct bContext *C,
+                                    struct Mask *mask,
+                                    const float co[2],
+                                    MaskLayer **r_mask_layer,
+                                    MaskSpline **r_mask_spline);
 
 void MASK_OT_new(struct wmOperatorType *ot);
 void MASK_OT_layer_new(struct wmOperatorType *ot);
diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c
index 6fa7457ce14..376e3ac8cbd 100644
--- a/source/blender/editors/mask/mask_ops.c
+++ b/source/blender/editors/mask/mask_ops.c
@@ -261,11 +261,11 @@ static void mask_point_undistort_pos(SpaceClip *sc, float r_co[2], const float c
   BKE_mask_coord_from_movieclip(sc->clip, &sc->user, r_co, r_co);
 }
 
-static bool spline_under_mouse_get(const bContext *C,
-                                   Mask *mask,
-                                   const float co[2],
-                                   MaskLayer **r_mask_layer,
-                                   MaskSpline **r_mask_spline)
+bool ED_mask_spline_under_mouse_get(const bContext *C,
+                                    Mask *mask,
+                                    const float co[2],
+                                    MaskLayer **r_mask_layer,
+                                    MaskSpline **r_mask_spline)
 {
   const float threshold = 19.0f;
   ScrArea *area = CTX_wm_area(C);
@@ -480,7 +480,7 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
   }
 
   if (action == SLIDE_ACTION_NONE) {
-    if (spline_under_mouse_get(C, mask, co, &mask_layer, &spline)) {
+    if (ED_mask_spline_under_mouse_get(C, mask, co, &mask_layer, &spline)) {
       action = SLIDE_ACTION_SPLINE;
       point = NULL;
     }
@@ -498,7 +498,9 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *
     customdata->action = action;
     customdata->uw = uw;
 
-    customdata->is_sliding_new_point = RNA_boolean_get(op->ptr, "is_new_point");
+    if (point != NULL) {
+      customdata->is_sliding_new_point = RNA_boolean_get(op->ptr, "is_new_point");
+    }
 
     if (customdata->action != SLIDE_ACTION_SPLINE) {
       customdata->old_h1 = point->bezt.h1;



More information about the Bf-blender-cvs mailing list