diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-06 04:30:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-06 04:32:54 +0300 |
commit | aa3a4973a30ff668a62447e18ac41f6c916b4a8b (patch) | |
tree | 1b24cc55995ba8b3d72aaabd9400a3e1e030d540 /source/blender/editors | |
parent | 7cb20d841da16d0bffb63154403267500e9941f5 (diff) |
Cleanup: use ELEM macro
Diffstat (limited to 'source/blender/editors')
65 files changed, 121 insertions, 125 deletions
diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 66c12a0d0d7..60fe8ee7dee 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -1806,11 +1806,11 @@ static void select_similar_data_pchan(bContext *C, const size_t bytes_size, cons static void is_ancestor(EditBone *bone, EditBone *ancestor) { - if (bone->temp.ebone == ancestor || bone->temp.ebone == NULL) { + if (ELEM(bone->temp.ebone, ancestor, NULL)) { return; } - if (bone->temp.ebone->temp.ebone != NULL && bone->temp.ebone->temp.ebone != ancestor) { + if (!ELEM(bone->temp.ebone->temp.ebone, NULL, ancestor)) { is_ancestor(bone->temp.ebone, ancestor); } diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index eb2a0d7a073..3781b2e318b 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -961,7 +961,7 @@ static int pose_slide_invoke_common(bContext *C, wmOperator *op, tPoseSlideOp *p /* initial apply for operator... */ /* TODO: need to calculate percentage for initial round too... */ - if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) { + if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) { pose_slide_apply(C, pso); } else { @@ -1200,7 +1200,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) pose_slide_reset(pso); /* apply... */ - if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) { + if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) { pose_slide_apply(C, pso); } else { @@ -1223,7 +1223,7 @@ static void pose_slide_cancel(bContext *UNUSED(C), wmOperator *op) static int pose_slide_exec_common(bContext *C, wmOperator *op, tPoseSlideOp *pso) { /* settings should have been set up ok for applying, so just apply! */ - if (pso->mode != POSESLIDE_PUSH_REST && pso->mode != POSESLIDE_RELAX_REST) { + if (!ELEM(pso->mode, POSESLIDE_PUSH_REST, POSESLIDE_RELAX_REST)) { pose_slide_apply(C, pso); } else { diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d39c7eb0d95..4b7efe0f23c 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -2055,7 +2055,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag) bp++; } - if (u == 0 || u == nu->pntsv - 1) { /* row in u-direction selected */ + if (ELEM(u, 0, nu->pntsv - 1)) { /* row in u-direction selected */ ok = true; newbp = (BPoint *)MEM_mallocN(nu->pntsu * (nu->pntsv + 1) * sizeof(BPoint), "extrudeNurb1"); @@ -2083,7 +2083,7 @@ bool ed_editnurb_extrude_flag(EditNurb *editnurb, const uint8_t flag) nu->pntsv++; BKE_nurb_knot_calc_v(nu); } - else if (v == 0 || v == nu->pntsu - 1) { /* column in v-direction selected */ + else if (ELEM(v, 0, nu->pntsu - 1)) { /* column in v-direction selected */ ok = true; bpn = newbp = (BPoint *)MEM_mallocN((nu->pntsu + 1) * nu->pntsv * sizeof(BPoint), "extrudeNurb1"); @@ -2309,7 +2309,7 @@ static void adduplicateflagNurb( newv = 0; for (a = 0; a < nu->pntsu; a++) { if (usel[a]) { - if (newv == 0 || usel[a] == newv) { + if (ELEM(newv, 0, usel[a])) { newv = usel[a]; newu++; } @@ -3868,7 +3868,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) const bool use_handles = RNA_boolean_get(op->ptr, "use_handles"); const int type = RNA_enum_get(op->ptr, "type"); - if (type == CU_CARDINAL || type == CU_BSPLINE) { + if (ELEM(type, CU_CARDINAL, CU_BSPLINE)) { BKE_report(op->reports, RPT_ERROR, "Not yet implemented"); continue; } @@ -4408,7 +4408,7 @@ static int merge_nurb(View3D *v3d, Object *obedit) /* resolution match, to avoid uv rotations */ if (nus1->nu->pntsv == 1) { - if (nus1->nu->pntsu == nus2->nu->pntsu || nus1->nu->pntsu == nus2->nu->pntsv) { + if (ELEM(nus1->nu->pntsu, nus2->nu->pntsu, nus2->nu->pntsv)) { /* pass */ } else { @@ -4416,7 +4416,7 @@ static int merge_nurb(View3D *v3d, Object *obedit) } } else if (nus2->nu->pntsv == 1) { - if (nus2->nu->pntsu == nus1->nu->pntsu || nus2->nu->pntsu == nus1->nu->pntsv) { + if (ELEM(nus2->nu->pntsu, nus1->nu->pntsu, nus1->nu->pntsv)) { /* pass */ } else { diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 5e2af960550..5b66d473466 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -141,7 +141,7 @@ Nurb *ED_curve_add_nurbs_primitive( BKE_nurbList_flag_set(editnurb, SELECT, false); /* these types call this function to return a Nurb */ - if (stype != CU_PRIM_TUBE && stype != CU_PRIM_DONUT) { + if (!ELEM(stype, CU_PRIM_TUBE, CU_PRIM_DONUT)) { nu = (Nurb *)MEM_callocN(sizeof(Nurb), "addNurbprim"); nu->type = cutype; nu->resolu = cu->resolu; diff --git a/source/blender/editors/curve/editcurve_query.c b/source/blender/editors/curve/editcurve_query.c index 369137cbe25..56392aab5bf 100644 --- a/source/blender/editors/curve/editcurve_query.c +++ b/source/blender/editors/curve/editcurve_query.c @@ -185,7 +185,7 @@ void ED_curve_nurb_vert_selected_find( a = nu1->pntsu; while (a--) { if (BEZT_ISSEL_ANY_HIDDENHANDLES(v3d, bezt1)) { - if (*r_nu != NULL && *r_nu != nu1) { + if (!ELEM(*r_nu, NULL, nu1)) { *r_nu = NULL; *r_bp = NULL; *r_bezt = NULL; @@ -209,7 +209,7 @@ void ED_curve_nurb_vert_selected_find( a = nu1->pntsu * nu1->pntsv; while (a--) { if (bp1->f1 & SELECT) { - if (*r_nu != NULL && *r_nu != nu1) { + if (!ELEM(*r_nu, NULL, nu1)) { *r_bp = NULL; *r_bezt = NULL; *r_nu = NULL; diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 0a5e35364b2..13a64ba5071 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -1695,7 +1695,7 @@ static int insert_text_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (event_val && (ascii || event->utf8_buf[0])) { /* handle case like TAB (== 9) */ - if ((ascii > 31 && ascii < 254 && ascii != 127) || (ascii == 13) || (ascii == 10) || + if ((ascii > 31 && ascii < 254 && ascii != 127) || (ELEM(ascii, 13, 10)) || (ascii == 8) || (event->utf8_buf[0])) { if (accentcode) { diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 1a0a3e578ee..a9f9625db7a 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -2041,7 +2041,7 @@ static void annotation_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgr short ok = annotation_stroke_addpoint(p, p->mval, p->pressure, p->curtime); /* handle errors while adding point */ - if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { + if (ELEM(ok, GP_STROKEADD_FULL, GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ annotation_paint_strokeend(p); /* And start a new one!!! Else, projection errors! */ diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 07a1b34fa84..2cee06c36ad 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -1557,14 +1557,14 @@ static int gpencil_stroke_arrange_exec(bContext *C, wmOperator *op) continue; } /* some stroke is already at front*/ - if ((direction == GP_STROKE_MOVE_TOP) || (direction == GP_STROKE_MOVE_UP)) { + if (ELEM(direction, GP_STROKE_MOVE_TOP, GP_STROKE_MOVE_UP)) { if (gps == gpf->strokes.last) { gpf_lock = true; continue; } } /* some stroke is already at botom */ - if ((direction == GP_STROKE_MOVE_BOTTOM) || (direction == GP_STROKE_MOVE_DOWN)) { + if (ELEM(direction, GP_STROKE_MOVE_BOTTOM, GP_STROKE_MOVE_DOWN)) { if (gps == gpf->strokes.first) { gpf_lock = true; continue; @@ -3035,7 +3035,7 @@ static int gpencil_material_isolate_exec(bContext *C, wmOperator *op) for (short i = 0; i < *totcol; i++) { ma = BKE_gpencil_material(ob, i + 1); /* Skip if this is the active one */ - if ((ma == NULL) || (ma == active_ma)) { + if (ELEM(ma, NULL, active_ma)) { continue; } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 6258e6e8481..4ba75bcd604 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -1042,7 +1042,7 @@ static void gpencil_add_move_points(bGPDframe *gpf, bGPDstroke *gps) /* review points in the middle of stroke to create new strokes */ for (int i = 0; i < gps->totpoints; i++) { /* skip first and last point */ - if ((i == 0) || (i == gps->totpoints - 1)) { + if (ELEM(i, 0, gps->totpoints - 1)) { continue; } @@ -3221,13 +3221,13 @@ static int gpencil_stroke_caps_set_exec(bContext *C, wmOperator *op) continue; } - if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) || (type == GP_STROKE_CAPS_TOGGLE_START)) { + if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_START)) { ++gps->caps[0]; if (gps->caps[0] >= GP_STROKE_CAP_MAX) { gps->caps[0] = GP_STROKE_CAP_ROUND; } } - if ((type == GP_STROKE_CAPS_TOGGLE_BOTH) || (type == GP_STROKE_CAPS_TOGGLE_END)) { + if (ELEM(type, GP_STROKE_CAPS_TOGGLE_BOTH, GP_STROKE_CAPS_TOGGLE_END)) { ++gps->caps[1]; if (gps->caps[1] >= GP_STROKE_CAP_MAX) { gps->caps[1] = GP_STROKE_CAP_ROUND; @@ -4389,7 +4389,7 @@ static int gpencil_stroke_separate_exec(bContext *C, wmOperator *op) ob_dst->data = (bGPdata *)gpd_dst; /* Loop old data-block and separate parts. */ - if ((mode == GP_SEPARATE_POINT) || (mode == GP_SEPARATE_STROKE)) { + if (ELEM(mode, GP_SEPARATE_POINT, GP_SEPARATE_STROKE)) { CTX_DATA_BEGIN (C, bGPDlayer *, gpl, editable_gpencil_layers) { gpl_dst = NULL; bGPDframe *init_gpf = (is_multiedit) ? gpl->frames.first : gpl->actframe; diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 3c1f538cb99..f06a1d6b6c8 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -359,14 +359,12 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4]) tgpw.custonion = true; /* normal strokes */ - if ((tgpf->fill_draw_mode == GP_FILL_DMODE_STROKE) || - (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) { + if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_STROKE, GP_FILL_DMODE_BOTH)) { ED_gpencil_draw_fill(&tgpw); } /* 3D Lines with basic shapes and invisible lines */ - if ((tgpf->fill_draw_mode == GP_FILL_DMODE_CONTROL) || - (tgpf->fill_draw_mode == GP_FILL_DMODE_BOTH)) { + if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_CONTROL, GP_FILL_DMODE_BOTH)) { gpencil_draw_basic_stroke(tgpf, gps, tgpw.diff_mat, diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 3e63d644760..938f4ab26af 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -314,7 +314,7 @@ static int gpencil_insert_to_array(tGPencilPointCache *src_array, } src_elem = &src_array[idx]; /* check if all points or only a stroke */ - if ((gps_filter != NULL) && (gps_filter != src_elem->gps)) { + if (!ELEM(gps_filter, NULL, src_elem->gps)) { continue; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 543ff8e7e9a..82c30dea91d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1152,7 +1152,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* invalidate any other point, to interpolate between * first and last contact in an imaginary line between them */ for (i = 0; i < gpd->runtime.sbuffer_used; i++) { - if ((i != first_valid) && (i != last_valid)) { + if (!ELEM(i, first_valid, last_valid)) { depth_arr[i] = FLT_MAX; } } @@ -2719,7 +2719,7 @@ static void gpencil_draw_apply(bContext *C, wmOperator *op, tGPsdata *p, Depsgra short ok = gpencil_stroke_addpoint(p, p->mval, p->pressure, p->curtime); /* handle errors while adding point */ - if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { + if (ELEM(ok, GP_STROKEADD_FULL, GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ gpencil_paint_strokeend(p); /* And start a new one!!! Else, projection errors! */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index c03ff05ac73..55180885c5d 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -849,7 +849,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* invalidate any other point, to interpolate between * first and last contact in an imaginary line between them */ for (i = 0; i < gps->totpoints; i++) { - if ((i != first_valid) && (i != last_valid)) { + if (!ELEM(i, first_valid, last_valid)) { depth_arr[i] = FLT_MAX; } } diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 28a90a26a9d..3e16980c651 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -555,7 +555,7 @@ bool ED_gpencil_stroke_can_use_direct(const ScrArea *area, const bGPDstroke *gps /* filter stroke types by flags + spacetype */ if (gps->flag & GP_STROKE_3DSPACE) { /* 3D strokes - only in 3D view */ - return ((area->spacetype == SPACE_VIEW3D) || (area->spacetype == SPACE_PROPERTIES)); + return (ELEM(area->spacetype, SPACE_VIEW3D, SPACE_PROPERTIES)); } if (gps->flag & GP_STROKE_2DIMAGE) { /* Special "image" strokes - only in Image Editor */ @@ -1429,7 +1429,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { if (gpl->parent != NULL) { /* calculate new matrix */ - if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) { + if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { invert_m4_m4(cur_mat, gpl->parent->obmat); copy_v3_v3(gpl_loc, obact->obmat[3]); } @@ -2289,7 +2289,7 @@ static void gpencil_insert_point( gpencil_copy_points(gps, pt, pt_final, i, i2); /* create new point duplicating point and copy location */ - if ((i == a_idx) || (i == b_idx)) { + if (ELEM(i, a_idx, b_idx)) { i2++; pt_final = &gps->points[i2]; gpencil_copy_points(gps, pt, pt_final, i, i2); diff --git a/source/blender/editors/gpencil/gpencil_uv.c b/source/blender/editors/gpencil/gpencil_uv.c index 8304641611e..3bd2c3e6be6 100644 --- a/source/blender/editors/gpencil/gpencil_uv.c +++ b/source/blender/editors/gpencil/gpencil_uv.c @@ -502,13 +502,13 @@ static int gpencil_reset_transform_fill_exec(bContext *C, wmOperator *op) /* Loop all selected strokes and reset. */ GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { if (gps->flag & GP_STROKE_SELECT) { - if ((mode == GP_UV_TRANSLATE) || (mode == GP_UV_ALL)) { + if (ELEM(mode, GP_UV_TRANSLATE, GP_UV_ALL)) { zero_v2(gps->uv_translation); } - if ((mode == GP_UV_ROTATE) || (mode == GP_UV_ALL)) { + if (ELEM(mode, GP_UV_ROTATE, GP_UV_ALL)) { gps->uv_rotation = 0.0f; } - if ((mode == GP_UV_SCALE) || (mode == GP_UV_ALL)) { + if (ELEM(mode, GP_UV_SCALE, GP_UV_ALL)) { gps->uv_scale = 1.0f; } /* Calc geometry data. */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3ff65cccc21..a69540613fb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -702,10 +702,10 @@ static bool ui_but_equals_old(const uiBut *but, const uiBut *oldbut) if (but->funcN != oldbut->funcN) { return false; } - if (oldbut->func_arg1 != oldbut && but->func_arg1 != oldbut->func_arg1) { + if (!ELEM(oldbut->func_arg1, oldbut, but->func_arg1)) { return false; } - if (oldbut->func_arg2 != oldbut && but->func_arg2 != oldbut->func_arg2) { + if (!ELEM(oldbut->func_arg2, oldbut, but->func_arg2)) { return false; } if (!but->funcN && ((but->poin != oldbut->poin && (uiBut *)oldbut->poin != oldbut) || diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index dec1710ac69..d9571dc98bd 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -973,15 +973,15 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(region), 1.0, 1.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_a, res, is_line, pos); } else { - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_R) { + if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_R)) { histogram_draw_one( 1.0, 0.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_r, res, is_line, pos); } - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_G) { + if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_G)) { histogram_draw_one( 0.0, 1.0, 0.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_g, res, is_line, pos); } - if (hist->mode == HISTO_MODE_RGB || hist->mode == HISTO_MODE_B) { + if (ELEM(hist->mode, HISTO_MODE_RGB, HISTO_MODE_B)) { histogram_draw_one( 0.0, 0.0, 1.0, 0.75, rect.xmin, rect.ymin, w, h, hist->data_b, res, is_line, pos); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index bbb66a7e0e4..fb5844d24f3 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -1024,7 +1024,7 @@ static void ui_apply_but_TOG(bContext *C, uiBut *but, uiHandleButtonData *data) } ui_but_value_set(but, (double)value_toggle); - if (but->type == UI_BTYPE_ICON_TOGGLE || but->type == UI_BTYPE_ICON_TOGGLE_N) { + if (ELEM(but->type, UI_BTYPE_ICON_TOGGLE, UI_BTYPE_ICON_TOGGLE_N)) { ui_but_update_edited(but); } @@ -3564,7 +3564,7 @@ static void ui_do_but_textedit( /* for double click: we do a press again for when you first click on button * (selects all text, no cursor pos) */ - if (event->val == KM_PRESS || event->val == KM_DBL_CLICK) { + if (ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) { float mx = event->x; float my = event->y; ui_window_to_block_fl(data->region, block, &mx, &my); @@ -4740,7 +4740,7 @@ static float ui_numedit_apply_snap(int temp, float softmax, const enum eSnapType snap) { - if (temp == softmin || temp == softmax) { + if (ELEM(temp, softmin, softmax)) { return temp; } @@ -5052,7 +5052,7 @@ static int ui_do_but_NUM( } } else if (data->state == BUTTON_STATE_NUM_EDITING) { - if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) { + if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { if (event->val == KM_PRESS) { data->cancel = true; data->escapecancel = true; @@ -5244,13 +5244,13 @@ static bool ui_numedit_but_SLI(uiBut *but, temp = round_fl_to_int(tempf); if (snap) { - if (tempf == softmin || tempf == softmax) { + if (ELEM(tempf, softmin, softmax)) { /* pass */ } else if (ui_but_is_float(but)) { if (shift) { - if (tempf == softmin || tempf == softmax) { + if (ELEM(tempf, softmin, softmax)) { } else if (softrange < 2.10f) { tempf = roundf(tempf * 100.0f) * 0.01f; @@ -5374,7 +5374,7 @@ static int ui_do_but_SLI( #endif } else if (data->state == BUTTON_STATE_NUM_EDITING) { - if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) { + if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { if (event->val == KM_PRESS) { data->cancel = true; data->escapecancel = true; @@ -5997,7 +5997,7 @@ static int ui_do_but_UNITVEC( } } } - else if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) { + else if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { if (event->val == KM_PRESS) { data->cancel = true; data->escapecancel = true; @@ -6328,7 +6328,7 @@ static int ui_do_but_HSVCUBE( } } else if (data->state == BUTTON_STATE_NUM_EDITING) { - if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) { + if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { if (event->val == KM_PRESS) { data->cancel = true; data->escapecancel = true; @@ -6602,7 +6602,7 @@ static int ui_do_but_HSVCIRCLE( } } else if (data->state == BUTTON_STATE_NUM_EDITING) { - if (event->type == EVT_ESCKEY || event->type == RIGHTMOUSE) { + if (ELEM(event->type, EVT_ESCKEY, RIGHTMOUSE)) { if (event->val == KM_PRESS) { data->cancel = true; data->escapecancel = true; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index efb29fe75c3..30a73afa94e 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1002,7 +1002,7 @@ static uiBut *ui_item_with_label(uiLayout *layout, const PropertySubType subtype = RNA_property_subtype(prop); uiBut *but; - if (subtype == PROP_FILEPATH || subtype == PROP_DIRPATH) { + if (ELEM(subtype, PROP_FILEPATH, PROP_DIRPATH)) { UI_block_layout_set_current(block, uiLayoutRow(sub, true)); but = uiDefAutoButR(block, ptr, prop, index, "", icon, x, y, prop_but_width - UI_UNIT_X, h); @@ -1886,7 +1886,7 @@ static void ui_item_rna_size(uiLayout *layout, else if (type == PROP_ENUM && !icon_only) { w += UI_UNIT_X / 4; } - else if (type == PROP_FLOAT || type == PROP_INT) { + else if (ELEM(type, PROP_FLOAT, PROP_INT)) { w += UI_UNIT_X * 3; } } @@ -5480,7 +5480,7 @@ uiLayout *UI_block_layout(uiBlock *block, layout->context = NULL; layout->emboss = UI_EMBOSS_UNDEFINED; - if (type == UI_LAYOUT_MENU || type == UI_LAYOUT_PIEMENU) { + if (ELEM(type, UI_LAYOUT_MENU, UI_LAYOUT_PIEMENU)) { layout->space = 0; } diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 678dbe868e7..83274db9db9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -4969,7 +4969,7 @@ static void CurveProfile_buttons_layout(uiLayout *layout, PointerRNA *ptr, RNAUp selection_y = &point->h2_loc[1]; } } - if (i == 0 || i == profile->path_len - 1) { + if (ELEM(i, 0, profile->path_len - 1)) { point_last_or_first = true; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index f2afe27f40f..e2c835ac461 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -917,7 +917,7 @@ static void shape_preset_init_trias_ex(uiWidgetTrias *tria, float centx, centy, sizex, sizey, minsize; int a, i1 = 0, i2 = 1; - if (where == 'r' || where == 'l') { + if (ELEM(where, 'r', 'l')) { minsize = BLI_rcti_size_y(rect); } else { diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 258516a1c61..a5999962e09 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -293,7 +293,7 @@ static int view_pan_modal(bContext *C, wmOperator *op, const wmEvent *event) } #endif default: - if (event->type == vpd->invoke_event || event->type == EVT_ESCKEY) { + if (ELEM(event->type, vpd->invoke_event, EVT_ESCKEY)) { if (event->val == KM_RELEASE) { /* calculate overall delta mouse-movement for redo */ RNA_int_set(op->ptr, "deltax", (vpd->startx - vpd->lastx)); @@ -1241,7 +1241,7 @@ static int view_zoomdrag_invoke(bContext *C, wmOperator *op, const wmEvent *even vzd->zoom_to_mouse_pos = true; } - if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { + if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { float dx, dy, fac; vzd->lastx = event->prevx; @@ -1413,7 +1413,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event /* apply zooming */ view_zoomdrag_apply(C, op); } - else if (event->type == vzd->invoke_event || event->type == EVT_ESCKEY) { + else if (ELEM(event->type, vzd->invoke_event, EVT_ESCKEY)) { if (event->val == KM_RELEASE) { /* for redo, store the overall deltas - need to respect zoom-locks here... */ diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 62f46c93bc7..d7b3d74bc7e 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -202,7 +202,7 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer, MaskSplinePoint *cur_point = &cur_spline->points[i]; if (MASKPOINT_ISSEL_ANY(cur_point)) { - if (*spline != NULL && *spline != cur_spline) { + if (!ELEM(*spline, NULL, cur_spline)) { *spline = NULL; *point = NULL; return; diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 8acbb328ab0..c757b6f0cc3 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -111,7 +111,7 @@ static void draw_single_handle(const MaskLayer *mask_layer, const BezTriple *bezt = &point->bezt; char handle_type; - if (which_handle == MASK_WHICH_HANDLE_STICK || which_handle == MASK_WHICH_HANDLE_LEFT) { + if (ELEM(which_handle, MASK_WHICH_HANDLE_STICK, MASK_WHICH_HANDLE_LEFT)) { handle_type = bezt->h1; } else { diff --git a/source/blender/editors/mesh/editmesh_preselect_edgering.c b/source/blender/editors/mesh/editmesh_preselect_edgering.c index aa1df3d76fc..43e36957dc9 100644 --- a/source/blender/editors/mesh/editmesh_preselect_edgering.c +++ b/source/blender/editors/mesh/editmesh_preselect_edgering.c @@ -110,7 +110,7 @@ static void edgering_find_order(BMEdge *eed_last, BMEdge *eed, BMVert *eve_last, BMLoop *l_other = BM_loop_other_edge_loop(l, eed->v1); const bool rev = (l_other == l->prev); - while (l_other->v != eed_last->v1 && l_other->v != eed_last->v2) { + while (!ELEM(l_other->v, eed_last->v1, eed_last->v2)) { l_other = rev ? l_other->prev : l_other->next; } diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 85cc19e7471..c8367c720a7 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -875,7 +875,7 @@ static void edbm_add_edge_face_exec__tricky_finalize_sel(BMesh *bm, BMElem *ele_ } else { BMLoop *l = BM_face_edge_share_loop(f, (BMEdge *)ele_desel); - BLI_assert(f->len == 4 || f->len == 3); + BLI_assert(ELEM(f->len, 4, 3)); BM_edge_select_set(bm, (BMEdge *)ele_desel, false); if (f->len == 4) { @@ -4082,7 +4082,7 @@ static int edbm_knife_cut_exec(bContext *C, wmOperator *op) isect = bm_edge_seg_isect(sco_a, sco_b, mouse_path, len, mode, &isected); if (isect != 0.0f) { - if (mode != KNIFE_MULTICUT && mode != KNIFE_MIDPOINT) { + if (!ELEM(mode, KNIFE_MULTICUT, KNIFE_MIDPOINT)) { BMO_slot_map_float_insert(&bmop, slot_edge_percents, be, isect); } } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 62dd4a22654..3b5897de0b0 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -407,7 +407,7 @@ int ED_mesh_join_objects_exec(bContext *C, wmOperator *op) me = (Mesh *)ob->data; key = me->key; - if (totvert == 0 || totvert == me->totvert) { + if (ELEM(totvert, 0, me->totvert)) { BKE_report(op->reports, RPT_WARNING, "No mesh data to join"); return OPERATOR_CANCELLED; } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 36e780f7472..8973a74cd1d 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -2930,7 +2930,7 @@ static int object_convert_exec(bContext *C, wmOperator *op) /* Remove curves and meshes converted to Grease Pencil object. */ if (gpencilConverted) { FOREACH_SCENE_OBJECT_BEGIN (scene, ob_delete) { - if ((ob_delete->type == OB_CURVE) || (ob_delete->type == OB_MESH)) { + if (ELEM(ob_delete->type, OB_CURVE, OB_MESH)) { if (ob_delete->flag & OB_DONE) { ED_object_base_free_and_unlink(bmain, scene, ob_delete); } diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 0073aa830de..fa8531dfb48 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -2219,7 +2219,7 @@ static const EnumPropertyItem *object_constraint_add_itemf(bContext *UNUSED(C), int totitem = 0; while (item->identifier) { - if ((item->value != CONSTRAINT_TYPE_KINEMATIC) && (item->value != CONSTRAINT_TYPE_SPLINEIK)) { + if (!ELEM(item->value, CONSTRAINT_TYPE_KINEMATIC, CONSTRAINT_TYPE_SPLINEIK)) { RNA_enum_item_add(&object_constraint_items, &totitem, item); } item++; diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index df940d3fa25..70c3552e8da 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -761,7 +761,7 @@ bool ED_object_editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag WM_main_add_notifier(NC_SCENE | ND_MODE | NS_EDITMODE_LATTICE, scene); } - else if (ob->type == OB_SURF || ob->type == OB_CURVE) { + else if (ELEM(ob->type, OB_SURF, OB_CURVE)) { ok = 1; ED_curve_editnurb_make(ob); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 46624a76999..29393e8a8d1 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -911,7 +911,7 @@ bool ED_object_parent_set(ReportList *reports, else if (partype == PAR_ARMATURE_NAME) { ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_NAME); } - else if ((partype == PAR_ARMATURE_AUTO) || (partype == PAR_ARMATURE_ENVELOPE)) { + else if (ELEM(partype, PAR_ARMATURE_AUTO, PAR_ARMATURE_ENVELOPE)) { WM_cursor_wait(1); ED_gpencil_add_armature_weights(C, reports, ob, par, GP_PAR_ARMATURE_AUTO); WM_cursor_wait(0); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 7d853745ad6..76d0c162f29 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -565,7 +565,7 @@ static void append_sorted_object_parent_hierarchy(Object *root_object, Object **sorted_objects, int *object_index) { - if (object->parent != NULL && object->parent != root_object) { + if (!ELEM(object->parent, NULL, root_object)) { append_sorted_object_parent_hierarchy( root_object, object->parent, sorted_objects, object_index); } @@ -1374,7 +1374,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) if (centermode == ORIGIN_TO_CURSOR) { copy_v3_v3(gpcenter, cursor); } - if ((centermode == ORIGIN_TO_GEOMETRY) || (centermode == ORIGIN_TO_CURSOR)) { + if (ELEM(centermode, ORIGIN_TO_GEOMETRY, ORIGIN_TO_CURSOR)) { bGPDspoint *pt; float imat[3][3], bmat[3][3]; float offset_global[3]; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index cffcb1cb4dc..720d4608125 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1385,7 +1385,7 @@ static void region_rect_recursive( region->winrct = *remainder; BLI_rcti_init(remainder, 0, 0, 0, 0); } - else if (alignment == RGN_ALIGN_TOP || alignment == RGN_ALIGN_BOTTOM) { + else if (ELEM(alignment, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { rcti *winrct = (region->overlap) ? overlap_remainder : remainder; if ((prefsizey == 0) || (rct_fits(winrct, 'v', prefsizey) < 0)) { @@ -1437,7 +1437,7 @@ static void region_rect_recursive( BLI_rcti_sanitize(winrct); } } - else if (alignment == RGN_ALIGN_VSPLIT || alignment == RGN_ALIGN_HSPLIT) { + else if (ELEM(alignment, RGN_ALIGN_VSPLIT, RGN_ALIGN_HSPLIT)) { /* percentage subdiv*/ region->winrct = *remainder; @@ -3582,7 +3582,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const ofs_y += vertical_offset; } } /* Strip */ - else if (i == 1 || i == 2) { + else if (ELEM(i, 1, 2)) { int len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i + 1]); if (metadata_is_valid(ibuf, temp_str, i + 1, len)) { BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f); diff --git a/source/blender/editors/screen/screen_draw.c b/source/blender/editors/screen/screen_draw.c index ddb1f5c87ba..6432bdac1b1 100644 --- a/source/blender/editors/screen/screen_draw.c +++ b/source/blender/editors/screen/screen_draw.c @@ -203,7 +203,7 @@ static void draw_vertical_join_shape(ScrArea *area, char dir, uint pos) */ static void draw_join_shape(ScrArea *area, char dir, uint pos) { - if (dir == 'u' || dir == 'd') { + if (ELEM(dir, 'u', 'd')) { draw_vertical_join_shape(area, dir, pos); } else { diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 5f56bbaef9d..5e67d6855c0 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -362,7 +362,7 @@ static void screen_areas_align( { wmWindow *win = CTX_wm_window(C); - if (dir == 0 || dir == 2) { + if (ELEM(dir, 0, 2)) { /* horizontal join, use average for new top and bottom. */ int top = (sa1->v2->vec.y + sa2->v2->vec.y) / 2; int bottom = (sa1->v4->vec.y + sa2->v4->vec.y) / 2; @@ -687,7 +687,7 @@ static void screen_cursor_set(wmWindow *win, const int xy[2]) WM_cursor_set(win, WM_CURSOR_EDIT); } else if (az->type == AZONE_REGION) { - if (az->edge == AE_LEFT_TO_TOPRIGHT || az->edge == AE_RIGHT_TO_TOPLEFT) { + if (ELEM(az->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) { WM_cursor_set(win, WM_CURSOR_X_MOVE); } else { @@ -772,7 +772,7 @@ void ED_screen_set_active_region(bContext *C, wmWindow *win, const int xy[2]) } } - if (region == region_prev || region == screen->active_region) { + if (ELEM(region, region_prev, screen->active_region)) { do_draw = true; } } diff --git a/source/blender/editors/screen/screen_geometry.c b/source/blender/editors/screen/screen_geometry.c index 4acf3dd7ba5..ac159f4d633 100644 --- a/source/blender/editors/screen/screen_geometry.c +++ b/source/blender/editors/screen/screen_geometry.c @@ -202,7 +202,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, /* all selected vertices get the right offset */ LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) { /* if is a collapsed area */ - if (sv != area->v1 && sv != area->v4) { + if (!ELEM(sv, area->v1, area->v4)) { if (sv->flag) { sv->vec.y = yval; /* Changed size of a area. Run another pass to ensure everything still fits. */ @@ -228,7 +228,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, /* all selected vertices get the right offset */ LISTBASE_FOREACH (ScrVert *, sv, &screen->vertbase) { /* if is not a collapsed area */ - if (sv != area->v2 && sv != area->v3) { + if (!ELEM(sv, area->v2, area->v3)) { if (sv->flag) { sv->vec.y = yval; /* Changed size of a area. Run another pass to ensure everything still fits. */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 1efcc152f37..72b3b344813 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1617,7 +1617,7 @@ static int area_snap_calc_location(const bScreen *screen, switch (snap_type) { case SNAP_AREAGRID: m_cursor_final = m_cursor; - if (delta != bigger && delta != -smaller) { + if (!ELEM(delta, bigger, -smaller)) { m_cursor_final -= (m_cursor % AREAGRID); CLAMP(m_cursor_final, origval - smaller, origval + bigger); } @@ -2477,7 +2477,7 @@ static int area_max_regionsize(ScrArea *area, ARegion *scalear, AZEdge edge) } } else { - if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { + if (ELEM(edge, AE_RIGHT_TO_TOPLEFT, AE_LEFT_TO_TOPRIGHT)) { dist = BLI_rcti_size_x(&area->totrct); } else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ @@ -2574,7 +2574,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event } /* now copy to regionmovedata */ - if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) { rmd->origval = rmd->region->sizex; } else { @@ -2598,7 +2598,7 @@ static void region_scale_validate_size(RegionMoveData *rmd) if ((rmd->region->flag & RGN_FLAG_HIDDEN) == 0) { short *size, maxsize = -1; - if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) { size = &rmd->region->sizex; } else { @@ -2648,7 +2648,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) const float aspect = BLI_rctf_size_x(&rmd->region->v2d.cur) / (BLI_rcti_size_x(&rmd->region->v2d.mask) + 1); const int snap_size_threshold = (U.widget_unit * 2) / aspect; - if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { + if (ELEM(rmd->edge, AE_LEFT_TO_TOPRIGHT, AE_RIGHT_TO_TOPLEFT)) { delta = event->x - rmd->origx; if (rmd->edge == AE_LEFT_TO_TOPRIGHT) { delta = -delta; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index fe16611a6eb..2c33c0dbcf6 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -349,8 +349,7 @@ typedef struct PaintOperation { bool paint_use_opacity_masking(Brush *brush) { return ((brush->flag & BRUSH_AIRBRUSH) || (brush->flag & BRUSH_DRAG_DOT) || - (brush->flag & BRUSH_ANCHORED) || (brush->imagepaint_tool == PAINT_TOOL_SMEAR) || - (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) || + (brush->flag & BRUSH_ANCHORED) || (ELEM(brush->imagepaint_tool, PAINT_TOOL_SMEAR, PAINT_TOOL_SOFTEN)) || (brush->imagepaint_tool == PAINT_TOOL_FILL) || (brush->flag & BRUSH_USE_GRADIENT) || (brush->mtex.tex && !ELEM(brush->mtex.brush_map_mode, diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 37af1fb6cda..8c16300a047 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1789,7 +1789,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, static int project_paint_pixel_sizeof(const short tool) { - if ((tool == PAINT_TOOL_CLONE) || (tool == PAINT_TOOL_SMEAR)) { + if (ELEM(tool, PAINT_TOOL_CLONE, PAINT_TOOL_SMEAR)) { return sizeof(ProjPixelClone); } return sizeof(ProjPixel); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index e88af7caf42..9e9e0f441f7 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -964,7 +964,7 @@ static void do_weight_paint_vertex_multi( if (me->editflag & ME_EDIT_VERTEX_GROUPS_X_SYMMETRY) { index_mirr = mesh_get_x_mirror_vert(ob, NULL, index, topology); - if (index_mirr != -1 && index_mirr != index) { + if (!ELEM(index_mirr, -1, index)) { dv_mirr = &me->dvert[index_mirr]; } else { diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index ee9cc0e31df..bd11a746e11 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -675,7 +675,7 @@ void ED_space_clip_set_clip(bContext *C, bScreen *screen, SpaceClip *sc, MovieCl } } else { - if (cur_sc->clip == old_clip || cur_sc->clip == NULL) { + if (ELEM(cur_sc->clip, old_clip, NULL)) { cur_sc->clip = clip; } } diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 1b962a92be5..3f00e3114a5 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -616,7 +616,7 @@ static int view_zoom_exec(bContext *C, wmOperator *op) static int view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { + if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { float delta, factor; delta = event->prevx - event->x + event->prevy - event->y; diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 6f511d30aa9..153b63d11fe 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -519,7 +519,7 @@ enum { static int image_view_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { + if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { SpaceImage *sima = CTX_wm_space_image(C); ARegion *region = CTX_wm_region(C); float delta, factor, location[2]; diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index b1659bcd023..a39e84419d0 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -108,7 +108,7 @@ static void compo_tag_output_nodes(bNodeTree *nodetree, int recalc_flags) node->flag |= NODE_DO_OUTPUT_RECALC; } } - else if (node->type == CMP_NODE_VIEWER || node->type == CMP_NODE_SPLITVIEWER) { + else if (ELEM(node->type, CMP_NODE_VIEWER, CMP_NODE_SPLITVIEWER)) { if (recalc_flags & COM_RECALC_VIEWER) { node->flag |= NODE_DO_OUTPUT_RECALC; } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index 779efc3cacb..0d7255b5558 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -440,7 +440,7 @@ static void id_delete(bContext *C, ReportList *reports, TreeElement *te, TreeSto ID *id = tselem->id; BLI_assert(id != NULL); - BLI_assert((tselem->type == 0 && te->idcode != 0) || tselem->type == TSE_LAYER_COLLECTION); + BLI_assert(ELEM(tselem->type, 0 && te->idcode != 0, TSE_LAYER_COLLECTION)); UNUSED_VARS_NDEBUG(te); if (te->idcode == ID_LI && ((Library *)id)->parent != NULL) { diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index beba1fc9e8d..488264f9816 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -1435,7 +1435,7 @@ static bool do_outliner_range_select_recursive(ListBase *lb, } /* Set state for selection */ - if (te == active || te == cursor) { + if (ELEM(te, active, cursor)) { selecting = !selecting; } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index c037aae0ed5..7e23f4ed281 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -626,7 +626,7 @@ static void draw_seq_text(View2D *v2d, name = BKE_sequence_give_name(seq); } - if (seq->type == SEQ_TYPE_META || seq->type == SEQ_TYPE_ADJUSTMENT) { + if (ELEM(seq->type, SEQ_TYPE_META, SEQ_TYPE_ADJUSTMENT)) { str_len = BLI_snprintf(str, sizeof(str), "%s | %d", name, seq->len); } else if (seq->type == SEQ_TYPE_SCENE) { diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index a3f80e08a11..8f3a3ba50a0 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -589,7 +589,7 @@ int seq_effect_find_selected(Scene *scene, *r_error_str = N_("Cannot apply effects to audio sequence strips"); return 0; } - if ((seq != activeseq) && (seq != seq2)) { + if (!ELEM(seq, activeseq, seq2)) { if (seq2 == NULL) { seq2 = seq; } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 2af708494cb..f7c8c35d563 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -206,7 +206,7 @@ void ED_sequencer_select_sequence_single(Scene *scene, Sequence *seq, bool desel BKE_sequencer_active_set(scene, seq); - if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) { + if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) { if (seq->strip) { BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } @@ -466,7 +466,7 @@ static int sequencer_select_exec(bContext *C, wmOperator *op) BKE_sequencer_active_set(scene, seq); - if ((seq->type == SEQ_TYPE_IMAGE) || (seq->type == SEQ_TYPE_MOVIE)) { + if (ELEM(seq->type, SEQ_TYPE_IMAGE, SEQ_TYPE_MOVIE)) { if (seq->strip) { BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR); } diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index d3e6fd8f79c..2c9ea1d6afa 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -285,7 +285,7 @@ void wrap_offset( end += max; chop = 1; } - else if (ch == ' ' || ch == '-') { + else if (ELEM(ch, ' ', '-')) { end = i + 1; chop = 0; if (linep == linein && i >= cursin) { @@ -362,7 +362,7 @@ void wrap_offset_in_line( end += max; chop = 1; } - else if (ch == ' ' || ch == '-') { + else if (ELEM(ch, ' ', '-')) { end = i + 1; chop = 0; if (i >= cursin) { @@ -483,7 +483,7 @@ static int text_draw_wrapped(const SpaceText *st, break; } } - else if (str[mi] == ' ' || str[mi] == '-') { + else if (ELEM(str[mi], ' ', '-')) { wrap = i + 1; mend = mi + 1; } @@ -820,7 +820,7 @@ int text_get_visible_lines(const SpaceText *st, ARegion *region, const char *str start = MIN2(end, i); end += max; } - else if (ch == ' ' || ch == '-') { + else if (ELEM(ch, ' ', '-')) { end = i + 1; } diff --git a/source/blender/editors/space_text/text_format_lua.c b/source/blender/editors/space_text/text_format_lua.c index 4f6d91451e0..16eb66624ce 100644 --- a/source/blender/editors/space_text/text_format_lua.c +++ b/source/blender/editors/space_text/text_format_lua.c @@ -271,7 +271,7 @@ static void txtfmt_lua_format_line(SpaceText *st, TextLine *line, const bool do_ else if (*str == '-' && *(str + 1) == '-') { text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format)); } - else if (*str == '"' || *str == '\'') { + else if (ELEM(*str, '"', '\'')) { /* Strings */ find = *str; cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; diff --git a/source/blender/editors/space_text/text_format_osl.c b/source/blender/editors/space_text/text_format_osl.c index b205996d1d2..1a024779a83 100644 --- a/source/blender/editors/space_text/text_format_osl.c +++ b/source/blender/editors/space_text/text_format_osl.c @@ -292,7 +292,7 @@ static void txtfmt_osl_format_line(SpaceText *st, TextLine *line, const bool do_ str++; *fmt = FMT_TYPE_COMMENT; } - else if (*str == '"' || *str == '\'') { + else if (ELEM(*str, '"', '\'')) { /* Strings */ find = *str; cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; diff --git a/source/blender/editors/space_text/text_format_pov.c b/source/blender/editors/space_text/text_format_pov.c index 96d9c234a40..a68632c0d56 100644 --- a/source/blender/editors/space_text/text_format_pov.c +++ b/source/blender/editors/space_text/text_format_pov.c @@ -864,7 +864,7 @@ static void txtfmt_pov_format_line(SpaceText *st, TextLine *line, const bool do_ else if (*str == '/' && *(str + 1) == '/') { text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format)); } - else if (*str == '"' || *str == '\'') { + else if (ELEM(*str, '"', '\'')) { /* Strings */ find = *str; cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; diff --git a/source/blender/editors/space_text/text_format_pov_ini.c b/source/blender/editors/space_text/text_format_pov_ini.c index 8d6b877d3f7..1c6a93d2d7a 100644 --- a/source/blender/editors/space_text/text_format_pov_ini.c +++ b/source/blender/editors/space_text/text_format_pov_ini.c @@ -442,7 +442,7 @@ static void txtfmt_pov_ini_format_line(SpaceText *st, TextLine *line, const bool if (*str == ';') { text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format)); } - else if (*str == '"' || *str == '\'') { + else if (ELEM(*str, '"', '\'')) { /* Strings */ find = *str; cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index 39985438462..31177c53d6a 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -224,7 +224,7 @@ static uint txtfmt_py_numeral_string_count_hexadecimal(const char *string) /* Zeros. */ static bool txtfmt_py_numeral_char_is_zero(const char c) { - return (c == '0') || (c == '_'); + return (ELEM(c, '0', '_')); } static uint txtfmt_py_numeral_string_count_zeros(const char *string) { @@ -408,7 +408,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const bool do_n /* fill the remaining line */ text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(fmt - line->format)); } - else if (*str == '"' || *str == '\'') { + else if (ELEM(*str, '"', '\'')) { /* Strings */ find = *str; cont = (*str == '"') ? FMT_CONT_QUOTEDOUBLE : FMT_CONT_QUOTESINGLE; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 7c592519384..1814846c76f 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -1722,7 +1722,7 @@ static int text_get_cursor_rel( loop = 0; break; } - else if (ch == ' ' || ch == '-') { + else if (ELEM(ch, ' ', '-')) { if (found) { loop = 0; break; @@ -1987,7 +1987,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *region, const bool sel) loop = 0; break; } - else if (ch == ' ' || ch == '-') { + else if (ELEM(ch, ' ', '-')) { end = i + 1; endj = j; chop = 0; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index d7ef03453f3..5ae012ce5dd 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -153,7 +153,7 @@ bool ED_view3d_area_user_region(const ScrArea *area, const View3D *v3d, ARegion rv3d = region->regiondata; if ((rv3d->viewlock & RV3D_LOCK_ROTATION) == 0) { region_unlock = region; - if (rv3d->persp == RV3D_PERSP || rv3d->persp == RV3D_CAMOB) { + if (ELEM(rv3d->persp, RV3D_PERSP, RV3D_CAMOB)) { region_unlock_user = region; break; } diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index f67eb73bbd1..36da0791c4f 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -280,7 +280,7 @@ static void v3d_editvertex_buts(uiLayout *layout, View3D *v3d, Object *ob, float has_meshdata = (tot || totedgedata); } - else if (ob->type == OB_CURVE || ob->type == OB_SURF) { + else if (ELEM(ob->type, OB_CURVE, OB_SURF)) { TransformMedian_Curve *median = &median_basis.curve; Curve *cu = ob->data; BPoint *bp; diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 6e24dfd1db9..897777c9159 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2138,7 +2138,7 @@ static void viewzoom_apply_camera(ViewOpsData *vod, zoomfac_prev, &vod->prev.time); - if (zfac != 1.0f && zfac != 0.0f) { + if (!ELEM(zfac, 1.0f, 0.0f)) { /* calculate inverted, then invert again (needed because of camera zoom scaling) */ zfac = 1.0f / zfac; view_zoom_to_window_xy_camera(vod->scene, @@ -2382,7 +2382,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, const wmEvent *event) viewzoom_exec(C, op); } else { - if (event->type == MOUSEZOOM || event->type == MOUSEPAN) { + if (ELEM(event->type, MOUSEZOOM, MOUSEPAN)) { if (U.uiflag & USER_ZOOM_HORIZ) { vod->init.event_xy[0] = vod->prev.event_xy[0] = event->x; diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 3f7d6142758..22cdbb090a5 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -303,8 +303,8 @@ void ED_view3d_clipping_calc( /* four clipping planes and bounding volume */ /* first do the bounding volume */ for (int val = 0; val < 4; val++) { - float xs = (val == 0 || val == 3) ? rect->xmin : rect->xmax; - float ys = (val == 0 || val == 1) ? rect->ymin : rect->ymax; + float xs = (ELEM(val, 0, 3)) ? rect->xmin : rect->xmax; + float ys = (ELEM(val, 0, 1)) ? rect->ymin : rect->ymax; ED_view3d_unproject(region, xs, ys, 0.0, bb->vec[val]); ED_view3d_unproject(region, xs, ys, 1.0, bb->vec[4 + val]); diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index b622ef79c64..77ce9c10c77 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1947,7 +1947,7 @@ int transformEnd(bContext *C, TransInfo *t) t->context = C; - if (t->state != TRANS_STARTING && t->state != TRANS_RUNNING) { + if (!ELEM(t->state, TRANS_STARTING, TRANS_RUNNING)) { /* handle restoring objects */ if (t->state == TRANS_CANCEL) { exit_code = OPERATOR_CANCELLED; diff --git a/source/blender/editors/transform/transform_convert_armature.c b/source/blender/editors/transform/transform_convert_armature.c index a14ff6c500d..a7301161570 100644 --- a/source/blender/editors/transform/transform_convert_armature.c +++ b/source/blender/editors/transform/transform_convert_armature.c @@ -1504,7 +1504,7 @@ static void bone_children_clear_transflag(int mode, short around, ListBase *lb) if ((bone->flag & BONE_HINGE) && (bone->flag & BONE_CONNECTED)) { bone->flag |= BONE_HINGE_CHILD_TRANSFORM; } - else if ((bone->flag & BONE_TRANSFORM) && (mode == TFM_ROTATION || mode == TFM_TRACKBALL) && + else if ((bone->flag & BONE_TRANSFORM) && (ELEM(mode, TFM_ROTATION, TFM_TRACKBALL)) && (around == V3D_AROUND_LOCAL_ORIGINS)) { bone->flag |= BONE_TRANSFORM_CHILD; } diff --git a/source/blender/editors/transform/transform_convert_curve.c b/source/blender/editors/transform/transform_convert_curve.c index 90257b28f55..d2feb966657 100644 --- a/source/blender/editors/transform/transform_convert_curve.c +++ b/source/blender/editors/transform/transform_convert_curve.c @@ -406,7 +406,7 @@ void createTransCurveVerts(TransInfo *t) } td->ext = NULL; - if (t->mode == TFM_CURVE_SHRINKFATTEN || t->mode == TFM_RESIZE) { + if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_RESIZE)) { td->val = &(bp->radius); td->ival = bp->radius; } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 9f39099ea4b..c455dd55b8a 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -541,7 +541,7 @@ static bool transform_poll_property(const bContext *UNUSED(C), { /* Hide orientation axis if no constraints are set, since it wont be used. */ PropertyRNA *prop_con = RNA_struct_find_property(op->ptr, "orient_type"); - if (prop_con != NULL && (prop_con != prop)) { + if (!ELEM(prop_con, NULL, prop)) { if (STRPREFIX(prop_id, "constraint")) { /* Special case: show constraint axis if we don't have values, diff --git a/source/blender/editors/uvedit/uvedit_parametrizer.c b/source/blender/editors/uvedit/uvedit_parametrizer.c index 0ae167c117e..cc6eb49f984 100644 --- a/source/blender/editors/uvedit/uvedit_parametrizer.c +++ b/source/blender/editors/uvedit/uvedit_parametrizer.c @@ -4407,8 +4407,7 @@ void param_delete(ParamHandle *handle) PHandle *phandle = (PHandle *)handle; int i; - param_assert((phandle->state == PHANDLE_STATE_ALLOCATED) || - (phandle->state == PHANDLE_STATE_CONSTRUCTED)); + param_assert(ELEM(phandle->state, PHANDLE_STATE_ALLOCATED, PHANDLE_STATE_CONSTRUCTED)); for (i = 0; i < phandle->ncharts; i++) { p_chart_delete(phandle->charts[i]); @@ -4507,7 +4506,7 @@ void param_face_add(ParamHandle *handle, param_assert(phash_lookup(phandle->hash_faces, key) == NULL); param_assert(phandle->state == PHANDLE_STATE_ALLOCATED); - param_assert((nverts == 3) || (nverts == 4)); + param_assert(ELEM(nverts, 3, 4)); if (nverts > 4) { /* ngon */ |