[Bf-blender-cvs] [21462565632] master: Cleanup: use ELEM macro
Campbell Barton
noreply at git.blender.org
Wed Mar 9 00:14:14 CET 2022
Commit: 21462565632b876ac4eadf2bd30573f2fda70c76
Author: Campbell Barton
Date: Wed Mar 9 09:35:37 2022 +1100
Branches: master
https://developer.blender.org/rB21462565632b876ac4eadf2bd30573f2fda70c76
Cleanup: use ELEM macro
===================================================================
M source/blender/blenkernel/intern/fluid.c
M source/blender/blenkernel/intern/gpencil_modifier.c
M source/blender/blenkernel/intern/idprop.c
M source/blender/blenkernel/intern/image_gpu.cc
M source/blender/blenkernel/intern/mask.c
M source/blender/blenkernel/intern/node.cc
M source/blender/blenkernel/intern/pointcache.c
M source/blender/blenkernel/intern/spline_bezier.cc
M source/blender/blenkernel/intern/tracking.c
M source/blender/blenkernel/intern/writeffmpeg.c
M source/blender/blenlib/intern/path_util.c
M source/blender/editors/interface/interface_handlers.c
M source/blender/editors/space_file/filelist.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_text/text_draw.c
M source/blender/editors/transform/transform_convert_mesh.c
M source/blender/editors/uvedit/uvedit_parametrizer.c
M source/blender/editors/uvedit/uvedit_select.c
M source/blender/gpu/intern/gpu_vertex_format.cc
M source/blender/imbuf/intern/dds/DirectDrawSurface.cpp
M source/blender/makesrna/intern/makesrna.c
M source/blender/makesrna/intern/rna_camera.c
M source/blender/makesrna/intern/rna_define.c
M source/blender/makesrna/intern/rna_dynamicpaint.c
M source/blender/makesrna/intern/rna_particle.c
M source/blender/makesrna/intern/rna_rna.c
M source/blender/makesrna/intern/rna_scene.c
M source/blender/makesrna/intern/rna_ui.c
M source/blender/makesrna/intern/rna_xr.c
M source/blender/windowmanager/intern/wm_event_system.c
M source/blender/windowmanager/xr/intern/wm_xr_operators.c
M source/creator/creator_args.c
===================================================================
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 6f2760e91a6..f85361e94ff 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1845,8 +1845,8 @@ static void sample_mesh(FluidFlowSettings *ffs,
const float surface_distance = 1.732;
nearest.dist_sq = surface_distance * surface_distance; /* find_nearest uses squared distance. */
- bool is_gas_flow = (ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_FIRE ||
- ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE);
+ bool is_gas_flow = ELEM(
+ ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_FIRE, FLUID_FLOW_TYPE_SMOKEFIRE);
/* Emission strength for gases will be computed below.
* For liquids it's not needed. Just set to non zero value
@@ -2035,8 +2035,7 @@ static void emit_from_mesh_task_cb(void *__restrict userdata,
/* Compute emission only for flow objects that produce fluid (i.e. skip outflow objects).
* Result in bb->influence. Also computes initial velocities. Result in bb->velocity. */
- if ((data->ffs->behavior == FLUID_FLOW_BEHAVIOR_GEOMETRY) ||
- (data->ffs->behavior == FLUID_FLOW_BEHAVIOR_INFLOW)) {
+ if (ELEM(data->ffs->behavior, FLUID_FLOW_BEHAVIOR_GEOMETRY, FLUID_FLOW_BEHAVIOR_INFLOW)) {
sample_mesh(data->ffs,
data->mvert,
data->vert_normals,
@@ -2697,8 +2696,8 @@ static bool escape_flowsobject(Object *flowobj,
bool is_static = is_static_object(flowobj);
bool liquid_flow = ffs->type == FLUID_FLOW_TYPE_LIQUID;
- bool gas_flow = (ffs->type == FLUID_FLOW_TYPE_SMOKE || ffs->type == FLUID_FLOW_TYPE_FIRE ||
- ffs->type == FLUID_FLOW_TYPE_SMOKEFIRE);
+ bool gas_flow = ELEM(
+ ffs->type, FLUID_FLOW_TYPE_SMOKE, FLUID_FLOW_TYPE_FIRE, FLUID_FLOW_TYPE_SMOKEFIRE);
bool is_geometry = (ffs->behavior == FLUID_FLOW_BEHAVIOR_GEOMETRY);
bool liquid_domain = fds->type == FLUID_DOMAIN_TYPE_LIQUID;
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c
index ffc1f2d8774..9c546cc118a 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -196,9 +196,11 @@ bool BKE_gpencil_has_transform_modifiers(Object *ob)
LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
/* Only if enabled in edit mode. */
if (!GPENCIL_MODIFIER_EDIT(md, true) && GPENCIL_MODIFIER_ACTIVE(md, false)) {
- if ((md->type == eGpencilModifierType_Armature) || (md->type == eGpencilModifierType_Hook) ||
- (md->type == eGpencilModifierType_Lattice) ||
- (md->type == eGpencilModifierType_Offset)) {
+ if (ELEM(md->type,
+ eGpencilModifierType_Armature,
+ eGpencilModifierType_Hook,
+ eGpencilModifierType_Lattice,
+ eGpencilModifierType_Offset)) {
return true;
}
}
diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c
index d00fc8814e0..7b8dfdc690c 100644
--- a/source/blender/blenkernel/intern/idprop.c
+++ b/source/blender/blenkernel/intern/idprop.c
@@ -903,8 +903,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char *
break;
case IDP_ARRAY: {
/* for now, we only support float and int and double arrays */
- if ((val->array.type == IDP_FLOAT) || (val->array.type == IDP_INT) ||
- (val->array.type == IDP_DOUBLE) || (val->array.type == IDP_GROUP)) {
+ if (ELEM(val->array.type, IDP_FLOAT, IDP_INT, IDP_DOUBLE, IDP_GROUP)) {
prop = MEM_callocN(sizeof(IDProperty), "IDProperty array");
prop->subtype = val->array.type;
if (val->array.len) {
diff --git a/source/blender/blenkernel/intern/image_gpu.cc b/source/blender/blenkernel/intern/image_gpu.cc
index c4a43d8b023..0d470c5b663 100644
--- a/source/blender/blenkernel/intern/image_gpu.cc
+++ b/source/blender/blenkernel/intern/image_gpu.cc
@@ -280,7 +280,7 @@ static GPUTexture **get_image_gpu_texture_ptr(Image *ima,
{
const bool in_range = (textarget >= 0) && (textarget < TEXTARGET_COUNT);
BLI_assert(in_range);
- BLI_assert(multiview_eye == 0 || multiview_eye == 1);
+ BLI_assert(ELEM(multiview_eye, 0, 1));
const int resolution = (texture_resolution == IMA_TEXTURE_RESOLUTION_LIMITED) ? 1 : 0;
if (in_range) {
diff --git a/source/blender/blenkernel/intern/mask.c b/source/blender/blenkernel/intern/mask.c
index fca7c10ca77..da0f899001c 100644
--- a/source/blender/blenkernel/intern/mask.c
+++ b/source/blender/blenkernel/intern/mask.c
@@ -1374,7 +1374,7 @@ static void mask_calc_point_handle(MaskSplinePoint *point,
else if (handle_type == HD_AUTO) {
BKE_nurb_handle_calc(bezt, bezt_prev, bezt_next, 0, 0);
}
- else if (handle_type == HD_ALIGN || handle_type == HD_ALIGN_DOUBLESIDE) {
+ else if (ELEM(handle_type, HD_ALIGN, HD_ALIGN_DOUBLESIDE)) {
float v1[3], v2[3];
float vec[3], h[3];
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index 1c0eb0ecd44..29770ea5475 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -553,7 +553,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
BKE_curvemapping_blend_write(writer, (const CurveMapping *)node->storage);
}
else if ((ntree->type == NTREE_TEXTURE) &&
- (node->type == TEX_NODE_CURVE_RGB || node->type == TEX_NODE_CURVE_TIME)) {
+ ELEM(node->type, TEX_NODE_CURVE_RGB, TEX_NODE_CURVE_TIME)) {
BKE_curvemapping_blend_write(writer, (const CurveMapping *)node->storage);
}
else if ((ntree->type == NTREE_COMPOSIT) && (node->type == CMP_NODE_MOVIEDISTORTION)) {
@@ -579,7 +579,7 @@ void ntreeBlendWrite(BlendWriter *writer, bNodeTree *ntree)
BLO_write_struct_by_name(writer, node->typeinfo->storagename, node->storage);
}
else if ((ntree->type == NTREE_COMPOSIT) &&
- (ELEM(node->type, CMP_NODE_CRYPTOMATTE, CMP_NODE_CRYPTOMATTE_LEGACY))) {
+ ELEM(node->type, CMP_NODE_CRYPTOMATTE, CMP_NODE_CRYPTOMATTE_LEGACY)) {
NodeCryptomatte *nc = (NodeCryptomatte *)node->storage;
BLO_write_string(writer, nc->matte_id);
LISTBASE_FOREACH (CryptomatteEntry *, entry, &nc->entries) {
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index 859e3499cc4..19abff19b77 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -683,8 +683,7 @@ static int ptcache_dynamicpaint_write(PTCacheFile *pf, void *dp_v)
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
in_len = sizeof(PaintPoint) * total_points;
}
- 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)) {
in_len = sizeof(float) * total_points;
}
else if (surface->type == MOD_DPAINT_SURFACE_T_WAVE) {
diff --git a/source/blender/blenkernel/intern/spline_bezier.cc b/source/blender/blenkernel/intern/spline_bezier.cc
index 3c2ac1dae9c..e9ae51b16f8 100644
--- a/source/blender/blenkernel/intern/spline_bezier.cc
+++ b/source/blender/blenkernel/intern/spline_bezier.cc
@@ -365,7 +365,7 @@ BezierSpline::InsertResult BezierSpline::calculate_segment_insertion(const int i
using namespace blender::math;
BLI_assert(parameter <= 1.0f && parameter >= 0.0f);
- BLI_assert(next_index == 0 || next_index == index + 1);
+ BLI_assert(ELEM(next_index, 0, index + 1));
const float3 &point_prev = positions_[index];
const float3 &handle_prev = handle_positions_right_[index];
const float3 &handle_next = handle_positions_left_[next_index];
diff --git a/source/blender/blenkernel/intern/tracking.c b/source/blender/blenkernel/intern/tracking.c
index 5708d3eeaec..2a415b8f6fb 100644
--- a/source/blender/blenkernel/intern/tracking.c
+++ b/source/blender/blenkernel/intern/tracking.c
@@ -1473,7 +1473,7 @@ static const MovieTrackingMarker *get_usable_marker_for_interpolation(
const MovieTrackingMarker *anchor_marker,
const int direction)
{
- BLI_assert(direction == -1 || direction == 1);
+ BLI_assert(ELEM(direction, -1, 1));
const MovieTrackingMarker *last_marker = track->markers + track->markersnr - 1;
const MovieTrackingMarker *current_marker = anchor_marker;
diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c
index b9d013d4756..5e11cd0703a 100644
--- a/source/blender/blenkernel/intern/writeffmpeg.c
+++ b/source/blender/blenkernel/intern/writeffmpeg.c
@@ -622,8 +622,7 @@ static AVStream *alloc_video_stream(FFMpegContext *context,
if (codec_id == AV_CODEC_ID_VP9 && rd->im_format.planes == R_IMF_PLANES_RGBA) {
c->pix_fmt = AV_PIX_FMT_YUVA420P;
}
- else if ((codec_id == AV_CODEC_ID_H264 || codec_id == AV_CODEC_ID_VP9) &&
- context->ffmpeg_crf == 0) {
+ else if (ELEM(codec_id, AV_CODEC_ID_H264, AV_CODEC_ID_VP9) && (context->ffmpeg_crf == 0)) {
/* Use 4:4:4 instead of 4:2:0 pixel format for lossless rendering. */
c->pix_fmt = AV_PIX_FMT_YUV444P;
}
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index a6f09d074e7..f94d49cf1dd 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -470,7 +470,7 @@ void BLI_path_rel(char *file, const char *relfile)
* can happen with old recent-files.txt files */
BLI_windows_get_default_root_dir(temp);
ptemp = &temp[2];
- if (relfile[0] != '\\' && relfile[0] != '/') {
+ if (!ELEM(relfile[0], '\\', '/')) {
ptemp++;
}
BLI_strncpy(ptemp, relfile, FILE_MAX - 3);
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index f5fa710067b..2386b388a41 100644
--- a/
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list