From b280699078eee23bd8eb572668d6f0d8972d879a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Oct 2021 10:45:59 +1100 Subject: Cleanup: use elem macros --- source/blender/editors/animation/keyframing.c | 2 +- source/blender/editors/armature/pose_slide.c | 2 +- source/blender/editors/curve/editcurve.c | 2 +- source/blender/editors/curve/editcurve_add.c | 2 +- .../editors/gpencil/gpencil_bake_animation.c | 2 +- .../blender/editors/interface/interface_handlers.c | 2 +- .../editors/interface/interface_region_popup.c | 4 ++-- source/blender/editors/mesh/editmesh_bevel.c | 3 +-- source/blender/editors/mesh/editmesh_rip.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_bake.c | 2 +- source/blender/editors/sculpt_paint/paint_cursor.c | 2 +- source/blender/editors/sculpt_paint/paint_vertex.c | 4 ++-- .../editors/sculpt_paint/paint_vertex_color_ops.c | 2 +- source/blender/editors/sculpt_paint/sculpt.c | 5 ++--- .../editors/space_buttons/buttons_context.c | 26 +++++++++++----------- source/blender/editors/space_image/image_edit.c | 2 +- .../editors/space_sequencer/sequencer_add.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 2 +- .../editors/space_sequencer/sequencer_thumbnails.c | 2 +- .../editors/transform/transform_convert_object.c | 5 ++--- 21 files changed, 37 insertions(+), 40 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2c6b5cc594b..0a9f1a36a28 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -425,7 +425,7 @@ int insert_bezt_fcurve(FCurve *fcu, const BezTriple *bezt, eInsertKeyFlags flag) if (flag & INSERTKEY_CYCLE_AWARE) { /* If replacing an end point of a cyclic curve without offset, * modify the other end too. */ - if ((i == 0 || i == fcu->totvert - 1) && + if (ELEM(i, 0, fcu->totvert - 1) && BKE_fcurve_get_cycle_type(fcu) == FCU_CYCLE_PERFECT) { replace_bezt_keyframe_ypos(&fcu->bezt[i == 0 ? fcu->totvert - 1 : 0], bezt); } diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 1079985346c..ca024f1d4d6 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -634,7 +634,7 @@ static void pose_slide_apply_quat(tPoseSlideOp *pso, tPChanFCurveLink *pfl) interp_qt_qtqt(quat_final, quat_prev, quat_next, ED_slider_factor_get(pso->slider)); } - else if (pso->mode == POSESLIDE_PUSH || pso->mode == POSESLIDE_RELAX) { + else if (ELEM(pso->mode, POSESLIDE_PUSH, POSESLIDE_RELAX)) { float quat_breakdown[4]; float quat_curr[4]; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d4fdf46d8f4..029c8b05923 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -5409,7 +5409,7 @@ static int ed_editcurve_addvert(Curve *cu, add_v3_v3(bezt->vec[1], ofs); add_v3_v3(bezt->vec[2], ofs); - if (((nu->flagu & CU_NURB_CYCLIC) == 0) && (i == 0 || i == nu->pntsu - 1)) { + if (((nu->flagu & CU_NURB_CYCLIC) == 0) && ELEM(i, 0, nu->pntsu - 1)) { BKE_nurb_handle_calc_simple_auto(nu, bezt); } } diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index 75fb17e8cc1..614805a70f5 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -356,7 +356,7 @@ Nurb *ED_curve_add_nurbs_primitive( bp->vec[0] += fac * grid; fac = (float)b - 1.5f; bp->vec[1] += fac * grid; - if ((a == 1 || a == 2) && (b == 1 || b == 2)) { + if ((ELEM(a, 1, 2)) && (ELEM(b, 1, 2))) { bp->vec[2] += grid; } mul_m4_v3(mat, bp->vec); diff --git a/source/blender/editors/gpencil/gpencil_bake_animation.c b/source/blender/editors/gpencil/gpencil_bake_animation.c index 960f228edd0..4467e6202b4 100644 --- a/source/blender/editors/gpencil/gpencil_bake_animation.c +++ b/source/blender/editors/gpencil/gpencil_bake_animation.c @@ -102,7 +102,7 @@ static bool gpencil_bake_grease_pencil_animation_poll(bContext *C) } /* Check if grease pencil or empty for dupli groups. */ - if ((obact == NULL) || ((obact->type != OB_GPENCIL) && (obact->type != OB_EMPTY))) { + if ((obact == NULL) || (!ELEM(obact->type, OB_GPENCIL, OB_EMPTY))) { return false; } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index e1f8d18ce35..81494264cdf 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -11129,7 +11129,7 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle case EVT_XKEY: case EVT_YKEY: case EVT_ZKEY: { - if ((event->val == KM_PRESS || event->val == KM_DBL_CLICK) && + if ((ELEM(event->val, KM_PRESS, KM_DBL_CLICK)) && !IS_EVENT_MOD(event, shift, ctrl, oskey)) { LISTBASE_FOREACH (uiBut *, but, &block->buttons) { if (but->menu_key == event->type) { diff --git a/source/blender/editors/interface/interface_region_popup.c b/source/blender/editors/interface/interface_region_popup.c index 55a162c883a..3234af3d344 100644 --- a/source/blender/editors/interface/interface_region_popup.c +++ b/source/blender/editors/interface/interface_region_popup.c @@ -184,10 +184,10 @@ static void ui_popup_block_position(wmWindow *window, dir1 &= (UI_DIR_UP | UI_DIR_DOWN); } - if ((dir2 == 0) && (dir1 == UI_DIR_LEFT || dir1 == UI_DIR_RIGHT)) { + if ((dir2 == 0) && (ELEM(dir1, UI_DIR_LEFT, UI_DIR_RIGHT))) { dir2 = UI_DIR_DOWN; } - if ((dir2 == 0) && (dir1 == UI_DIR_UP || dir1 == UI_DIR_DOWN)) { + if ((dir2 == 0) && (ELEM(dir1, UI_DIR_UP, UI_DIR_DOWN))) { dir2 = UI_DIR_LEFT; } diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 0d74187b50e..6f41b7f04a6 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -764,8 +764,7 @@ static int edbm_bevel_modal(bContext *C, wmOperator *op, const wmEvent *event) } } /* Update offset accordingly to new offset_type. */ - if (!has_numinput && - (opdata->value_mode == OFFSET_VALUE || opdata->value_mode == OFFSET_VALUE_PERCENT)) { + if (!has_numinput && (ELEM(opdata->value_mode, OFFSET_VALUE, OFFSET_VALUE_PERCENT))) { edbm_bevel_mouse_set_value(op, event); } edbm_bevel_calc(op); diff --git a/source/blender/editors/mesh/editmesh_rip.c b/source/blender/editors/mesh/editmesh_rip.c index d1df063d9d0..07ec8e184ba 100644 --- a/source/blender/editors/mesh/editmesh_rip.c +++ b/source/blender/editors/mesh/editmesh_rip.c @@ -930,7 +930,7 @@ static int edbm_rip_invoke__edge(bContext *C, const wmEvent *event, Object *obed /* NOTE: if the case of 3 edges has one change in loop stepping, * if this becomes more involved we may be better off splitting * the 3 edge case into its own else-if branch */ - if ((totedge_manifold == 4 || totedge_manifold == 3) || (all_manifold == false)) { + if ((ELEM(totedge_manifold, 4, 3)) || (all_manifold == false)) { BMLoop *l_a = e_best->l; BMLoop *l_b = l_a->radial_next; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index cf7c848ae24..9c6969110fd 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -1487,7 +1487,7 @@ static void object_add_ui(bContext *UNUSED(C), wmOperator *op) uiItemR(layout, op->ptr, "type", 0, NULL, ICON_NONE); int type = RNA_enum_get(op->ptr, "type"); - if (type == GP_LRT_COLLECTION || type == GP_LRT_OBJECT || type == GP_LRT_SCENE) { + if (ELEM(type, GP_LRT_COLLECTION, GP_LRT_OBJECT, GP_LRT_SCENE)) { uiItemR(layout, op->ptr, "use_lights", 0, NULL, ICON_NONE); uiItemR(layout, op->ptr, "use_in_front", 0, NULL, ICON_NONE); bool in_front = RNA_boolean_get(op->ptr, "use_in_front"); diff --git a/source/blender/editors/object/object_bake.c b/source/blender/editors/object/object_bake.c index 3a10a423e91..1b6b0c78037 100644 --- a/source/blender/editors/object/object_bake.c +++ b/source/blender/editors/object/object_bake.c @@ -198,7 +198,7 @@ static bool multiresbake_check(bContext *C, wmOperator *op) ok = false; } - if (ibuf->rect_float && !(ibuf->channels == 0 || ibuf->channels == 4)) { + if (ibuf->rect_float && !(ELEM(ibuf->channels, 0, 4))) { ok = false; } diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index ab2b2f4b16b..dafc7f45e2e 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1103,7 +1103,7 @@ static void cursor_draw_point_with_symmetry(const uint gpuattr, float location[3], symm_rot_mat[4][4]; for (int i = 0; i <= symm; i++) { - if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5))))) { /* Axis Symmetry. */ flip_v3_v3(location, true_location, (char)i); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 9387b84f437..4e0dcfe8e3c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -2332,7 +2332,7 @@ static void wpaint_do_symmetrical_brush_actions( /* symm is a bit combination of XYZ - 1 is mirror * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ for (i = 1; i <= symm; i++) { - if ((symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + if ((symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5))))) { cache->mirror_symmetry_pass = i; cache->radial_symmetry_pass = 0; SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0); @@ -3350,7 +3350,7 @@ static void vpaint_do_symmetrical_brush_actions( /* symm is a bit combination of XYZ - 1 is mirror * X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ for (i = 1; i <= symm; i++) { - if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))) { + if (symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5)))) { cache->mirror_symmetry_pass = i; cache->radial_symmetry_pass = 0; SCULPT_cache_calc_brushdata_symm(cache, i, 0, 0); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index 9f023dd6e63..f95e1d8d89c 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -48,7 +48,7 @@ static bool vertex_weight_paint_mode_poll(bContext *C) { Object *ob = CTX_data_active_object(C); Mesh *me = BKE_mesh_from_object(ob); - return (ob && (ob->mode == OB_MODE_VERTEX_PAINT || ob->mode == OB_MODE_WEIGHT_PAINT)) && + return (ob && (ELEM(ob->mode, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT))) && (me && me->totpoly && me->dvert); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 95be866adf1..1330beb917b 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1046,7 +1046,7 @@ int SCULPT_nearest_vertex_get( bool SCULPT_is_symmetry_iteration_valid(char i, char symm) { - return i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5))); + return i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (!ELEM(i, 3, 5)))); } /* Checks if a vertex is inside the brush radius from any of its mirrored axis. */ @@ -7695,8 +7695,7 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob) /* Restore the mesh before continuing with anchored stroke. */ if ((brush->flag & BRUSH_ANCHORED) || - ((brush->sculpt_tool == SCULPT_TOOL_GRAB || - brush->sculpt_tool == SCULPT_TOOL_ELASTIC_DEFORM) && + ((ELEM(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ELASTIC_DEFORM)) && BKE_brush_use_size_pressure(brush)) || (brush->flag & BRUSH_DRAG_DOT)) { diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index 91b0677ebaa..600b04f8563 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -242,55 +242,55 @@ static bool buttons_context_path_data(ButsContextPath *path, int type) PointerRNA *ptr = &path->ptr[path->len - 1]; /* if we already have a data, we're done */ - if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (type == -1 || type == OB_MESH)) { + if (RNA_struct_is_a(ptr->type, &RNA_Mesh) && (ELEM(type, -1, OB_MESH))) { return true; } if (RNA_struct_is_a(ptr->type, &RNA_Curve) && (type == -1 || ELEM(type, OB_CURVE, OB_SURF, OB_FONT))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) { + if (RNA_struct_is_a(ptr->type, &RNA_Armature) && (ELEM(type, -1, OB_ARMATURE))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) { + if (RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (ELEM(type, -1, OB_MBALL))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) { + if (RNA_struct_is_a(ptr->type, &RNA_Lattice) && (ELEM(type, -1, OB_LATTICE))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) { + if (RNA_struct_is_a(ptr->type, &RNA_Camera) && (ELEM(type, -1, OB_CAMERA))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_Light) && (type == -1 || type == OB_LAMP)) { + if (RNA_struct_is_a(ptr->type, &RNA_Light) && (ELEM(type, -1, OB_LAMP))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (type == -1 || type == OB_SPEAKER)) { + if (RNA_struct_is_a(ptr->type, &RNA_Speaker) && (ELEM(type, -1, OB_SPEAKER))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (type == -1 || type == OB_LIGHTPROBE)) { + if (RNA_struct_is_a(ptr->type, &RNA_LightProbe) && (ELEM(type, -1, OB_LIGHTPROBE))) { return true; } - if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (type == -1 || type == OB_GPENCIL)) { + if (RNA_struct_is_a(ptr->type, &RNA_GreasePencil) && (ELEM(type, -1, OB_GPENCIL))) { return true; } #ifdef WITH_HAIR_NODES - if (RNA_struct_is_a(ptr->type, &RNA_Hair) && (type == -1 || type == OB_HAIR)) { + if (RNA_struct_is_a(ptr->type, &RNA_Hair) && (ELEM(type, -1, OB_HAIR))) { return true; } #endif #ifdef WITH_POINT_CLOUD - if (RNA_struct_is_a(ptr->type, &RNA_PointCloud) && (type == -1 || type == OB_POINTCLOUD)) { + if (RNA_struct_is_a(ptr->type, &RNA_PointCloud) && (ELEM(type, -1, OB_POINTCLOUD))) { return true; } #endif - if (RNA_struct_is_a(ptr->type, &RNA_Volume) && (type == -1 || type == OB_VOLUME)) { + if (RNA_struct_is_a(ptr->type, &RNA_Volume) && (ELEM(type, -1, OB_VOLUME))) { return true; } /* try to get an object in the path, no pinning supported here */ if (buttons_context_path_object(path)) { Object *ob = path->ptr[path->len - 1].data; - if (ob && (type == -1 || type == ob->type)) { + if (ob && (ELEM(type, -1, ob->type))) { RNA_id_pointer_create(ob->data, &path->ptr[path->len]); path->len++; diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index c1aa2da9e00..05124f49a20 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -434,7 +434,7 @@ void ED_space_image_scopes_update(const struct bContext *C, /* We also don't update scopes of render result during render. */ if (G.is_rendering) { const Image *image = sima->image; - if (image != NULL && (image->type == IMA_TYPE_R_RESULT || image->type == IMA_TYPE_COMPOSITE)) { + if (image != NULL && (ELEM(image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE))) { return; } } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 8d6d81d7115..e58e52b5e94 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -195,7 +195,7 @@ static int sequencer_generic_invoke_xy_guess_channel(bContext *C, int type) } for (seq = ed->seqbasep->first; seq; seq = seq->next) { - if ((type == -1 || seq->type == type) && (seq->enddisp < timeline_frame) && + if ((ELEM(type, -1, seq->type)) && (seq->enddisp < timeline_frame) && (timeline_frame - seq->enddisp < proximity)) { tgt = seq; proximity = timeline_frame - seq->enddisp; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7117323c214..644d2cbfedb 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1388,7 +1388,7 @@ static void draw_seq_strip(const bContext *C, if ((sseq->flag & SEQ_SHOW_OVERLAY) && (sseq->timeline_overlay.flag & SEQ_TIMELINE_SHOW_THUMBNAILS) && - (seq->type == SEQ_TYPE_MOVIE || seq->type == SEQ_TYPE_IMAGE)) { + (ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE))) { draw_seq_strip_thumbnail(v2d, C, scene, seq, y1, y2, pixelx, pixely); } diff --git a/source/blender/editors/space_sequencer/sequencer_thumbnails.c b/source/blender/editors/space_sequencer/sequencer_thumbnails.c index 06db96badc2..9efd78c47ff 100644 --- a/source/blender/editors/space_sequencer/sequencer_thumbnails.c +++ b/source/blender/editors/space_sequencer/sequencer_thumbnails.c @@ -85,7 +85,7 @@ static void thumbnail_endjob(void *data) static bool check_seq_need_thumbnails(Sequence *seq, rctf *view_area) { - if (seq->type != SEQ_TYPE_MOVIE && seq->type != SEQ_TYPE_IMAGE) { + if (!ELEM(seq->type, SEQ_TYPE_MOVIE, SEQ_TYPE_IMAGE)) { return false; } if (min_ii(seq->startdisp, seq->start) > view_area->xmax) { diff --git a/source/blender/editors/transform/transform_convert_object.c b/source/blender/editors/transform/transform_convert_object.c index 947fbb00fad..7e4e0892420 100644 --- a/source/blender/editors/transform/transform_convert_object.c +++ b/source/blender/editors/transform/transform_convert_object.c @@ -388,7 +388,7 @@ static void set_trans_object_base_flags(TransInfo *t) if (parsel != NULL) { /* Rotation around local centers are allowed to propagate. */ if ((t->around == V3D_AROUND_LOCAL_ORIGINS) && - (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL)) { + (ELEM(t->mode, TFM_ROTATION, TFM_TRACKBALL))) { base->flag_legacy |= BA_TRANSFORM_CHILD; } else { @@ -432,8 +432,7 @@ static int count_proportional_objects(TransInfo *t) /* Clear all flags we need. It will be used to detect dependencies. */ trans_object_base_deps_flag_prepare(view_layer); /* Rotations around local centers are allowed to propagate, so we take all objects. */ - if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) && - (t->mode == TFM_ROTATION || t->mode == TFM_TRACKBALL))) { + if (!((t->around == V3D_AROUND_LOCAL_ORIGINS) && (ELEM(t->mode, TFM_ROTATION, TFM_TRACKBALL)))) { /* Mark all parents. */ LISTBASE_FOREACH (Base *, base, &view_layer->object_bases) { if (BASE_SELECTED_EDITABLE(v3d, base) && BASE_SELECTABLE(v3d, base)) { -- cgit v1.2.3