diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c index e3c2570ab93..1b6dabbf94c 100644 --- a/source/blender/blenkernel/intern/mask.c +++ b/source/blender/blenkernel/intern/mask.c @@ -957,13 +957,13 @@ void BKE_mask_calc_handles(Mask *mask) void BKE_mask_evaluate(Mask *mask, float ctime) { - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; int i; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; BezTriple *bezt = &point->bezt; @@ -977,11 +977,7 @@ void BKE_mask_evaluate(Mask *mask, float ctime) add_v2_v2(bezt->vec[1], delta); add_v2_v2(bezt->vec[2], delta); } - - spline = spline->next; } - - maskobj = maskobj->next; } BKE_mask_calc_handles(mask); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index d0b9808697f..17eabc3d7ac 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -6282,8 +6282,7 @@ static void direct_link_mask(FileData *fd, Mask *mask) link_list(fd, &mask->maskobjs); - maskobj = mask->maskobjs.first; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline; link_list(fd, &maskobj->splines); @@ -6306,8 +6305,6 @@ static void direct_link_mask(FileData *fd, Mask *mask) maskobj->act_spline = newdataadr(fd, maskobj->act_spline); maskobj->act_point = newdataadr(fd, maskobj->act_point); - - maskobj = maskobj->next; } } @@ -6328,8 +6325,7 @@ static void lib_link_mask(FileData *fd, Main *main) if (mask->adt) lib_link_animdata(fd, &mask->id, mask->adt); - maskobj = mask->maskobjs.first; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline; spline = maskobj->splines.first; @@ -6346,8 +6342,6 @@ static void lib_link_mask(FileData *fd, Main *main) spline = spline->next; } - - maskobj = maskobj->next; } mask->id.flag -= LIB_NEEDLINK; diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index a514a3283b1..7a924238c77 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -2769,14 +2769,12 @@ static void write_masks(WriteData *wd, ListBase *idbase) if (mask->adt) write_animdata(wd, mask->adt); - maskobj = mask->maskobjs.first; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline; writestruct(wd, DATA, "MaskObject", 1, maskobj); - spline = maskobj->splines.first; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i; writestruct(wd, DATA, "MaskSpline", 1, spline); @@ -2788,11 +2786,7 @@ static void write_masks(WriteData *wd, ListBase *idbase) if (point->tot_uw) writestruct(wd, DATA, "MaskSplinePointUW", point->tot_uw, point->uw); } - - spline = spline->next; } - - maskobj = maskobj->next; } } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 06f24c6fa8f..f4022581f2d 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -218,22 +218,18 @@ static void draw_spline_curve(MaskObject *maskobj, MaskSpline *spline) static void draw_maskobjs(Mask *mask) { - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { /* draw curve itself first... */ draw_spline_curve(maskobj, spline); /* ...and then handles over the curve so they're nicely visible */ draw_spline_points(maskobj, spline); - - spline = spline->next; } - - maskobj = maskobj->next; } } diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 9b9dbcec7e5..7774af690d7 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -167,19 +167,16 @@ static int points_has_selection(MaskSplinePoint *points, int tot_point) static int mask_has_selection(Mask *mask) { - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { - if (points_has_selection(spline->points, spline->tot_point)) + for (spline = maskobj->splines.first; spline; spline = spline->next) { + if (points_has_selection(spline->points, spline->tot_point)) { return TRUE; - - spline = spline->next; + } } - - maskobj = maskobj->next; } return FALSE; @@ -187,7 +184,7 @@ static int mask_has_selection(Mask *mask) static void toggle_selection_all(Mask *mask, int action) { - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; if (action == SEL_TOGGLE) { if (mask_has_selection(mask)) @@ -196,10 +193,10 @@ static void toggle_selection_all(Mask *mask, int action) action = SEL_SELECT; } - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i; for (i = 0; i < spline->tot_point; i++) { @@ -207,11 +204,7 @@ static void toggle_selection_all(Mask *mask, int action) spline_point_select(point, action); } - - spline = spline->next; } - - maskobj = maskobj->next; } } @@ -234,11 +227,10 @@ static MaskSplinePoint *find_nearest_point(bContext *C, Mask *mask, float normal co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; - maskobj = mask->maskobjs.first; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i; for (i = 0; i < spline->tot_point; i++) { @@ -274,11 +266,7 @@ static MaskSplinePoint *find_nearest_point(bContext *C, Mask *mask, float normal is_handle = FALSE; } } - - spline = spline->next; } - - maskobj = maskobj->next; } if (len < threshold) { @@ -328,11 +316,10 @@ static int find_nearest_feather(bContext *C, Mask *mask, float normal_co[2], int co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; - maskobj = mask->maskobjs.first; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i, tot_feather_point; float *feather_points, *fp; @@ -367,11 +354,7 @@ static int find_nearest_feather(bContext *C, Mask *mask, float normal_co[2], int } MEM_freeN(feather_points); - - spline = spline->next; } - - maskobj = maskobj->next; } if (len < threshold) { @@ -424,11 +407,10 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, float normal_co[2], co[0] = normal_co[0] * scalex; co[1] = normal_co[1] * scaley; - maskobj = mask->maskobjs.first; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i; for (i = 0; i < spline->tot_point; i++) { @@ -484,11 +466,7 @@ static int find_nearest_diff_point(bContext *C, Mask *mask, float normal_co[2], MEM_freeN(diff_points); } } - - spline = spline->next; } - - maskobj = maskobj->next; } if (point && dist < threshold) { @@ -526,11 +504,10 @@ static void mask_flush_selection(Mask *mask) { MaskObject *maskobj; - maskobj = mask->maskobjs.first; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { int i; spline->flag &= ~SELECT; @@ -552,11 +529,7 @@ static void mask_flush_selection(Mask *mask) } } } - - spline = spline->next; } - - maskobj = maskobj->next; } } @@ -1477,19 +1450,16 @@ void MASK_OT_add_feather_vertex(wmOperatorType *ot) static int cyclic_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { - if (points_has_selection(spline->points, spline->tot_point)) + for (spline = maskobj->splines.first; spline; spline = spline->next) { + if (points_has_selection(spline->points, spline->tot_point)) { spline->flag ^= MASK_SPLINE_CYCLIC; - - spline = spline->next; + } } - - maskobj = maskobj->next; } WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); @@ -1553,9 +1523,9 @@ static void delete_feather_points(MaskSplinePoint *point) static int delete_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline = maskobj->splines.first; while (spline) { @@ -1615,8 +1585,6 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) spline = next_spline; } - - maskobj = maskobj->next; } WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); @@ -1645,14 +1613,14 @@ void MASK_OT_delete(wmOperatorType *ot) static int set_handle_type_exec(bContext *C, wmOperator *op) { Mask *mask = CTX_data_edit_mask(C); - MaskObject *maskobj = mask->maskobjs.first; + MaskObject *maskobj; int handle_type = RNA_enum_get(op->ptr, "type"); - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; int i; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { for (i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; @@ -1662,11 +1630,7 @@ static int set_handle_type_exec(bContext *C, wmOperator *op) bezt->h1 = bezt->h2 = handle_type; } } - - spline = spline->next; } - - maskobj = maskobj->next; } WM_event_add_notifier(C, NC_MASK | ND_DATA, mask); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 0a4b7aaeb01..e8cec774a60 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -5949,8 +5949,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) TransDataMasking *tdm = NULL; /* count */ - maskobj = mask ? mask->maskobjs.first : NULL; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline = maskobj->splines.first; while (spline) { @@ -5969,8 +5968,6 @@ static void createTransMaskingData(bContext *C, TransInfo *t) spline = spline->next; } - - maskobj = maskobj->next; } if (t->total == 0) @@ -5985,8 +5982,7 @@ static void createTransMaskingData(bContext *C, TransInfo *t) t->flag |= T_FREE_CUSTOMDATA; /* create data */ - maskobj = mask->maskobjs.first; - while (maskobj) { + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { MaskSpline *spline = maskobj->splines.first; while (spline) { @@ -6013,8 +6009,6 @@ static void createTransMaskingData(bContext *C, TransInfo *t) spline = spline->next; } - - maskobj = maskobj->next; } } diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 864a7c31cef..53a6bc34c4a 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -185,19 +185,17 @@ static PointerRNA rna_MaskObject_active_spline_point_get(PointerRNA *ptr) static void rna_MaskObject_active_spline_point_set(PointerRNA *ptr, PointerRNA value) { MaskObject *maskobj = (MaskObject *)ptr->data; - MaskSpline *spline = maskobj->splines.first; + MaskSpline *spline; MaskSplinePoint *point = (MaskSplinePoint *)value.data; maskobj->act_point = NULL; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { if (point >= spline->points && point < spline->points + spline->tot_point) { maskobj->act_point = point; break; } - - spline = spline->next; } } diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.c b/source/blender/nodes/composite/nodes/node_composite_mask.c index 2f7f48c5c4b..93d1edd76e8 100644 --- a/source/blender/nodes/composite/nodes/node_composite_mask.c +++ b/source/blender/nodes/composite/nodes/node_composite_mask.c @@ -84,11 +84,10 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) stackbuf = alloc_compbuf(sx, sy, CB_VAL, TRUE); res = stackbuf->rect; - maskobj = mask->maskobjs.first; - while (maskobj) { - MaskSpline *spline = maskobj->splines.first; + for (maskobj = mask->maskobjs.first; maskobj; maskobj = maskobj->next) { + MaskSpline *spline; - while (spline) { + for (spline = maskobj->splines.first; spline; spline = spline->next) { float *diff_points; int tot_diff_point; @@ -119,11 +118,7 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) MEM_freeN(diff_points); } - - spline = spline->next; } - - maskobj = maskobj->next; } /* pass on output and free */