Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2020-11-06 04:51:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-11-06 04:54:19 +0300
commitf11f7ce08e92463b8a7495ed60082546f228cb60 (patch)
treee48a9811ca300b5115837a12d633f0f1bc4da25b /source
parentd89fedf2667298042ed12a899fb2afe538a69901 (diff)
Cleanup: use ELEM macro (>2 args)
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/fluid.c20
-rw-r--r--source/blender/blenkernel/intern/mball_tessellate.c12
-rw-r--r--source/blender/blenkernel/intern/particle.c32
-rw-r--r--source/blender/blenkernel/intern/particle_system.c9
-rw-r--r--source/blender/blenkernel/intern/text.c2
-rw-r--r--source/blender/blenlib/tests/BLI_delaunay_2d_test.cc2
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp19
-rw-r--r--source/blender/editors/interface/interface_layout.c2
-rw-r--r--source/blender/editors/interface/interface_utils.c2
-rw-r--r--source/blender/editors/sculpt_paint/sculpt.c2
-rw-r--r--source/blender/editors/space_text/text_ops.c4
-rw-r--r--source/blender/gpu/opengl/gl_vertex_array.cc2
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c4
-rw-r--r--source/blender/modifiers/intern/MOD_skin.c4
-rw-r--r--source/blender/python/generic/blf_py_api.c2
-rw-r--r--source/blender/python/mathutils/mathutils_Matrix.c8
16 files changed, 71 insertions, 55 deletions
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index f5bbccb2618..a940a8a97c7 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -4697,9 +4697,11 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
const char data_depth = settings->openvdb_data_depth;
if (settings->type == FLUID_DOMAIN_TYPE_GAS) {
- if (coba_field == FLUID_DOMAIN_FIELD_PHI || coba_field == FLUID_DOMAIN_FIELD_PHI_IN ||
- coba_field == FLUID_DOMAIN_FIELD_PHI_OUT ||
- coba_field == FLUID_DOMAIN_FIELD_PHI_OBSTACLE) {
+ if (ELEM(coba_field,
+ FLUID_DOMAIN_FIELD_PHI,
+ FLUID_DOMAIN_FIELD_PHI_IN,
+ FLUID_DOMAIN_FIELD_PHI_OUT,
+ FLUID_DOMAIN_FIELD_PHI_OBSTACLE)) {
/* Defaulted to density for gas domain. */
settings->coba_field = FLUID_DOMAIN_FIELD_DENSITY;
}
@@ -4710,10 +4712,14 @@ void BKE_fluid_fields_sanitize(FluidDomainSettings *settings)
}
}
else if (settings->type == FLUID_DOMAIN_TYPE_LIQUID) {
- if (coba_field == FLUID_DOMAIN_FIELD_COLOR_R || coba_field == FLUID_DOMAIN_FIELD_COLOR_G ||
- coba_field == FLUID_DOMAIN_FIELD_COLOR_B || coba_field == FLUID_DOMAIN_FIELD_DENSITY ||
- coba_field == FLUID_DOMAIN_FIELD_FLAME || coba_field == FLUID_DOMAIN_FIELD_FUEL ||
- coba_field == FLUID_DOMAIN_FIELD_HEAT) {
+ if (ELEM(coba_field,
+ FLUID_DOMAIN_FIELD_COLOR_R,
+ FLUID_DOMAIN_FIELD_COLOR_G,
+ FLUID_DOMAIN_FIELD_COLOR_B,
+ FLUID_DOMAIN_FIELD_DENSITY,
+ FLUID_DOMAIN_FIELD_FLAME,
+ FLUID_DOMAIN_FIELD_FUEL,
+ FLUID_DOMAIN_FIELD_HEAT)) {
/* Defaulted to phi for liquid domain. */
settings->coba_field = FLUID_DOMAIN_FIELD_PHI;
}
diff --git a/source/blender/blenkernel/intern/mball_tessellate.c b/source/blender/blenkernel/intern/mball_tessellate.c
index 7273d2a920d..cb01927d992 100644
--- a/source/blender/blenkernel/intern/mball_tessellate.c
+++ b/source/blender/blenkernel/intern/mball_tessellate.c
@@ -807,22 +807,22 @@ static void makecubetable(void)
INTLIST *edges;
for (edges = polys->list; edges; edges = edges->next) {
- if (edges->i == LB || edges->i == LT || edges->i == LN || edges->i == LF) {
+ if (ELEM(edges->i, LB, LT, LN, LF)) {
faces[i] |= 1 << L;
}
- if (edges->i == RB || edges->i == RT || edges->i == RN || edges->i == RF) {
+ if (ELEM(edges->i, RB, RT, RN, RF)) {
faces[i] |= 1 << R;
}
- if (edges->i == LB || edges->i == RB || edges->i == BN || edges->i == BF) {
+ if (ELEM(edges->i, LB, RB, BN, BF)) {
faces[i] |= 1 << B;
}
- if (edges->i == LT || edges->i == RT || edges->i == TN || edges->i == TF) {
+ if (ELEM(edges->i, LT, RT, TN, TF)) {
faces[i] |= 1 << T;
}
- if (edges->i == LN || edges->i == RN || edges->i == BN || edges->i == TN) {
+ if (ELEM(edges->i, LN, RN, BN, TN)) {
faces[i] |= 1 << N;
}
- if (edges->i == LF || edges->i == RF || edges->i == BF || edges->i == TF) {
+ if (ELEM(edges->i, LF, RF, BF, TF)) {
faces[i] |= 1 << F;
}
}
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c
index 108a43981a5..abcd0b0e0e4 100644
--- a/source/blender/blenkernel/intern/particle.c
+++ b/source/blender/blenkernel/intern/particle.c
@@ -3997,19 +3997,25 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
if (psys->part->type == PART_FLUID_FLIP) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FLIP;
}
- if (psys->part->type == PART_FLUID_SPRAY || psys->part->type == PART_FLUID_SPRAYFOAM ||
- psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_SPRAY,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_SPRAY;
}
- if (psys->part->type == PART_FLUID_FOAM || psys->part->type == PART_FLUID_SPRAYFOAM ||
- psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_FOAM,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_FOAM;
}
- if (psys->part->type == PART_FLUID_BUBBLE || psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_BUBBLE,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->particle_type &= ~FLUID_DOMAIN_PARTICLE_BUBBLE;
}
if (psys->part->type == PART_FLUID_TRACER) {
@@ -4017,9 +4023,11 @@ void object_remove_particle_system(Main *bmain, Scene *UNUSED(scene), Object *ob
}
/* Disable combined export if combined particle system was deleted. */
- if (psys->part->type == PART_FLUID_SPRAYFOAM || psys->part->type == PART_FLUID_SPRAYBUBBLE ||
- psys->part->type == PART_FLUID_FOAMBUBBLE ||
- psys->part->type == PART_FLUID_SPRAYFOAMBUBBLE) {
+ if (ELEM(psys->part->type,
+ PART_FLUID_SPRAYFOAM,
+ PART_FLUID_SPRAYBUBBLE,
+ PART_FLUID_FOAMBUBBLE,
+ PART_FLUID_SPRAYFOAMBUBBLE)) {
fmd->domain->sndparticle_combined_export = SNDPARTICLE_COMBINED_EXPORT_OFF;
}
}
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index 58264432cdf..91bdfaeae95 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -4151,20 +4151,17 @@ static bool particles_has_tracer(short parttype)
static bool particles_has_spray(short parttype)
{
- return ((parttype == PART_FLUID_SPRAY) || (parttype == PART_FLUID_SPRAYFOAM) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_SPRAY, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
}
static bool particles_has_bubble(short parttype)
{
- return ((parttype == PART_FLUID_BUBBLE) || (parttype == PART_FLUID_FOAMBUBBLE) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_BUBBLE, PART_FLUID_FOAMBUBBLE, PART_FLUID_SPRAYFOAMBUBBLE));
}
static bool particles_has_foam(short parttype)
{
- return ((parttype == PART_FLUID_FOAM) || (parttype == PART_FLUID_SPRAYFOAM) ||
- (parttype == PART_FLUID_SPRAYFOAMBUBBLE));
+ return (ELEM(parttype, PART_FLUID_FOAM, PART_FLUID_SPRAYFOAM, PART_FLUID_SPRAYFOAMBUBBLE));
}
static void particles_fluid_step(ParticleSimulationData *sim,
diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c
index c09d3070da9..6f4ac4c44a0 100644
--- a/source/blender/blenkernel/intern/text.c
+++ b/source/blender/blenkernel/intern/text.c
@@ -2461,7 +2461,7 @@ int text_check_identifier_nodigit_unicode(const unsigned int ch)
bool text_check_whitespace(const char ch)
{
- if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') {
+ if (ELEM(ch, ' ', '\t', '\r', '\n')) {
return true;
}
return false;
diff --git a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
index 14db4254f70..caacbf1a2c4 100644
--- a/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
+++ b/source/blender/blenlib/tests/BLI_delaunay_2d_test.cc
@@ -667,7 +667,7 @@ template<typename T> void crosssegs_test()
if (out.vert.size() == 5) {
int v_intersect = -1;
for (int i = 0; i < 5; i++) {
- if (i != v0_out && i != v1_out && i != v2_out && i != v3_out) {
+ if (!ELEM(i, v0_out, v1_out, v2_out, v3_out)) {
EXPECT_EQ(v_intersect, -1);
v_intersect = i;
}
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index 60676ee42b7..15a52d10071 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -116,12 +116,19 @@
bool Converter::is_fast_node(bNode *b_node)
{
- return !(b_node->type == CMP_NODE_BLUR || b_node->type == CMP_NODE_VECBLUR ||
- b_node->type == CMP_NODE_BILATERALBLUR || b_node->type == CMP_NODE_DEFOCUS ||
- b_node->type == CMP_NODE_BOKEHBLUR || b_node->type == CMP_NODE_GLARE ||
- b_node->type == CMP_NODE_DBLUR || b_node->type == CMP_NODE_MOVIEDISTORTION ||
- b_node->type == CMP_NODE_LENSDIST || b_node->type == CMP_NODE_DOUBLEEDGEMASK ||
- b_node->type == CMP_NODE_DILATEERODE || b_node->type == CMP_NODE_DENOISE);
+ return !ELEM(b_node->type,
+ CMP_NODE_BLUR,
+ CMP_NODE_VECBLUR,
+ CMP_NODE_BILATERALBLUR,
+ CMP_NODE_DEFOCUS,
+ CMP_NODE_BOKEHBLUR,
+ CMP_NODE_GLARE,
+ CMP_NODE_DBLUR,
+ CMP_NODE_MOVIEDISTORTION,
+ CMP_NODE_LENSDIST,
+ CMP_NODE_DOUBLEEDGEMASK,
+ CMP_NODE_DILATEERODE,
+ CMP_NODE_DENOISE);
}
Node *Converter::convert(bNode *b_node)
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 30a73afa94e..df7fd3dee0e 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -2295,7 +2295,7 @@ void uiItemFullR(uiLayout *layout,
ui_item_enum_expand(layout, block, ptr, prop, name, h, icon_only);
}
/* property with separate label */
- else if (type == PROP_ENUM || type == PROP_STRING || type == PROP_POINTER) {
+ else if (ELEM(type, PROP_ENUM, PROP_STRING, PROP_POINTER)) {
but = ui_item_with_label(layout, block, name, icon, ptr, prop, index, 0, 0, w, h, flag);
but = ui_but_add_search(but, ptr, prop, NULL, NULL);
diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c
index 1abde7cf714..958a0bc03cd 100644
--- a/source/blender/editors/interface/interface_utils.c
+++ b/source/blender/editors/interface/interface_utils.c
@@ -792,7 +792,7 @@ void UI_butstore_update(uiBlock *block)
/* warning, loop-in-loop, in practice we only store <10 buttons at a time,
* so this isn't going to be a problem, if that changes old-new mapping can be cached first */
LISTBASE_FOREACH (uiButStore *, bs_handle, &block->butstore) {
- BLI_assert((bs_handle->block == NULL) || (bs_handle->block == block) ||
+ BLI_assert(ELEM(bs_handle->block, NULL, block) ||
(block->oldblock && block->oldblock == bs_handle->block));
if (bs_handle->block == block->oldblock) {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index d2b8c17160c..421a3653d8c 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3922,7 +3922,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata,
if (brush->elastic_deform_type == BRUSH_ELASTIC_DEFORM_TWIST) {
int symm = ss->cache->mirror_symmetry_pass;
- if (symm == 1 || symm == 2 || symm == 4 || symm == 7) {
+ if (ELEM(symm, 1, 2, 4, 7)) {
dir = -dir;
}
}
diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 1814846c76f..52a5ff609d8 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -1897,7 +1897,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *region, const bool sel)
end += max;
chop = 1;
}
- else if (ch == ' ' || ch == '-' || ch == '\0') {
+ else if (ELEM(ch, ' ', '-', '\0')) {
if (j >= oldc) {
*charp = BLI_str_utf8_offset_from_column((*linep)->line, start);
loop = 0;
@@ -3065,7 +3065,7 @@ static void text_cursor_set_to_pos_wrapped(
break;
}
}
- else if (ch == ' ' || ch == '-' || ch == '\0') {
+ else if (ELEM(ch, ' ', '-', '\0')) {
if (found) {
break;
}
diff --git a/source/blender/gpu/opengl/gl_vertex_array.cc b/source/blender/gpu/opengl/gl_vertex_array.cc
index ed6699e51f3..7585a327b3b 100644
--- a/source/blender/gpu/opengl/gl_vertex_array.cc
+++ b/source/blender/gpu/opengl/gl_vertex_array.cc
@@ -76,7 +76,7 @@ static uint16_t vbo_bind(const ShaderInterface *interface,
enabled_attrib |= (1 << input->location);
- if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) {
+ if (ELEM(a->comp_len, 16, 12, 8)) {
BLI_assert(a->fetch_mode == GPU_FETCH_FLOAT);
BLI_assert(a->comp_type == GPU_COMP_F32);
for (int i = 0; i < a->comp_len / 4; i++) {
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 65482430346..b7a15812547 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -277,9 +277,7 @@ LogImageFile *dpxOpen(const unsigned char *byteStuff, int fromMemory, size_t buf
}
dpx->element[i].bitsPerSample = header.imageHeader.element[i].bits_per_sample;
- if (dpx->element[i].bitsPerSample != 1 && dpx->element[i].bitsPerSample != 8 &&
- dpx->element[i].bitsPerSample != 10 && dpx->element[i].bitsPerSample != 12 &&
- dpx->element[i].bitsPerSample != 16) {
+ if (!ELEM(dpx->element[i].bitsPerSample, 1, 8, 10, 12, 16)) {
if (verbose) {
printf("DPX: Unsupported bitsPerSample for elements %d: %d\n",
i,
diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c
index d2fcd1214ba..6936f5a53f8 100644
--- a/source/blender/modifiers/intern/MOD_skin.c
+++ b/source/blender/modifiers/intern/MOD_skin.c
@@ -998,7 +998,7 @@ static void add_poly(SkinOutput *so, BMVert *v1, BMVert *v2, BMVert *v3, BMVert
BMVert *verts[4] = {v1, v2, v3, v4};
BMFace *f;
- BLI_assert(v1 != v2 && v1 != v3 && v1 != v4);
+ BLI_assert(!ELEM(v1, v2, v3, v4));
BLI_assert(!ELEM(v2, v3, v4));
BLI_assert(v3 != v4);
BLI_assert(v1 && v2 && v3);
@@ -1414,7 +1414,7 @@ static void quad_from_tris(BMEdge *e, BMFace *adj[2], BMVert *ndx[4])
/* Find what the second tri has that the first doesn't */
for (i = 0; i < 3; i++) {
- if (tri[1][i] != tri[0][0] && tri[1][i] != tri[0][1] && tri[1][i] != tri[0][2]) {
+ if (!ELEM(tri[1][i], tri[0][0], tri[0][1], tri[0][2])) {
opp = tri[1][i];
break;
}
diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c
index 836f4f1a12c..0ec66e22fa9 100644
--- a/source/blender/python/generic/blf_py_api.c
+++ b/source/blender/python/generic/blf_py_api.c
@@ -373,7 +373,7 @@ static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
return NULL;
}
- if (level != 0 && level != 3 && level != 5) {
+ if (!ELEM(level, 0, 3, 5)) {
PyErr_SetString(PyExc_TypeError, "blf.shadow expected arg to be in (0, 3, 5)");
return NULL;
}
diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c
index 0b9fa1841ec..87d16656d70 100644
--- a/source/blender/python/mathutils/mathutils_Matrix.c
+++ b/source/blender/python/mathutils/mathutils_Matrix.c
@@ -514,7 +514,7 @@ static PyObject *C_Matrix_Rotation(PyObject *cls, PyObject *args)
angle = angle_wrap_rad(angle);
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Rotation(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -653,7 +653,7 @@ static PyObject *C_Matrix_Scale(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "fi|O:Matrix.Scale", &factor, &matSize, &vec)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Scale(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -759,7 +759,7 @@ static PyObject *C_Matrix_OrthoProjection(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "Oi:Matrix.OrthoProjection", &axis, &matSize)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.OrthoProjection(): "
"can only return a 2x2 3x3 or 4x4 matrix");
@@ -895,7 +895,7 @@ static PyObject *C_Matrix_Shear(PyObject *cls, PyObject *args)
if (!PyArg_ParseTuple(args, "siO:Matrix.Shear", &plane, &matSize, &fac)) {
return NULL;
}
- if (matSize != 2 && matSize != 3 && matSize != 4) {
+ if (!ELEM(matSize, 2, 3, 4)) {
PyErr_SetString(PyExc_ValueError,
"Matrix.Shear(): "
"can only return a 2x2 3x3 or 4x4 matrix");