diff options
57 files changed, 95 insertions, 103 deletions
diff --git a/source/blender/blendthumb/src/blendthumb_extract.cc b/source/blender/blendthumb/src/blendthumb_extract.cc index 99b13c89994..f1c5567bab5 100644 --- a/source/blender/blendthumb/src/blendthumb_extract.cc +++ b/source/blender/blendthumb/src/blendthumb_extract.cc @@ -42,7 +42,7 @@ static bool blend_header_check_magic(const char header[12]) return false; } /* Check pointer size and endianness indicators. */ - if (((header[7] != '_') && (header[7] != '-')) || ((header[8] != 'v') && (header[8] != 'V'))) { + if (!ELEM(header[7], '_', '-') || !ELEM(header[8], 'v', 'V')) { return false; } /* Check version number. */ diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc index 0658569752c..d0510e0008e 100644 --- a/source/blender/blenkernel/intern/attribute_access.cc +++ b/source/blender/blenkernel/intern/attribute_access.cc @@ -1060,7 +1060,7 @@ std::unique_ptr<blender::fn::GVArray> GeometryComponent::attribute_try_get_for_r } std::unique_ptr<blender::fn::GVArray> varray = std::move(attribute.varray); - if (domain != ATTR_DOMAIN_AUTO && attribute.domain != domain) { + if (!ELEM(domain, ATTR_DOMAIN_AUTO, attribute.domain)) { varray = this->attribute_try_adapt_domain(std::move(varray), attribute.domain, domain); if (!varray) { return {}; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index b0fc1426093..620110f7881 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -3347,7 +3347,7 @@ static void calchandleNurb_intern(BezTriple *bezt, if (skip_align || /* when one handle is free, alignming makes no sense, see: T35952 */ - (ELEM(HD_FREE, bezt->h1, bezt->h2)) || + ELEM(HD_FREE, bezt->h1, bezt->h2) || /* also when no handles are aligned, skip this step */ (!ELEM(HD_ALIGN, bezt->h1, bezt->h2) && !ELEM(HD_ALIGN_DOUBLESIDE, bezt->h1, bezt->h2))) { /* handles need to be updated during animation and applying stuff like hooks, diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 6fc3e0fa8e2..2ef7ef91160 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -5883,8 +5883,7 @@ static void dynamic_paint_surface_pre_step_cb(void *__restrict userdata, } /* dissolve for float types */ else if (surface->flags & MOD_DPAINT_DISSOLVE && - (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT)) { + ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WEIGHT)) { float *point = &((float *)sData->type_data)[index]; /* log or linear */ value_dissolve( diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index e272b71acb8..6b7594dcf36 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -2676,7 +2676,7 @@ static void update_flowsflags(FluidDomainSettings *fds, Object **flowobjs, int n } /* Activate color field if flows add smoke with varying colors. */ if (ffs->density != 0.0 && - (ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE)) { + ELEM(ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_SMOKEFIRE)) { if (!(active_fields & FLUID_DOMAIN_ACTIVE_COLOR_SET)) { copy_v3_v3(fds->active_color, ffs->color); active_fields |= FLUID_DOMAIN_ACTIVE_COLOR_SET; diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 59cdb6a2b27..adfbe4b8c94 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -454,10 +454,10 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu, mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu; /* cyclic correction */ - if ((i == 1 || i == 2) && mloopuv->uv[0] == 0.0f) { + if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) { mloopuv->uv[0] = 1.0f; } - if ((i == 0 || i == 1) && mloopuv->uv[1] == 0.0f) { + if ((ELEM(i, 0, 1)) && mloopuv->uv[1] == 0.0f) { mloopuv->uv[1] = 1.0f; } } diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 0dffa63d044..b47fe45c868 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1417,7 +1417,7 @@ void nodeUnregisterType(bNodeType *nt) bool nodeTypeUndefined(bNode *node) { return (node->typeinfo == &NodeTypeUndefined) || - ((node->type == NODE_GROUP || node->type == NODE_CUSTOM_GROUP) && node->id && + ((ELEM(node->type, NODE_GROUP, NODE_CUSTOM_GROUP)) && node->id && ID_IS_LINKED(node->id) && (node->id->tag & LIB_TAG_MISSING)); } diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index e3bb384ffcc..2f3b229a180 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -5628,7 +5628,7 @@ bool BKE_object_modifier_update_subframe(Depsgraph *depsgraph, /* skip subframe if object is parented * to vertex of a dynamic paint canvas */ - if (no_update && (ob->partype == PARVERT1 || ob->partype == PARVERT3)) { + if (no_update && (ELEM(ob->partype, PARVERT1, PARVERT3))) { return false; } diff --git a/source/blender/blenlib/intern/boxpack_2d.c b/source/blender/blenlib/intern/boxpack_2d.c index 4a07f1134d0..cf5831cada5 100644 --- a/source/blender/blenlib/intern/boxpack_2d.c +++ b/source/blender/blenlib/intern/boxpack_2d.c @@ -516,7 +516,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r * flag verts on one or both of the boxes * as being used by checking the width or * height of both boxes */ - if (vert->tlb && vert->trb && (box == vert->tlb || box == vert->trb)) { + if (vert->tlb && vert->trb && (ELEM(box, vert->tlb, vert->trb))) { if (UNLIKELY(fabsf(vert->tlb->h - vert->trb->h) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->trb->v[TL]) @@ -547,7 +547,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r vert->tlb->v[TR]->free &= ~(TRF | BRF); } } - else if (vert->blb && vert->brb && (box == vert->blb || box == vert->brb)) { + else if (vert->blb && vert->brb && (ELEM(box, vert->blb, vert->brb))) { if (UNLIKELY(fabsf(vert->blb->h - vert->brb->h) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->blb->v[BR]) @@ -579,7 +579,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r } } /* Horizontal */ - if (vert->tlb && vert->blb && (box == vert->tlb || box == vert->blb)) { + if (vert->tlb && vert->blb && (ELEM(box, vert->tlb, vert->blb))) { if (UNLIKELY(fabsf(vert->tlb->w - vert->blb->w) < EPSILON_MERGE)) { #ifdef USE_MERGE # define A (vert->blb->v[TL]) @@ -610,7 +610,7 @@ void BLI_box_pack_2d(BoxPack *boxarray, const uint len, float *r_tot_x, float *r vert->tlb->v[BL]->free &= ~(BLF | BRF); } } - else if (vert->trb && vert->brb && (box == vert->trb || box == vert->brb)) { + else if (vert->trb && vert->brb && (ELEM(box, vert->trb, vert->brb))) { if (UNLIKELY(fabsf(vert->trb->w - vert->brb->w) < EPSILON_MERGE)) { #ifdef USE_MERGE diff --git a/source/blender/blenlib/intern/delaunay_2d.cc b/source/blender/blenlib/intern/delaunay_2d.cc index 4582ea69d9b..53e881a9fc7 100644 --- a/source/blender/blenlib/intern/delaunay_2d.cc +++ b/source/blender/blenlib/intern/delaunay_2d.cc @@ -2274,8 +2274,8 @@ void add_face_constraints(CDT_state<T> *cdt_state, * making valid BMesh faces. */ int id = cdt_state->need_ids ? f : 0; add_face_ids(cdt_state, face_symedge0, id, fedge_start, fedge_end); - if (cdt_state->need_ids || (output_type == CDT_CONSTRAINTS_VALID_BMESH || - output_type == CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) { + if (cdt_state->need_ids || + ELEM(output_type, CDT_CONSTRAINTS_VALID_BMESH, CDT_CONSTRAINTS_VALID_BMESH_WITH_HOLES)) { add_face_ids(cdt_state, face_symedge0, f, fedge_start, fedge_end); } } diff --git a/source/blender/blenlib/intern/filereader_gzip.c b/source/blender/blenlib/intern/filereader_gzip.c index 72eb153a8b9..fe766e5da41 100644 --- a/source/blender/blenlib/intern/filereader_gzip.c +++ b/source/blender/blenlib/intern/filereader_gzip.c @@ -64,7 +64,7 @@ static ssize_t gzip_read(FileReader *reader, void *buffer, size_t size) int ret = inflate(&gzip->strm, Z_NO_FLUSH); - if (ret != Z_OK && ret != Z_BUF_ERROR) { + if (!ELEM(ret, Z_OK, Z_BUF_ERROR)) { break; } } diff --git a/source/blender/blenlib/intern/noise.cc b/source/blender/blenlib/intern/noise.cc index 58b6bb638e9..5fa2746d07f 100644 --- a/source/blender/blenlib/intern/noise.cc +++ b/source/blender/blenlib/intern/noise.cc @@ -410,7 +410,7 @@ BLI_INLINE float noise_grad(uint32_t hash, float x, float y, float z) { uint32_t h = hash & 15u; float u = h < 8u ? x : y; - float vt = ((h == 12u) || (h == 14u)) ? x : z; + float vt = ELEM(h, 12u, 14u) ? x : z; float v = h < 4u ? y : vt; return negate_if(u, h & 1u) + negate_if(v, h & 2u); } diff --git a/source/blender/blenlib/intern/scanfill_utils.c b/source/blender/blenlib/intern/scanfill_utils.c index ec0f8659395..33c0f4afd01 100644 --- a/source/blender/blenlib/intern/scanfill_utils.c +++ b/source/blender/blenlib/intern/scanfill_utils.c @@ -156,15 +156,13 @@ static ScanFillEdge *edge_step(PolyInfo *poly_info, eed = (e_curr->next && e_curr != poly_info[poly_nr].edge_last) ? e_curr->next : poly_info[poly_nr].edge_first; - if ((v_curr == eed->v1 || v_curr == eed->v2) == true && - (ELEM(v_prev, eed->v1, eed->v2)) == false) { + if (ELEM(v_curr, eed->v1, eed->v2) == true && ELEM(v_prev, eed->v1, eed->v2) == false) { return eed; } eed = (e_curr->prev && e_curr != poly_info[poly_nr].edge_first) ? e_curr->prev : poly_info[poly_nr].edge_last; - if ((v_curr == eed->v1 || v_curr == eed->v2) == true && - (ELEM(v_prev, eed->v1, eed->v2)) == false) { + if (ELEM(v_curr, eed->v1, eed->v2) == true && ELEM(v_prev, eed->v1, eed->v2) == false) { return eed; } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 8bd498a08bd..6cf3641fed2 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -4691,7 +4691,7 @@ static VMesh *pipe_adj_vmesh(BevelParams *bp, BevVert *bv, BoundVert *vpipe) * vertices to snap to the midline on the pipe, not just to one plane or the other. */ bool even = (ns % 2) == 0; bool midline = even && k == half_ns && - ((i == 0 && j == half_ns) || (i == ipipe1 || i == ipipe2)); + ((i == 0 && j == half_ns) || (ELEM(i, ipipe1, ipipe2))); snap_to_pipe_profile(vpipe, midline, mesh_vert(vm, i, j, k)->co); } } @@ -5217,7 +5217,7 @@ static void bevel_build_rings(BevelParams *bp, BMesh *bm, BevVert *bv, BoundVert for (int i = 0; i < n_bndv; i++) { for (int j = 0; j <= ns2; j++) { for (int k = 0; k <= ns; k++) { - if (j == 0 && (k == 0 || k == ns)) { + if (j == 0 && (ELEM(k, 0, ns))) { continue; /* Boundary corners already made. */ } if (!is_canon(vm, i, j, k)) { @@ -5794,7 +5794,7 @@ static void build_vmesh(BevelParams *bp, BMesh *bm, BevVert *bv) /* Make sure the pipe case ADJ mesh is used for both the "Grid Fill" (ADJ) and cutoff options. */ BoundVert *vpipe = NULL; - if ((vm->count == 3 || vm->count == 4) && bp->seg > 1) { + if (ELEM(vm->count, 3, 4) && bp->seg > 1) { /* Result is passed to bevel_build_rings to avoid overhead. */ vpipe = pipe_test(bv); if (vpipe) { diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index a3a5d6b065a..7b66026f7ad 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -2431,9 +2431,9 @@ GPUBatch *DRW_cache_bone_stick_get(void) /* Bone rectangle */ pos[0] = 0.0f; for (int i = 0; i < 6; i++) { - pos[1] = (ELEM(i, 0, 3)) ? 0.0f : ((i < 3) ? 1.0f : -1.0f); - flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | ((i == 0 || i == 3) ? 0 : COL_WIRE) | - COL_BONE | POS_BONE; + pos[1] = ELEM(i, 0, 3) ? 0.0f : ((i < 3) ? 1.0f : -1.0f); + flag = ((i < 2 || i > 4) ? POS_HEAD : POS_TAIL) | (ELEM(i, 0, 3) ? 0 : COL_WIRE) | COL_BONE | + POS_BONE; GPU_vertbuf_attr_set(vbo, attr_id.pos, v, pos); GPU_vertbuf_attr_set(vbo, attr_id.flag, v, &flag); GPU_indexbuf_add_generic_vert(&elb, v++); diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index 1fed5d79697..fb8f998f036 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -372,10 +372,10 @@ static void surf_uv_quad(const DispList *dl, const uint quad[4], float r_uv[4][2 r_uv[i][1] = (quad[i] % dl->nr) / (float)orco_sizeu; /* cyclic correction */ - if ((i == 1 || i == 2) && r_uv[i][0] == 0.0f) { + if (ELEM(i, 1, 2) && r_uv[i][0] == 0.0f) { r_uv[i][0] = 1.0f; } - if ((i == 0 || i == 1) && r_uv[i][1] == 0.0f) { + if (ELEM(i, 0, 1) && r_uv[i][1] == 0.0f) { r_uv[i][1] = 1.0f; } } 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)) { diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c index 7441c9a909c..6660da79b40 100644 --- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c +++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c @@ -1830,7 +1830,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu if (usage == OBJECT_LRT_INTERSECTION_ONLY) { tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY; } - else if (usage == OBJECT_LRT_NO_INTERSECTION || usage == OBJECT_LRT_OCCLUSION_ONLY) { + else if (ELEM(usage, OBJECT_LRT_NO_INTERSECTION, OBJECT_LRT_OCCLUSION_ONLY)) { tri->flags |= LRT_TRIANGLE_NO_INTERSECTION; } @@ -1917,8 +1917,7 @@ static void lineart_geometry_object_load(LineartObjectInfo *obi, LineartRenderBu la_e->flags = use_type; la_e->object_ref = orig_ob; BLI_addtail(&la_e->segments, la_s); - if (usage == OBJECT_LRT_INHERIT || usage == OBJECT_LRT_INCLUDE || - usage == OBJECT_LRT_NO_INTERSECTION) { + if (ELEM(usage, OBJECT_LRT_INHERIT, OBJECT_LRT_INCLUDE, OBJECT_LRT_NO_INTERSECTION)) { lineart_add_edge_to_list_thread(obi, la_e); } diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 70bb70ec4fa..5b9d78f5614 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -151,8 +151,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[ } /* Validate and cross-check offsets and sizes. */ - if (x < 1 || - !(depth == 1 || depth == 4 || depth == 8 || depth == 16 || depth == 24 || depth == 32)) { + if (x < 1 || !(ELEM(depth, 1, 4, 8, 16, 24, 32))) { return NULL; } diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index 7b68e3f3bea..623c00fa670 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -457,7 +457,7 @@ static int imb_read_tiff_pixels(ImBuf *ibuf, TIFF *image) } /* simple RGBA image */ - if (!(bitspersample == 32 || bitspersample == 16)) { + if (!(ELEM(bitspersample, 32, 16))) { success |= TIFFReadRGBAImage(image, ibuf->x, ibuf->y, tmpibuf->rect, 0); } /* contiguous channels: RGBRGBRGB */ diff --git a/source/blender/io/avi/intern/avi.c b/source/blender/io/avi/intern/avi.c index 88f2e1a259f..87058693378 100644 --- a/source/blender/io/avi/intern/avi.c +++ b/source/blender/io/avi/intern/avi.c @@ -145,7 +145,7 @@ static bool fcc_is_data(int fcc) fccs[2] = fcc >> 16; fccs[3] = fcc >> 24; - if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (fccs[2] != 'd' && fccs[2] != 'w')) { + if (!isdigit(fccs[0]) || !isdigit(fccs[1]) || (!ELEM(fccs[2], 'd', 'w'))) { return 0; } if (!ELEM(fccs[3], 'b', 'c')) { diff --git a/source/blender/io/usd/intern/usd_reader_material.cc b/source/blender/io/usd/intern/usd_reader_material.cc index 93e433e231c..317dfd2a62b 100644 --- a/source/blender/io/usd/intern/usd_reader_material.cc +++ b/source/blender/io/usd/intern/usd_reader_material.cc @@ -648,7 +648,7 @@ void USDMaterialReader::load_tex_image(const pxr::UsdShadeShader &usd_shader, color_space = file_input.GetAttr().GetColorSpace(); } - if (color_space == usdtokens::RAW || color_space == usdtokens::raw) { + if (ELEM(color_space, usdtokens::RAW, usdtokens::raw)) { STRNCPY(image->colorspace_settings.name, "Raw"); } } diff --git a/source/blender/io/usd/intern/usd_reader_mesh.cc b/source/blender/io/usd/intern/usd_reader_mesh.cc index 9c75bc8afae..5c8bd88e87a 100644 --- a/source/blender/io/usd/intern/usd_reader_mesh.cc +++ b/source/blender/io/usd/intern/usd_reader_mesh.cc @@ -390,8 +390,9 @@ void USDMeshReader::read_uvs(Mesh *mesh, const double motionSampleTime, const bo const UVSample &sample = uv_primvars[layer_idx]; - if (!(sample.interpolation == pxr::UsdGeomTokens->faceVarying || - sample.interpolation == pxr::UsdGeomTokens->vertex)) { + if (!(ELEM(sample.interpolation, + pxr::UsdGeomTokens->faceVarying, + pxr::UsdGeomTokens->vertex))) { std::cerr << "WARNING: unexpected interpolation type " << sample.interpolation << " for uv " << layer->name << std::endl; continue; @@ -781,9 +782,10 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, bool is_uv = false; /* Assume all UVs are stored in one of these primvar types */ - if (type == pxr::SdfValueTypeNames->TexCoord2hArray || - type == pxr::SdfValueTypeNames->TexCoord2fArray || - type == pxr::SdfValueTypeNames->TexCoord2dArray) { + if (ELEM(type, + pxr::SdfValueTypeNames->TexCoord2hArray, + pxr::SdfValueTypeNames->TexCoord2fArray, + pxr::SdfValueTypeNames->TexCoord2dArray)) { is_uv = true; } /* In some cases, the st primvar is stored as float2 values. */ @@ -795,7 +797,7 @@ Mesh *USDMeshReader::read_mesh(Mesh *existing_mesh, pxr::TfToken interp = p.GetInterpolation(); - if (!(interp == pxr::UsdGeomTokens->faceVarying || interp == pxr::UsdGeomTokens->vertex)) { + if (!(ELEM(interp, pxr::UsdGeomTokens->faceVarying, pxr::UsdGeomTokens->vertex))) { continue; } diff --git a/source/blender/makesdna/intern/dna_genfile.c b/source/blender/makesdna/intern/dna_genfile.c index 83e55f3bf0d..8aa2a07d071 100644 --- a/source/blender/makesdna/intern/dna_genfile.c +++ b/source/blender/makesdna/intern/dna_genfile.c @@ -525,7 +525,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error sdna->pointer_size = sdna->types_size[struct_info->type] / 2; - if (struct_info->members_len != 2 || (sdna->pointer_size != 4 && sdna->pointer_size != 8)) { + if (struct_info->members_len != 2 || (!ELEM(sdna->pointer_size, 4, 8))) { *r_error_message = "ListBase struct error! Needs it to calculate pointerize."; /* well, at least sizeof(ListBase) is error proof! (ton) */ return false; diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index 9a8af35109a..f452b0c7091 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -464,7 +464,7 @@ void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, BLI_assert(src_mesh.totedge == edge_map.size()); for (const int i_src : IndexRange(src_mesh.totedge)) { const int i_dst = edge_map[i_src]; - if (i_dst == -1 || i_dst == -2) { + if (ELEM(i_dst, -1, -2)) { continue; } diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 7d90935f678..07ce819e91c 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -1479,7 +1479,7 @@ static void quad_from_tris(BMEdge *e, BMFace *adj[2], BMVert *ndx[4]) ndx[j] = tri[0][i]; /* When the triangle edge cuts across our quad-to-be, * throw in the second triangle's vertex */ - if ((tri[0][i] == e->v1 || tri[0][i] == e->v2) && + if ((ELEM(tri[0][i], e->v1, e->v2)) && (tri[0][(i + 1) % 3] == e->v1 || tri[0][(i + 1) % 3] == e->v2)) { j++; ndx[j] = opp; diff --git a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc index efc2dff48c1..8d5f4855512 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_curve_primitive_circle.cc @@ -77,7 +77,7 @@ static bool colinear_f3_f3_f3(const float3 p1, const float3 p2, const float3 p3) { const float3 a = (p2 - p1).normalized(); const float3 b = (p3 - p1).normalized(); - return (a == b || a == b * -1.0f); + return (ELEM(a, b, b * -1.0f)); } static std::unique_ptr<CurveEval> create_point_circle_curve( diff --git a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc index 25f0d355c9e..e293cd9b8fe 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_delete_geometry.cc @@ -202,7 +202,7 @@ static void copy_masked_edges_to_new_mesh(const Mesh &src_mesh, Mesh &dst_mesh, BLI_assert(src_mesh.totedge == edge_map.size()); for (const int i_src : IndexRange(src_mesh.totedge)) { const int i_dst = edge_map[i_src]; - if (i_dst == -1 || i_dst == -2) { + if (ELEM(i_dst, -1, -2)) { continue; } diff --git a/source/blender/nodes/shader/node_shader_util.c b/source/blender/nodes/shader/node_shader_util.c index abc2c7008c7..97041b3fdfd 100644 --- a/source/blender/nodes/shader/node_shader_util.c +++ b/source/blender/nodes/shader/node_shader_util.c @@ -40,7 +40,7 @@ static bool sh_fn_poll_default(bNodeType *UNUSED(ntype), bNodeTree *ntree, const char **r_disabled_hint) { - if (!STREQ(ntree->idname, "ShaderNodeTree") && !STREQ(ntree->idname, "GeometryNodeTree")) { + if (!STR_ELEM(ntree->idname, "ShaderNodeTree", "GeometryNodeTree")) { *r_disabled_hint = "Not a shader or geometry node tree"; return false; } diff --git a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c index 2d3957d159e..cb4f0594310 100644 --- a/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c +++ b/source/blender/nodes/shader/nodes/node_shader_bsdf_principled.c @@ -183,7 +183,7 @@ static void node_shader_update_principled(bNodeTree *UNUSED(ntree), bNode *node) } } - if (STREQ(sock->name, "Subsurface IOR") || STREQ(sock->name, "Subsurface Anisotropy")) { + if (STR_ELEM(sock->name, "Subsurface IOR", "Subsurface Anisotropy")) { if (sss_method == SHD_SUBSURFACE_BURLEY) { sock->flag |= SOCK_UNAVAIL; } diff --git a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc index 07904123ace..574260f3c36 100644 --- a/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc +++ b/source/blender/nodes/shader/nodes/node_shader_tex_voronoi.cc @@ -157,7 +157,7 @@ static void node_shader_update_tex_voronoi(bNodeTree *UNUSED(ntree), bNode *node nodeSetSocketAvailability(outWSock, tex->feature != SHD_VORONOI_DISTANCE_TO_EDGE && tex->feature != SHD_VORONOI_N_SPHERE_RADIUS && - (tex->dimensions == 1 || tex->dimensions == 4)); + (ELEM(tex->dimensions, 1, 4))); nodeSetSocketAvailability(outRadiusSock, tex->feature == SHD_VORONOI_N_SPHERE_RADIUS); } @@ -211,7 +211,7 @@ class VoronoiMinowskiFunction : public fn::MultiFunction { if (dimensions != 1) { signature.single_output<float3>("Position"); } - if ((dimensions == 1 || dimensions == 4)) { + if (ELEM(dimensions, 1, 4)) { signature.single_output<float>("W"); } @@ -547,7 +547,7 @@ class VoronoiMetricFunction : public fn::MultiFunction { if (dimensions != 1) { signature.single_output<float3>("Position"); } - if ((dimensions == 1 || dimensions == 4)) { + if (ELEM(dimensions, 1, 4)) { signature.single_output<float>("W"); } @@ -1048,8 +1048,7 @@ static void sh_node_voronoi_build_multi_function(blender::nodes::NodeMultiFuncti NodeTexVoronoi *tex = (NodeTexVoronoi *)node.storage; bool minowski = (tex->distance == SHD_VORONOI_MINKOWSKI && tex->dimensions != 1 && !ELEM(tex->feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS)); - bool dist_radius = (tex->feature == SHD_VORONOI_DISTANCE_TO_EDGE || - tex->feature == SHD_VORONOI_N_SPHERE_RADIUS); + bool dist_radius = ELEM(tex->feature, SHD_VORONOI_DISTANCE_TO_EDGE, SHD_VORONOI_N_SPHERE_RADIUS); if (dist_radius) { builder.construct_and_set_matching_fn<VoronoiEdgeFunction>(tex->dimensions, tex->feature); } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 8c83f611b5c..1296a6c174c 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -5495,7 +5495,7 @@ static PyObject *pyprop_array_foreach_getset(BPy_PropertyArrayRNA *self, } else { const char f = buf.format ? buf.format[0] : 0; - if ((prop_type == PROP_INT && (buf.itemsize != sizeof(int) || (f != 'l' && f != 'i'))) || + if ((prop_type == PROP_INT && (buf.itemsize != sizeof(int) || (!ELEM(f, 'l', 'i')))) || (prop_type == PROP_FLOAT && (buf.itemsize != sizeof(float) || f != 'f'))) { PyBuffer_Release(&buf); PyErr_Format(PyExc_TypeError, "incorrect sequence item type: %s", buf.format); diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index ce04a143aae..28b91e13d47 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -526,7 +526,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args) "cannot create a 2x2 rotation matrix around arbitrary axis"); return NULL; } - if ((matSize == 3 || matSize == 4) && (axis == NULL) && (vec == NULL)) { + if ((ELEM(matSize, 3, 4)) && (axis == NULL) && (vec == NULL)) { PyErr_SetString(PyExc_ValueError, "Matrix.Rotation(): " "axis of rotation for 3d and 4d matrices is required"); diff --git a/source/blender/render/intern/texture_image.c b/source/blender/render/intern/texture_image.c index edfa284242c..dfeaec2341e 100644 --- a/source/blender/render/intern/texture_image.c +++ b/source/blender/render/intern/texture_image.c @@ -959,7 +959,7 @@ static void alpha_clip_aniso( /* TXF alpha: we're doing the same alpha-clip here as box-sample, but I'm doubting * if this is actually correct for the all the filtering algorithms. */ - if (!(extflag == TXC_REPT || extflag == TXC_EXTD)) { + if (!(ELEM(extflag, TXC_REPT, TXC_EXTD))) { rf.xmin = minx * (ibuf->x); rf.xmax = maxx * (ibuf->x); rf.ymin = miny * (ibuf->y); diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c index 7b3d342b2e4..c742fca0562 100644 --- a/source/blender/sequencer/intern/image_cache.c +++ b/source/blender/sequencer/intern/image_cache.c @@ -151,7 +151,7 @@ static float seq_cache_timeline_frame_to_frame_index(Sequence *seq, float timeli /* With raw images, map timeline_frame to strip input media frame range. This means that static * images or extended frame range of movies will only generate one cache entry. No special * treatment in converting frame index to timeline_frame is needed. */ - if (type == SEQ_CACHE_STORE_RAW || type == SEQ_CACHE_STORE_THUMBNAIL) { + if (ELEM(type, SEQ_CACHE_STORE_RAW, SEQ_CACHE_STORE_THUMBNAIL)) { return seq_give_frame_index(seq, timeline_frame); } diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 7e8910644b6..dffbea64a30 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -505,8 +505,7 @@ void wm_event_do_notifiers(bContext *C) } } - if (note->window == win || - (note->window == NULL && (note->reference == NULL || note->reference == scene))) { + if (note->window == win || (note->window == NULL && (ELEM(note->reference, NULL, scene)))) { if (note->category == NC_SCENE) { if (note->data == ND_FRAME) { do_anim = true; diff --git a/source/blender/windowmanager/xr/intern/wm_xr_action.c b/source/blender/windowmanager/xr/intern/wm_xr_action.c index ba347c537ec..b5a606b4298 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_action.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_action.c @@ -118,7 +118,7 @@ static wmXrAction *action_create(const char *action_name, action->states = MEM_calloc_arrayN(count, size, "XrAction_States"); action->states_prev = MEM_calloc_arrayN(count, size, "XrAction_StatesPrev"); - const bool is_float_action = (type == XR_FLOAT_INPUT || type == XR_VECTOR2F_INPUT); + const bool is_float_action = ELEM(type, XR_FLOAT_INPUT, XR_VECTOR2F_INPUT); const bool is_button_action = (is_float_action || type == XR_BOOLEAN_INPUT); if (is_float_action) { action->float_thresholds = MEM_calloc_arrayN( |