diff options
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r-- | source/blender/editors/mask/mask_add.c | 27 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_draw.c | 33 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 3 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_editaction.c | 60 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_ops.c | 102 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_select.c | 24 |
6 files changed, 166 insertions, 83 deletions
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 1c872e73226..3c456f9e2e2 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -126,8 +126,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, dist_sq = dist_squared_to_line_segment_v2(co, a, b); if (dist_sq < dist_best_sq) { - if (tangent) + if (tangent) { sub_v2_v2v2(tangent, &diff_points[2 * j + 2], &diff_points[2 * j]); + } point_masklay = masklay; point_spline = spline; @@ -138,8 +139,9 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, } } - if (feather_points) + if (feather_points) { MEM_freeN(feather_points); + } MEM_freeN(diff_points); } @@ -148,14 +150,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, } if (point && dist_best_sq < threshold) { - if (masklay_r) + if (masklay_r) { *masklay_r = point_masklay; + } - if (spline_r) + if (spline_r) { *spline_r = point_spline; + } - if (point_r) + if (point_r) { *point_r = point; + } if (u_r) { /* TODO(sergey): Projection fails in some weirdo cases.. */ @@ -173,14 +178,17 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, return true; } - if (masklay_r) + if (masklay_r) { *masklay_r = NULL; + } - if (spline_r) + if (spline_r) { *spline_r = NULL; + } - if (point_r) + if (point_r) { *point_r = NULL; + } return false; } @@ -702,8 +710,9 @@ static int add_feather_vertex_exec(bContext *C, wmOperator *op) RNA_float_get_array(op->ptr, "location", co); point = ED_mask_point_find_nearest(C, mask, co, threshold, NULL, NULL, NULL, NULL); - if (point) + if (point) { return OPERATOR_FINISHED; + } if (ED_mask_find_nearest_diff_point( C, mask, co, threshold, true, NULL, true, true, &masklay, &spline, &point, &u, NULL)) { diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 479e4fd2d6c..305e3a328ab 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -203,11 +203,13 @@ static void draw_spline_points(const bContext *C, float(*feather_points)[2], (*fp)[2]; float min[2], max[2]; - if (!spline->tot_point) + if (!spline->tot_point) { return; + } - if (sc) + if (sc) { undistort = sc->clip && (sc->user.render_flag & MCLIP_PROXY_RENDER_UNDISTORT); + } /* TODO, add this to sequence editor */ float handle_size = 2.0f * UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize; @@ -233,8 +235,9 @@ static void draw_spline_points(const bContext *C, copy_v2_v2(feather_point, *fp); - if (undistort) + if (undistort) { mask_point_undistort_pos(sc, feather_point, feather_point); + } if (j == 0) { sel = MASKPOINT_ISSEL_ANY(point); @@ -244,10 +247,12 @@ static void draw_spline_points(const bContext *C, } if (sel) { - if (point == masklay->act_point) + if (point == masklay->act_point) { immUniformColor3f(1.0f, 1.0f, 1.0f); - else + } + else { immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255); + } } else { immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255); @@ -314,13 +319,16 @@ static void draw_spline_points(const bContext *C, /* draw CV point */ if (MASKPOINT_ISSEL_KNOT(point)) { - if (point == masklay->act_point) + if (point == masklay->act_point) { immUniformColor3f(1.0f, 1.0f, 1.0f); - else + } + else { immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX_SELECT, 0, 255); + } } - else + else { immUniformThemeColorShadeAlpha(TH_HANDLE_VERTEX, 0, 255); + } immBegin(GPU_PRIM_POINTS, 1); immVertex2fv(pos, vert); @@ -502,8 +510,9 @@ static void mask_draw_curve_type(const bContext *C, BLI_assert(false); } - if (points != orig_points) + if (points != orig_points) { MEM_freeN(points); + } } static void draw_spline_curve(const bContext *C, @@ -533,8 +542,9 @@ static void draw_spline_curve(const bContext *C, diff_points = BKE_mask_spline_differentiate_with_resolution(spline, &tot_diff_point, resol); - if (!diff_points) + if (!diff_points) { return; + } if (is_smooth) { GPU_line_smooth(true); @@ -633,8 +643,9 @@ void ED_mask_draw(const bContext *C, const char draw_flag, const char draw_type) Mask *mask = CTX_data_edit_mask(C); int width, height; - if (!mask) + if (!mask) { return; + } ED_mask_get_size(sa, &width, &height); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 7325686d4f0..454e7e2a731 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -374,8 +374,9 @@ bool ED_mask_selected_minmax(const bContext *C, float min[2], float max[2]) MaskLayer *mask_layer; bool ok = false; - if (mask == NULL) + if (mask == NULL) { return ok; + } INIT_MINMAX2(min, max); for (mask_layer = mask->masklayers.first; mask_layer != NULL; mask_layer = mask_layer->next) { diff --git a/source/blender/editors/mask/mask_editaction.c b/source/blender/editors/mask/mask_editaction.c index d30e62d89f5..985fa58cace 100644 --- a/source/blender/editors/mask/mask_editaction.c +++ b/source/blender/editors/mask/mask_editaction.c @@ -60,15 +60,17 @@ bool ED_masklayer_frames_looper(MaskLayer *masklay, MaskLayerShape *masklay_shape; /* error checker */ - if (masklay == NULL) + if (masklay == NULL) { return false; + } /* do loop */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { /* execute callback */ - if (masklay_shape_cb(masklay_shape, scene)) + if (masklay_shape_cb(masklay_shape, scene)) { return true; + } } /* nothing to return */ @@ -85,8 +87,9 @@ void ED_masklayer_make_cfra_list(MaskLayer *masklay, ListBase *elems, bool onlys CfraElem *ce; /* error checking */ - if (ELEM(NULL, masklay, elems)) + if (ELEM(NULL, masklay, elems)) { return; + } /* loop through mask-frames, adding */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; @@ -111,14 +114,16 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay) MaskLayerShape *masklay_shape; /* error checking */ - if (masklay == NULL) + if (masklay == NULL) { return 0; + } /* stop at the first one found */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { - if (masklay_shape->flag & MASK_SHAPE_SELECT) + if (masklay_shape->flag & MASK_SHAPE_SELECT) { return 1; + } } /* not found */ @@ -128,8 +133,9 @@ bool ED_masklayer_frame_select_check(MaskLayer *masklay) /* helper function - select mask-frame based on SELECT_* mode */ static void masklayshape_select(MaskLayerShape *masklay_shape, short select_mode) { - if (masklay_shape == NULL) + if (masklay_shape == NULL) { return; + } switch (select_mode) { case SELECT_ADD: @@ -150,8 +156,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode) MaskLayerShape *masklay_shape; /* error checking */ - if (masklay == NULL) + if (masklay == NULL) { return; + } /* handle according to mode */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; @@ -164,8 +171,9 @@ void ED_mask_select_frames(MaskLayer *masklay, short select_mode) void ED_masklayer_frame_select_set(MaskLayer *masklay, short mode) { /* error checking */ - if (masklay == NULL) + if (masklay == NULL) { return; + } /* now call the standard function */ ED_mask_select_frames(masklay, mode); @@ -176,8 +184,9 @@ void ED_mask_select_frame(MaskLayer *masklay, int selx, short select_mode) { MaskLayerShape *masklay_shape; - if (masklay == NULL) + if (masklay == NULL) { return; + } masklay_shape = BKE_mask_layer_shape_find_frame(masklay, selx); @@ -191,14 +200,16 @@ void ED_masklayer_frames_select_box(MaskLayer *masklay, float min, float max, sh { MaskLayerShape *masklay_shape; - if (masklay == NULL) + if (masklay == NULL) { return; + } /* only select those frames which are in bounds */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = masklay_shape->next) { - if (IN_RANGE(masklay_shape->frame, min, max)) + if (IN_RANGE(masklay_shape->frame, min, max)) { masklayshape_select(masklay_shape, select_mode); + } } } @@ -210,8 +221,9 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked, { MaskLayerShape *masklay_shape; - if (masklay == NULL) + if (masklay == NULL) { return; + } /* only select frames which are within the region */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; @@ -225,13 +237,15 @@ void ED_masklayer_frames_select_region(KeyframeEditData *ked, /* check the necessary regions */ if (tool == BEZT_OK_CHANNEL_LASSO) { /* Lasso */ - if (keyframe_region_lasso_test(ked->data, pt)) + if (keyframe_region_lasso_test(ked->data, pt)) { masklayshape_select(masklay_shape, select_mode); + } } else if (tool == BEZT_OK_CHANNEL_CIRCLE) { /* Circle */ - if (keyframe_region_circle_test(ked->data, pt)) + if (keyframe_region_circle_test(ked->data, pt)) { masklayshape_select(masklay_shape, select_mode); + } } } } @@ -246,8 +260,9 @@ bool ED_masklayer_frames_delete(MaskLayer *masklay) bool changed = false; /* error checking */ - if (masklay == NULL) + if (masklay == NULL) { return false; + } /* check for frames to delete */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; @@ -269,8 +284,9 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay) MaskLayerShape *masklay_shape, *gpfn; /* error checking */ - if (masklay == NULL) + if (masklay == NULL) { return; + } /* duplicate selected frames */ for (masklay_shape = masklay->splines_shapes.first; masklay_shape; masklay_shape = gpfn) { @@ -295,31 +311,35 @@ void ED_masklayer_frames_duplicate(MaskLayer *masklay) static short snap_masklayer_nearest(MaskLayerShape *masklay_shape, Scene *UNUSED(scene)) { - if (masklay_shape->flag & MASK_SHAPE_SELECT) + if (masklay_shape->flag & MASK_SHAPE_SELECT) { masklay_shape->frame = (int)(floor(masklay_shape->frame + 0.5)); + } return 0; } static short snap_masklayer_nearestsec(MaskLayerShape *masklay_shape, Scene *scene) { float secf = (float)FPS; - if (masklay_shape->flag & MASK_SHAPE_SELECT) + if (masklay_shape->flag & MASK_SHAPE_SELECT) { masklay_shape->frame = (int)(floorf(masklay_shape->frame / secf + 0.5f) * secf); + } return 0; } static short snap_masklayer_cframe(MaskLayerShape *masklay_shape, Scene *scene) { - if (masklay_shape->flag & MASK_SHAPE_SELECT) + if (masklay_shape->flag & MASK_SHAPE_SELECT) { masklay_shape->frame = (int)CFRA; + } return 0; } static short snap_masklayer_nearmarker(MaskLayerShape *masklay_shape, Scene *scene) { - if (masklay_shape->flag & MASK_SHAPE_SELECT) + if (masklay_shape->flag & MASK_SHAPE_SELECT) { masklay_shape->frame = (int)ED_markers_find_nearest_marker_time(&scene->markers, (float)masklay_shape->frame); + } return 0; } diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 2b925b9095e..ab774fa13df 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -179,29 +179,36 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, } if (len_sq < threshold_sq) { - if (masklay_r) + if (masklay_r) { *masklay_r = point_masklay; + } - if (spline_r) + if (spline_r) { *spline_r = point_spline; + } - if (which_handle_r) + if (which_handle_r) { *which_handle_r = which_handle; + } - if (score) + if (score) { *score = sqrtf(len_sq); + } return point; } - if (masklay_r) + if (masklay_r) { *masklay_r = NULL; + } - if (spline_r) + if (spline_r) { *spline_r = NULL; + } - if (which_handle_r) + if (which_handle_r) { *which_handle_r = MASK_WHICH_HANDLE_NONE; + } return NULL; } @@ -262,10 +269,12 @@ bool ED_mask_feather_find_nearest(const bContext *C, cur_len_sq = len_squared_v2v2(vec, co); if (point == NULL || cur_len_sq < len) { - if (j == 0) + if (j == 0) { uw = NULL; - else + } + else { uw = &cur_point->uw[j - 1]; + } point_masklay = masklay; point_spline = spline; @@ -282,32 +291,40 @@ bool ED_mask_feather_find_nearest(const bContext *C, } if (len < threshold_sq) { - if (masklay_r) + if (masklay_r) { *masklay_r = point_masklay; + } - if (spline_r) + if (spline_r) { *spline_r = point_spline; + } - if (point_r) + if (point_r) { *point_r = point; + } - if (uw_r) + if (uw_r) { *uw_r = uw; + } - if (score) + if (score) { *score = sqrtf(len); + } return true; } - if (masklay_r) + if (masklay_r) { *masklay_r = NULL; + } - if (spline_r) + if (spline_r) { *spline_r = NULL; + } - if (point_r) + if (point_r) { *point_r = NULL; + } return false; } @@ -720,10 +737,12 @@ static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent * } if (cv_point && action == SLIDE_ACTION_NONE) { - if (which_handle != MASK_WHICH_HANDLE_NONE) + if (which_handle != MASK_WHICH_HANDLE_NONE) { action = SLIDE_ACTION_HANDLE; - else + } + else { action = SLIDE_ACTION_POINT; + } masklay = cv_masklay; spline = cv_spline; @@ -851,8 +870,9 @@ static void slide_point_restore_spline(SlidePointData *data) point->bezt = orig_point->bezt; - for (j = 0; j < point->tot_uw; j++) + for (j = 0; j < point->tot_uw; j++) { point->uw[j] = orig_point->uw[j]; + } } } @@ -865,10 +885,12 @@ static void cancel_slide_point(SlidePointData *data) } else { if (data->action == SLIDE_ACTION_FEATHER) { - if (data->uw) + if (data->uw) { data->uw->w = data->weight; - else + } + else { data->point->bezt.weight = data->weight; + } } else if (data->action != SLIDE_ACTION_SPLINE) { copy_m3_m3(data->point->bezt.vec, data->vec); @@ -880,8 +902,9 @@ static void cancel_slide_point(SlidePointData *data) static void free_slide_point_data(SlidePointData *data) { - if (data->orig_spline) + if (data->orig_spline) { BKE_mask_spline_free(data->orig_spline); + } MEM_freeN(data); } @@ -906,8 +929,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) } } - if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) + if (ELEM(event->type, LEFTSHIFTKEY, RIGHTSHIFTKEY)) { data->is_accurate = (event->val == KM_PRESS); + } ATTR_FALLTHROUGH; /* update CV position */ case MOUSEMOVE: { @@ -1028,8 +1052,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) if (is_overall_feather) { float w_delta; - if (dot_v2v2(no, vec) <= 0.0f) + if (dot_v2v2(no, vec) <= 0.0f) { w = -w; + } w_delta = w - data->weight * data->weight_scalar; @@ -1049,8 +1074,9 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) slide_point_delta_all_feather(data, w_delta); } else { - if (dot_v2v2(no, vec) <= 0.0f) + if (dot_v2v2(no, vec) <= 0.0f) { w = 0.0f; + } if (data->orig_spline) { /* restore possible overall feather changes */ @@ -1586,12 +1612,14 @@ static void delete_feather_points(MaskSplinePoint *point) { int i, count = 0; - if (!point->tot_uw) + if (!point->tot_uw) { return; + } for (i = 0; i < point->tot_uw; i++) { - if ((point->uw[i].flag & SELECT) == 0) + if ((point->uw[i].flag & SELECT) == 0) { count++; + } } if (count == 0) { @@ -1644,8 +1672,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - if (!MASKPOINT_ISSEL_ANY(point)) + if (!MASKPOINT_ISSEL_ANY(point)) { count++; + } } if (count == 0) { @@ -1670,8 +1699,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) MaskSplinePoint *point = &spline->points[i]; if (!MASKPOINT_ISSEL_ANY(point)) { - if (point == masklay->act_point) + if (point == masklay->act_point) { masklay->act_point = &new_points[j]; + } delete_feather_points(point); @@ -1679,8 +1709,9 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) j++; } else { - if (point == masklay->act_point) + if (point == masklay->act_point) { masklay->act_point = NULL; + } BKE_mask_point_free(point); spline->tot_point--; @@ -2138,14 +2169,16 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op) MaskLayer *mask_layer_other; int direction = RNA_enum_get(op->ptr, "direction"); - if (!mask_layer) + if (!mask_layer) { return OPERATOR_CANCELLED; + } if (direction == -1) { mask_layer_other = mask_layer->prev; - if (!mask_layer_other) + if (!mask_layer_other) { return OPERATOR_CANCELLED; + } BLI_remlink(&mask->masklayers, mask_layer); BLI_insertlinkbefore(&mask->masklayers, mask_layer_other, mask_layer); @@ -2154,8 +2187,9 @@ static int mask_layer_move_exec(bContext *C, wmOperator *op) else if (direction == 1) { mask_layer_other = mask_layer->next; - if (!mask_layer_other) + if (!mask_layer_other) { return OPERATOR_CANCELLED; + } BLI_remlink(&mask->masklayers, mask_layer); BLI_insertlinkafter(&mask->masklayers, mask_layer_other, mask_layer); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 076f8d067b9..00699c8ffe0 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -57,8 +57,9 @@ bool ED_mask_spline_select_check(MaskSpline *spline) for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; - if (MASKPOINT_ISSEL_ANY(point)) + if (MASKPOINT_ISSEL_ANY(point)) { return true; + } } return false; @@ -99,10 +100,12 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select) { int i; - if (do_select) + if (do_select) { spline->flag |= SELECT; - else + } + else { spline->flag &= ~SELECT; + } for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -131,10 +134,12 @@ void ED_mask_select_toggle_all(Mask *mask, int action) MaskLayer *masklay; if (action == SEL_TOGGLE) { - if (ED_mask_select_check(mask)) + if (ED_mask_select_check(mask)) { action = SEL_DESELECT; - else + } + else { action = SEL_SELECT; + } } for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { @@ -265,8 +270,9 @@ static int select_exec(bContext *C, wmOperator *op) point = ED_mask_point_find_nearest( C, mask, co, threshold, &masklay, &spline, &which_handle, NULL); - if (extend == false && deselect == false && toggle == false) + if (extend == false && deselect == false && toggle == false) { ED_mask_select_toggle_all(mask, SEL_DESELECT); + } if (point) { if (which_handle != MASK_WHICH_HANDLE_NONE) { @@ -333,12 +339,14 @@ static int select_exec(bContext *C, wmOperator *op) masklay->act_spline = spline; masklay->act_point = point; - if (uw) + if (uw) { uw->flag |= SELECT; + } } else if (deselect) { - if (uw) + if (uw) { uw->flag &= ~SELECT; + } } else { masklay->act_spline = spline; |