diff options
author | Jacques Lucke <jacques@blender.org> | 2020-09-09 17:35:20 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-09-09 17:36:57 +0300 |
commit | f8aad78830c185af50ab08f9362d637a23746447 (patch) | |
tree | 414d60581b68b20d85381817ea312a554a25b564 /source/blender/blenkernel/intern/mask.c | |
parent | 42e3eb8854c9495a197fd5fa9d0f7990c24cafa7 (diff) |
Cleanup: reduce variable scopes
Diffstat (limited to 'source/blender/blenkernel/intern/mask.c')
-rw-r--r-- | source/blender/blenkernel/intern/mask.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index 79b8a30242e..272c9fda9ae 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -362,7 +362,6 @@ void BKE_mask_point_direction_switch(MaskSplinePoint *point) { const int tot_uw = point->tot_uw; const int tot_uw_half = tot_uw / 2; - int i; float co_tmp[2]; @@ -377,14 +376,14 @@ void BKE_mask_point_direction_switch(MaskSplinePoint *point) /* swap UW's */ if (tot_uw > 1) { /* count */ - for (i = 0; i < tot_uw_half; i++) { + for (int i = 0; i < tot_uw_half; i++) { MaskSplinePointUW *uw_a = &point->uw[i]; MaskSplinePointUW *uw_b = &point->uw[tot_uw - (i + 1)]; SWAP(MaskSplinePointUW, *uw_a, *uw_b); } } - for (i = 0; i < tot_uw; i++) { + for (int i = 0; i < tot_uw; i++) { MaskSplinePointUW *uw = &point->uw[i]; uw->u = 1.0f - uw->u; } @@ -731,10 +730,8 @@ float BKE_mask_point_weight(MaskSpline *spline, MaskSplinePoint *point, const fl } float cur_u = 0.0f, cur_w = 0.0f, next_u = 0.0f, next_w = 0.0f, fac; /* Quite warnings */ - int i; - - for (i = 0; i <= point->tot_uw; i++) { + for (int i = 0; i <= point->tot_uw; i++) { if (i == 0) { cur_u = 0.0f; cur_w = 1.0f; /* mask_point_interp_weight will scale it */ @@ -815,8 +812,6 @@ void BKE_mask_point_add_uw(MaskSplinePoint *point, float u, float w) void BKE_mask_point_select_set(MaskSplinePoint *point, const bool do_select) { - int i; - if (do_select) { MASKPOINT_SEL_ALL(point); } @@ -824,7 +819,7 @@ void BKE_mask_point_select_set(MaskSplinePoint *point, const bool do_select) MASKPOINT_DESEL_ALL(point); } - for (i = 0; i < point->tot_uw; i++) { + for (int i = 0; i < point->tot_uw; i++) { if (do_select) { point->uw[i].flag |= SELECT; } @@ -979,12 +974,9 @@ void BKE_mask_spline_free_list(ListBase *splines) static MaskSplinePoint *mask_spline_points_copy(const MaskSplinePoint *points, int tot_point) { - MaskSplinePoint *npoints; - int i; - - npoints = MEM_dupallocN(points); + MaskSplinePoint *npoints = MEM_dupallocN(points); - for (i = 0; i < tot_point; i++) { + for (int i = 0; i < tot_point; i++) { MaskSplinePoint *point = &npoints[i]; if (point->uw) { @@ -1435,8 +1427,7 @@ void BKE_mask_layer_calc_handles(MaskLayer *masklay) { MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { BKE_mask_calc_handle_point(spline, &spline->points[i]); } } @@ -1451,9 +1442,7 @@ void BKE_mask_spline_ensure_deform(MaskSpline *spline) // printf("alloc new deform spline\n"); if (spline->points_deform) { - int i; - - for (i = 0; i < allocated_points; i++) { + for (int i = 0; i < allocated_points; i++) { MaskSplinePoint *point = &spline->points_deform[i]; BKE_mask_point_free(point); } @@ -1538,8 +1527,7 @@ void BKE_mask_layer_shape_from_mask(MaskLayer *masklay, MaskLayerShape *masklay_ MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { mask_layer_shape_from_mask_point(&spline->points[i].bezt, fp); fp += MASK_OBJECT_SHAPE_ELEM_SIZE; } @@ -1563,8 +1551,7 @@ void BKE_mask_layer_shape_to_mask(MaskLayer *masklay, MaskLayerShape *masklay_sh MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { mask_layer_shape_to_mask_point(&spline->points[i].bezt, fp); fp += MASK_OBJECT_SHAPE_ELEM_SIZE; } @@ -1600,8 +1587,7 @@ void BKE_mask_layer_shape_to_mask_interp(MaskLayer *masklay, MaskSpline *spline; for (spline = masklay->splines.first; spline; spline = spline->next) { - int i; - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { BezTriple *bezt = &spline->points[i].bezt; /* *** BKE_mask_layer_shape_from_mask - swapped *** */ interp_v2_v2v2_flfl(bezt->vec[0], fp_a, fp_b, fac, ifac); @@ -1836,9 +1822,8 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, const int pi_prev_abs = pi_prev + index_offset; const int pi_next_abs = pi_next + index_offset; - int i; if (do_init_interpolate) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { interp_weights_uv_v2_calc(uv[i], spline->points[pi_curr].bezt.vec[i], spline->points[pi_prev].bezt.vec[i], @@ -1873,7 +1858,7 @@ void BKE_mask_layer_shape_changed_add(MaskLayer *masklay, mask_layer_shape_from_mask_point(&spline->points[spline_point_index].bezt, fp); if (do_init_interpolate && spline->tot_point > 2) { - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { interp_weights_uv_v2_apply( uv[i], &fp[i * 2], @@ -1988,8 +1973,7 @@ void BKE_mask_clipboard_copy_from_layer(MaskLayer *mask_layer) for (spline = mask_layer->splines.first; spline; spline = spline->next) { if (spline->flag & SELECT) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); - int i; - for (i = 0; i < spline_new->tot_point; i++) { + for (int i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { if (!BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id)) { @@ -2019,9 +2003,8 @@ void BKE_mask_clipboard_paste_to_layer(Main *bmain, MaskLayer *mask_layer) for (spline = mask_clipboard.splines.first; spline; spline = spline->next) { MaskSpline *spline_new = BKE_mask_spline_copy(spline); - int i; - for (i = 0; i < spline_new->tot_point; i++) { + for (int i = 0; i < spline_new->tot_point; i++) { MaskSplinePoint *point = &spline_new->points[i]; if (point->parent.id) { const char *id_name = BLI_ghash_lookup(mask_clipboard.id_hash, point->parent.id); |