Cleanup: use elem macros

This commit is contained in:
Campbell Barton 2021-10-20 10:45:59 +11:00
parent ef9269bd62
commit b280699078
57 changed files with 95 additions and 103 deletions

View File

@ -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. */

View File

@ -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 {};

View File

@ -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,

View File

@ -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(

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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));
}

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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++);

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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];

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -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");

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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)) {

View File

@ -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++;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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) {

View File

@ -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)) {

View File

@ -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);
}

View File

@ -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;
}

View File

@ -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 */

View File

@ -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')) {

View File

@ -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");
}
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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(

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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");

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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(