Small refactor of mask sliding operator
[blender.git] / source / blender / editors / transform / transform_conversions.c
index f563a7a089d2d98032631d7b6f33f380821d654b..8a7caeb30601325de16a37cd325c9666415a7940 100644 (file)
@@ -4915,7 +4915,7 @@ void special_aftertrans_update(bContext *C, TransInfo *t)
                        if (IS_AUTOKEY_ON(t->scene)) {
                                Scene *scene = t->scene;
 
-                               ED_mask_object_shape_auto_key_all(mask, CFRA);
+                               ED_mask_layer_shape_auto_key_all(mask, CFRA);
                        }
                }
        }
@@ -5890,7 +5890,8 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
 {
        BezTriple *bezt = &point->bezt;
        float aspx, aspy;
-       short is_sel_point = MASKPOINT_ISSEL(point);
+       short is_sel_point = MASKPOINT_ISSEL_KNOT(point);
+       short is_sel_any = MASKPOINT_ISSEL_ANY(point);
 
        tdm->point = point;
        copy_m3_m3(tdm->vec, bezt->vec);
@@ -5920,7 +5921,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
                        td->ext= NULL;
                        td->val= NULL;
 
-                       if (is_sel_point) {
+                       if (is_sel_any) {
                                td->flag |= TD_SELECTED;
                        }
                        td->dist= 0.0;
@@ -5955,7 +5956,7 @@ static void MaskPointToTransData(SpaceClip *sc, MaskSplinePoint *point,
                td->ext= NULL;
                td->val= NULL;
 
-               if (is_sel_point) {
+               if (is_sel_any) {
                        td->flag |= TD_SELECTED;
                }
 
@@ -5973,7 +5974,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
 {
        SpaceClip *sc = CTX_wm_space_clip(C);
        Mask *mask = CTX_data_edit_mask(C);
-       MaskObject *maskobj;
+       MaskLayer *masklay;
        TransData *td = NULL;
        TransData2D *td2d = NULL;
        TransDataMasking *tdm = NULL;
@@ -5981,21 +5982,21 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
        int propmode = t->flag & T_PROP_EDIT;
 
        /* count */
-       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
-               MaskSpline *spline = maskobj->splines.first;
+       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+               MaskSpline *spline = masklay->splines.first;
 
-               if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+               if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
                        continue;
                }
 
-               for (spline = maskobj->splines.first; spline; spline = spline->next) {
+               for (spline = masklay->splines.first; spline; spline = spline->next) {
                        int i;
 
                        for (i = 0; i < spline->tot_point; i++) {
                                MaskSplinePoint *point = &spline->points[i];
 
-                               if (MASKPOINT_ISSEL(point)) {
-                                       if (MASKPOINT_CV_ISSEL(point))
+                               if (MASKPOINT_ISSEL_ANY(point)) {
+                                       if (MASKPOINT_ISSEL_KNOT(point))
                                                countsel += 3;
                                        else
                                                countsel += 1;
@@ -6020,23 +6021,23 @@ static void createTransMaskingData(bContext *C, TransInfo *t)
        t->flag |= T_FREE_CUSTOMDATA;
 
        /* create data */
-       for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) {
-               MaskSpline *spline = maskobj->splines.first;
+       for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) {
+               MaskSpline *spline = masklay->splines.first;
 
-               if (maskobj->restrictflag & MASK_RESTRICT_VIEW) {
+               if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) {
                        continue;
                }
 
-               for (spline = maskobj->splines.first; spline; spline = spline->next) {
+               for (spline = masklay->splines.first; spline; spline = spline->next) {
                        int i;
 
                        for (i = 0; i < spline->tot_point; i++) {
                                MaskSplinePoint *point = &spline->points[i];
 
-                               if (propmode || MASKPOINT_ISSEL(point)) {
+                               if (propmode || MASKPOINT_ISSEL_ANY(point)) {
                                        MaskPointToTransData(sc, point, td, td2d, tdm, propmode);
 
-                                       if (propmode || MASKPOINT_CV_ISSEL(point)) {
+                                       if (propmode || MASKPOINT_ISSEL_KNOT(point)) {
                                                td += 3;
                                                td2d += 3;
                                                tdm += 3;
@@ -6070,7 +6071,7 @@ void flushTransMasking(TransInfo *t)
                td->loc2d[1]= td->loc[1]*invy;
 
                if (tdm->is_handle)
-                       BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, aspx, aspy, tdm->orig_handle, tdm->vec);
+                       BKE_mask_point_set_handle(tdm->point, td->loc2d, t->flag & T_ALT_TRANSFORM, tdm->orig_handle, tdm->vec);
        }
 }