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/blenkernel | |
parent | 7cb20d841da16d0bffb63154403267500e9941f5 (diff) |
Cleanup: use ELEM macro
Diffstat (limited to 'source/blender/blenkernel')
24 files changed, 49 insertions, 51 deletions
diff --git a/source/blender/blenkernel/intern/CCGSubSurf.c b/source/blender/blenkernel/intern/CCGSubSurf.c index d63c5fe12ab..67e7b890548 100644 --- a/source/blender/blenkernel/intern/CCGSubSurf.c +++ b/source/blender/blenkernel/intern/CCGSubSurf.c @@ -736,7 +736,7 @@ CCGError ccgSubSurf_syncFace( } } else { - if (ss->syncState == eSyncState_Vert || ss->syncState == eSyncState_Edge) { + if (ELEM(ss->syncState, eSyncState_Vert, eSyncState_Edge)) { ss->syncState = eSyncState_Face; } else if (ss->syncState != eSyncState_Face) { diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c index 7b2e1be7b5d..eeff04788f9 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.c +++ b/source/blender/blenkernel/intern/DerivedMesh.c @@ -2190,7 +2190,7 @@ static void mesh_init_origspace(Mesh *mesh) for (i = 0; i < numpoly; i++, mp++) { OrigSpaceLoop *lof = lof_array + mp->loopstart; - if (mp->totloop == 3 || mp->totloop == 4) { + if (ELEM(mp->totloop, 3, 4)) { for (j = 0; j < mp->totloop; j++, lof++) { copy_v2_v2(lof->uv, default_osf[j]); } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 61726d28f12..fb885527cce 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -801,7 +801,7 @@ bool bone_autoside_name( while (changed) { /* remove extensions */ changed = false; if (len > 2 && basename[len - 2] == '.') { - if (basename[len - 1] == 'L' || basename[len - 1] == 'R') { /* L R */ + if (ELEM(basename[len - 1], 'L', 'R')) { /* L R */ basename[len - 2] = '\0'; len -= 2; changed = true; diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 38c1b0d9211..091d542c43d 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2869,15 +2869,15 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) /* indicate with handlecodes double points */ if (prevbezt->h1 == prevbezt->h2) { - if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) { + if (ELEM(prevbezt->h1, 0, HD_VECT)) { bevp->split_tag = true; } } else { - if (prevbezt->h1 == 0 || prevbezt->h1 == HD_VECT) { + if (ELEM(prevbezt->h1, 0, HD_VECT)) { bevp->split_tag = true; } - else if (prevbezt->h2 == 0 || prevbezt->h2 == HD_VECT) { + else if (ELEM(prevbezt->h2, 0, HD_VECT)) { bevp->split_tag = true; } } @@ -4961,7 +4961,7 @@ bool BKE_nurb_type_convert(Nurb *nu, } } else if (nu->type == CU_BEZIER) { /* Bezier */ - if (type == CU_POLY || type == CU_NURBS) { + if (ELEM(type, CU_POLY, CU_NURBS)) { nr = use_handles ? (3 * nu->pntsu) : nu->pntsu; nu->bp = MEM_calloc_arrayN(nr, sizeof(BPoint), "setsplinetype"); a = nu->pntsu; diff --git a/source/blender/blenkernel/intern/curve_decimate.c b/source/blender/blenkernel/intern/curve_decimate.c index 68c0d2a3cec..e4647908b58 100644 --- a/source/blender/blenkernel/intern/curve_decimate.c +++ b/source/blender/blenkernel/intern/curve_decimate.c @@ -269,11 +269,11 @@ uint BKE_curve_decimate_bezt_array(BezTriple *bezt_array, if (a == HD_VECT) { \ a = HD_FREE; \ } \ - else if (a == HD_AUTO || a == HD_AUTO_ANIM) { \ + else if (ELEM(a, HD_AUTO, HD_AUTO_ANIM)) { \ a = HD_ALIGN; \ } \ /* opposite handle */ \ - if (b == HD_AUTO || b == HD_AUTO_ANIM) { \ + if (ELEM(b, HD_AUTO, HD_AUTO_ANIM)) { \ b = HD_ALIGN; \ } \ } \ diff --git a/source/blender/blenkernel/intern/curve_deform.c b/source/blender/blenkernel/intern/curve_deform.c index d4f197521a1..4c72e23570e 100644 --- a/source/blender/blenkernel/intern/curve_deform.c +++ b/source/blender/blenkernel/intern/curve_deform.c @@ -225,7 +225,7 @@ static bool calc_curve_deform( quat_apply_track( quat, axis, - (axis == 0 || axis == 2) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */ + (ELEM(axis, 0, 2)) ? 1 : 0); /* up flag is a dummy, set so no rotation is done */ vec_apply_track(cent, axis); cent[index] = 0.0f; diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 0ad09b2f664..fdb3e246382 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -2509,7 +2509,7 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data, return &data->layers[CustomData_get_layer_index(data, type)]; } - if ((alloctype == CD_ASSIGN) || (alloctype == CD_REFERENCE)) { + if (ELEM(alloctype, CD_ASSIGN, CD_REFERENCE)) { newlayerdata = layerdata; } else if (totelem > 0 && typeInfo->size > 0) { diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index c842ed3aa22..95408c7d01f 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2700,7 +2700,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa const int final_tri_index = tempPoints[final_index].tri_index; /* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */ - if (final_tri_index != target_tri && final_tri_index != -1) { + if (!ELEM(final_tri_index, target_tri, -1)) { /* Check if it's close enough to likely touch the intended triangle. Any triangle * becomes thinner than a pixel at its vertices, so robustness requires some margin. */ const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index / w) + 0.5f) / h}; @@ -3034,7 +3034,7 @@ int dynamicPaint_createUVSurface(Scene *scene, n_pos++; } } - else if (n_target == ON_MESH_EDGE || n_target == OUT_OF_TEXTURE) { + else if (ELEM(n_target, ON_MESH_EDGE, OUT_OF_TEXTURE)) { ed->flags[final_index[index]] |= ADJ_ON_MESH_EDGE; } } @@ -3736,7 +3736,7 @@ static bool meshBrush_boundsIntersect(Bounds3D *b1, if (brush->collision == MOD_DPAINT_COL_VOLUME) { return boundsIntersect(b1, b2); } - if (brush->collision == MOD_DPAINT_COL_DIST || brush->collision == MOD_DPAINT_COL_VOLDIST) { + if (ELEM(brush->collision, MOD_DPAINT_COL_DIST, MOD_DPAINT_COL_VOLDIST)) { return boundsIntersectDist(b1, b2, brush_radius); } return true; @@ -4710,8 +4710,7 @@ static void dynamic_paint_paint_single_point_cb_ex(void *__restrict userdata, } /* Smooth range or color ramp */ - if (brush->proximity_falloff == MOD_DPAINT_PRFALL_SMOOTH || - brush->proximity_falloff == MOD_DPAINT_PRFALL_RAMP) { + if (ELEM(brush->proximity_falloff, MOD_DPAINT_PRFALL_SMOOTH, MOD_DPAINT_PRFALL_RAMP)) { strength = 1.0f - distance / brush_radius; CLAMP(strength, 0.0f, 1.0f); } diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index bd7d65f1e6f..47d4b70fef5 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1260,7 +1260,7 @@ void calchandles_fcurve_ex(FCurve *fcu, eBezTriple_Flag handle_sel_flag) /* For automatic ease in and out. */ if (BEZT_IS_AUTOH(bezt) && !cycle) { /* Only do this on first or last beztriple. */ - if ((a == 0) || (a == fcu->totvert - 1)) { + if (ELEM(a, 0, fcu->totvert - 1)) { /* Set both handles to have same horizontal value as keyframe. */ if (fcu->extend == FCURVE_EXTRAPOLATE_CONSTANT) { bezt->vec[0][1] = bezt->vec[2][1] = bezt->vec[1][1]; diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c index 70f8483efd3..9431915b4e4 100644 --- a/source/blender/blenkernel/intern/font.c +++ b/source/blender/blenkernel/intern/font.c @@ -949,7 +949,7 @@ static bool vfont_to_curve(Object *ob, // CLOG_WARN(&LOG, "linewidth exceeded: %c%c%c...", mem[i], mem[i+1], mem[i+2]); for (j = i; j && (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) { bool dobreak = false; - if (mem[j] == ' ' || mem[j] == '-') { + if (ELEM(mem[j], ' ', '-')) { ct -= (i - (j - 1)); cnr -= (i - (j - 1)); if (mem[j] == ' ') { diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index a4e07a76602..1dacd442e81 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -2670,7 +2670,7 @@ void BKE_gpencil_parent_matrix_get(const Depsgraph *depsgraph, return; } - if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) { + if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { mul_m4_m4m4(diff_mat, obparent_eval->obmat, gpl->inverse); add_v3_v3(diff_mat[3], ob_eval->obmat[3]); return; @@ -2712,7 +2712,7 @@ void BKE_gpencil_update_layer_parent(const Depsgraph *depsgraph, Object *ob) if ((gpl->parent != NULL) && (gpl->actframe != NULL)) { Object *ob_parent = DEG_get_evaluated_object(depsgraph, gpl->parent); /* calculate new matrix */ - if ((gpl->partype == PAROBJECT) || (gpl->partype == PARSKEL)) { + if (ELEM(gpl->partype, PAROBJECT, PARSKEL)) { copy_m4_m4(cur_mat, ob_parent->obmat); } else if (gpl->partype == PARBONE) { diff --git a/source/blender/blenkernel/intern/gpencil_geom.c b/source/blender/blenkernel/intern/gpencil_geom.c index 66a7ae757a2..ff7dde27db8 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.c +++ b/source/blender/blenkernel/intern/gpencil_geom.c @@ -189,7 +189,7 @@ BoundBox *BKE_gpencil_boundbox_get(Object *ob) /* Update orig object's boundbox with re-computed evaluated values. This function can be * called with the evaluated object and need update the original object bound box data * to keep both values synchronized. */ - if ((ob_orig != NULL) && (ob != ob_orig)) { + if (!ELEM(ob_orig, NULL, ob)) { if (ob_orig->runtime.bb == NULL) { ob_orig->runtime.bb = MEM_callocN(sizeof(BoundBox), "GPencil boundbox"); } @@ -778,7 +778,7 @@ bool BKE_gpencil_stroke_smooth(bGPDstroke *gps, int i, float inf) /* Only affect endpoints by a fraction of the normal strength, * to prevent the stroke from shrinking too much */ - if ((i == 0) || (i == gps->totpoints - 1)) { + if (ELEM(i, 0, gps->totpoints - 1)) { inf *= 0.1f; } @@ -838,7 +838,7 @@ bool BKE_gpencil_stroke_smooth_strength(bGPDstroke *gps, int point_index, float } /* Only affect endpoints by a fraction of the normal influence */ float inf = influence; - if ((point_index == 0) || (point_index == gps->totpoints - 1)) { + if (ELEM(point_index, 0, gps->totpoints - 1)) { inf *= 0.01f; } /* Limit max influence to reduce pop effect. */ @@ -902,7 +902,7 @@ bool BKE_gpencil_stroke_smooth_thickness(bGPDstroke *gps, int point_index, float } /* Only affect endpoints by a fraction of the normal influence */ float inf = influence; - if ((point_index == 0) || (point_index == gps->totpoints - 1)) { + if (ELEM(point_index, 0, gps->totpoints - 1)) { inf *= 0.01f; } /* Limit max influence to reduce pop effect. */ @@ -1402,7 +1402,7 @@ bool BKE_gpencil_stroke_trim(bGPDstroke *gps) memcpy(dvert->dw, dvert_src->dw, sizeof(MDeformWeight)); } } - if (idx == start || idx == end) { + if (ELEM(idx, start, end)) { copy_v3_v3(&pt_new->x, point); } } diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c index 5fb5e13d876..f87b1b5ff45 100644 --- a/source/blender/blenkernel/intern/image.c +++ b/source/blender/blenkernel/intern/image.c @@ -668,7 +668,7 @@ ImageTile *BKE_image_get_tile(Image *ima, int tile_number) /* Tile number 0 is a special case and refers to the first tile, typically * coming from non-UDIM-aware code. */ - if (tile_number == 0 || tile_number == 1001) { + if (ELEM(tile_number, 0, 1001)) { return ima->tiles.first; } @@ -805,7 +805,7 @@ Image *BKE_image_load_exists_ex(Main *bmain, const char *filepath, bool *r_exist /* first search an identical filepath */ for (ima = bmain->images.first; ima; ima = ima->id.next) { - if (ima->source != IMA_SRC_VIEWER && ima->source != IMA_SRC_GENERATED) { + if (!ELEM(ima->source, IMA_SRC_VIEWER, IMA_SRC_GENERATED)) { STRNCPY(strtest, ima->filepath); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &ima->id)); @@ -1316,7 +1316,7 @@ int BKE_image_imtype_to_ftype(const char imtype, ImbFormatOptions *r_options) return IMB_FTYPE_TIF; } #endif - if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) { + if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { return IMB_FTYPE_OPENEXR; } #ifdef WITH_CINEON @@ -1666,7 +1666,7 @@ static bool do_add_image_extension(char *string, } #endif #ifdef WITH_OPENEXR - else if (imtype == R_IMF_IMTYPE_OPENEXR || imtype == R_IMF_IMTYPE_MULTILAYER) { + else if (ELEM(imtype, R_IMF_IMTYPE_OPENEXR, R_IMF_IMTYPE_MULTILAYER)) { if (!BLI_path_extension_check(string, extension_test = ".exr")) { extension = extension_test; } diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c index 587b9eb1436..7468112b40e 100644 --- a/source/blender/blenkernel/intern/key.c +++ b/source/blender/blenkernel/intern/key.c @@ -1616,7 +1616,7 @@ int BKE_keyblock_element_count_from_shape(const Key *key, const int shape_index) int result = 0; int index = 0; for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { result += kb->totelem; } } @@ -1656,7 +1656,7 @@ void BKE_keyblock_data_get_from_shape(const Key *key, float (*arr)[3], const int uint8_t *elements = (uint8_t *)arr; int index = 0; for (const KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_len = kb->totelem * key->elemsize; memcpy(elements, kb->data, block_elem_len); elements += block_elem_len; @@ -1686,7 +1686,7 @@ void BKE_keyblock_data_set_with_mat4(Key *key, int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_len = kb->totelem; float(*block_data)[3] = (float(*)[3])kb->data; for (int data_offset = 0; data_offset < block_elem_len; ++data_offset) { @@ -1710,7 +1710,7 @@ void BKE_keyblock_curve_data_set_with_mat4( int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_size = kb->totelem * key->elemsize; BKE_keyblock_curve_data_transform(nurb, mat, elements, kb->data); elements += block_elem_size; @@ -1726,7 +1726,7 @@ void BKE_keyblock_data_set(Key *key, const int shape_index, const void *data) const uint8_t *elements = data; int index = 0; for (KeyBlock *kb = key->block.first; kb; kb = kb->next, index++) { - if ((shape_index == -1) || (index == shape_index)) { + if (ELEM(shape_index, -1, index)) { const int block_elem_size = kb->totelem * key->elemsize; memcpy(kb->data, elements, block_elem_size); elements += block_elem_size; diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index a7094a33752..cf9fff811ce 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -1331,7 +1331,7 @@ void id_sort_by_name(ListBase *lb, ID *id, ID *id_sorting_hint) BLI_remlink(lb, id); /* Check if we can actually insert id before or after id_sorting_hint, if given. */ - if (id_sorting_hint != NULL && id_sorting_hint != id) { + if (!ELEM(id_sorting_hint, NULL, id)) { BLI_assert(BLI_findindex(lb, id_sorting_hint) >= 0); ID *id_sorting_hint_next = id_sorting_hint->next; @@ -1569,7 +1569,7 @@ static bool check_for_dupid(ListBase *lb, ID *id, char *name, ID **r_id_sorting_ char base_name_test[MAX_ID_NAME - 2]; int number_test; if ((id != id_test) && !ID_IS_LINKED(id_test) && (name[0] == id_test->name[2]) && - (id_test->name[base_name_len + 2] == '.' || id_test->name[base_name_len + 2] == '\0') && + (ELEM(id_test->name[base_name_len + 2], '.', '\0')) && STREQLEN(name, id_test->name + 2, base_name_len) && (BLI_split_name_num(base_name_test, &number_test, id_test->name + 2, '.') == base_name_len)) { diff --git a/source/blender/blenkernel/intern/mesh_merge.c b/source/blender/blenkernel/intern/mesh_merge.c index 868694931cb..e118c1b6f6e 100644 --- a/source/blender/blenkernel/intern/mesh_merge.c +++ b/source/blender/blenkernel/intern/mesh_merge.c @@ -61,7 +61,7 @@ static int cddm_poly_compare(MLoop *mloop_array, MLoop *mloop_source, *mloop_target; - BLI_assert(direct_reverse == 1 || direct_reverse == -1); + BLI_assert(ELEM(direct_reverse, 1, -1)); i_loop_source = 0; mloop_source = mloop_array + mpoly_source->loopstart; diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 545f677e10a..58264432cdf 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1165,7 +1165,7 @@ ParticleSystem *psys_get_target_system(Object *ob, ParticleTarget *pt) { ParticleSystem *psys = NULL; - if (pt->ob == NULL || pt->ob == ob) { + if (ELEM(pt->ob, NULL, ob)) { psys = BLI_findlink(&ob->particlesystem, pt->psys - 1); } else { diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 44de92de04a..6a93245d995 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -738,8 +738,7 @@ static int ptcache_dynamicpaint_read(PTCacheFile *pf, void *dp_v) if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) { data_len = sizeof(PaintPoint); } - else if (surface->type == MOD_DPAINT_SURFACE_T_DISPLACE || - surface->type == MOD_DPAINT_SURFACE_T_WEIGHT) { + else if (ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WEIGHT)) { data_len = sizeof(float); } else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) { diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index 0a28ed7e9a1..1b8360a1cec 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -962,7 +962,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, int x, int if (area) { ARegion *region; for (region = area->regionbase.first; region; region = region->next) { - if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { + if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { region_found = region; break; @@ -980,7 +980,7 @@ ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, int x, { ARegion *region_found = NULL; LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { - if ((regiontype == RGN_TYPE_ANY) || (region->regiontype == regiontype)) { + if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) { if (BLI_rcti_isect_pt(®ion->winrct, x, y)) { region_found = region; break; @@ -1017,7 +1017,7 @@ ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const sh int size, maxsize = 0; for (area = screen->areabase.first; area; area = area->next) { - if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { + if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) { if (min <= area->winx && min <= area->winy) { size = area->winx * area->winy; if (size > maxsize) { @@ -1038,7 +1038,7 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, { LISTBASE_FOREACH (ScrArea *, area, &areamap->areabase) { if (BLI_rcti_isect_pt(&area->totrct, x, y)) { - if ((spacetype == SPACE_TYPE_ANY) || (area->spacetype == spacetype)) { + if (ELEM(spacetype, SPACE_TYPE_ANY, area->spacetype)) { return area; } break; diff --git a/source/blender/blenkernel/intern/softbody.c b/source/blender/blenkernel/intern/softbody.c index c2fc245ce41..efed9453003 100644 --- a/source/blender/blenkernel/intern/softbody.c +++ b/source/blender/blenkernel/intern/softbody.c @@ -2032,7 +2032,7 @@ static int _softbody_calc_forces_slice_in_a_thread(Scene *scene, attached = 0; for (b = obp->nofsprings; b > 0; b--) { bs = sb->bspring + obp->springs[b - 1]; - if ((ilast - bb == bs->v2) || (ilast - bb == bs->v1)) { + if (ELEM(ilast - bb, bs->v2, bs->v1)) { attached = 1; continue; } diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 619eb1ff90f..c09d3070da9 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2335,7 +2335,7 @@ int txt_setcurr_tab_spaces(Text *text, int space) if (ch == ':') { is_indent = 1; } - else if (ch != ' ' && ch != '\t') { + else if (!ELEM(ch, ' ', '\t')) { is_indent = 0; } } diff --git a/source/blender/blenkernel/intern/tracking_util.c b/source/blender/blenkernel/intern/tracking_util.c index bc6c94343b5..c7e4e0d5c08 100644 --- a/source/blender/blenkernel/intern/tracking_util.c +++ b/source/blender/blenkernel/intern/tracking_util.c @@ -722,7 +722,7 @@ static ImBuf *make_grayscale_ibuf_copy(ImBuf *ibuf) { ImBuf *grayscale = IMB_allocImBuf(ibuf->x, ibuf->y, 32, 0); - BLI_assert(ibuf->channels == 3 || ibuf->channels == 4); + BLI_assert(ELEM(ibuf->channels, 3, 4)); /* TODO(sergey): Bummer, currently IMB API only allows to create 4 channels * float buffer, so we do it manually here. @@ -880,7 +880,7 @@ static ImBuf *accessor_get_ibuf(TrackingImageAccessor *accessor, } /* Transform number of channels. */ if (input_mode == LIBMV_IMAGE_MODE_RGBA) { - BLI_assert(orig_ibuf->channels == 3 || orig_ibuf->channels == 4); + BLI_assert(ELEM(orig_ibuf->channels, 3, 4)); /* pass */ } else /* if (input_mode == LIBMV_IMAGE_MODE_MONO) */ { diff --git a/source/blender/blenkernel/intern/undo_system.c b/source/blender/blenkernel/intern/undo_system.c index a319c55709d..b687254fd69 100644 --- a/source/blender/blenkernel/intern/undo_system.c +++ b/source/blender/blenkernel/intern/undo_system.c @@ -357,7 +357,7 @@ void BKE_undosys_stack_init_from_main(UndoStack *ustack, struct Main *bmain) void BKE_undosys_stack_init_from_context(UndoStack *ustack, bContext *C) { const UndoType *ut = BKE_undosys_type_from_context(C); - if ((ut != NULL) && (ut != BKE_UNDOSYS_TYPE_MEMFILE)) { + if (!ELEM(ut, NULL, BKE_UNDOSYS_TYPE_MEMFILE)) { BKE_undosys_step_push_with_type(ustack, C, IFACE_("Original Mode"), ut); } } diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index a5418b8b8c5..4d287429558 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -816,7 +816,7 @@ static char *find_next_op(const char *str, char *remaining_str, int len_max) /* Make sure we don't look backwards before the start of the string. */ if (remaining_str != str && i != 0) { /* Check for scientific notation. */ - if (remaining_str[i - 1] == 'e' || remaining_str[i - 1] == 'E') { + if (ELEM(remaining_str[i - 1], 'e', 'E')) { scientific_notation = true; continue; } @@ -1178,7 +1178,7 @@ bool BKE_unit_replace_string( /* Any operators after this? */ for (ch = str_found + 1; *ch != '\0'; ch++) { - if (*ch == ' ' || *ch == '\t') { + if (ELEM(*ch, ' ', '\t')) { continue; } op_found = (ch_is_op(*ch) || ELEM(*ch, ',', ')')); |