diff --git a/intern/mantaflow/intern/MANTA_main.cpp b/intern/mantaflow/intern/MANTA_main.cpp index b9552c82335..66e27310d3e 100644 --- a/intern/mantaflow/intern/MANTA_main.cpp +++ b/intern/mantaflow/intern/MANTA_main.cpp @@ -6,6 +6,7 @@ * \ingroup intern_mantaflow */ +#include #include #include #include @@ -830,7 +831,7 @@ void MANTA::initializeRNAMap(FluidModifierData *fmd) string cacheDirectory(fds->cache_directory); float viscosity = fds->viscosity_base * pow(10.0f, -fds->viscosity_exponent); - float domainSize = MAX3(fds->global_size[0], fds->global_size[1], fds->global_size[2]); + float domainSize = std::max({fds->global_size[0], fds->global_size[1], fds->global_size[2]}); string vdbCompressionMethod = "Compression_None"; if (fds->openvdb_compression == VDB_COMPRESSION_NONE) { diff --git a/source/blender/blenfont/intern/blf_thumbs.cc b/source/blender/blenfont/intern/blf_thumbs.cc index de7534a557e..132e74c907c 100644 --- a/source/blender/blenfont/intern/blf_thumbs.cc +++ b/source/blender/blenfont/intern/blf_thumbs.cc @@ -10,6 +10,7 @@ * Isolate since this needs to be called by #ImBuf code (bad level call). */ +#include #include #include @@ -368,9 +369,9 @@ bool BLF_thumb_preview(const char *filename, uchar *buf, int w, int h, int /*cha width = std::max(width, height); /* Fill up to 96% horizontally or vertically. */ - float font_size = MIN3(float(w), - (float(w) * 0.96f / float(width) * float(w)), - float(h) * 0.96f / float(height) * float(h)); + float font_size = std::min({float(w), + (float(w) * 0.96f / float(width) * float(w)), + float(h) * 0.96f / float(height) * float(h)}); if (font_size < 1 || FT_Set_Char_Size(face, int(font_size * 64.0f), 0, 72, 72) != FT_Err_Ok) { /* Sizing can fail, but very rarely. */ diff --git a/source/blender/blenkernel/BKE_cryptomatte.hh b/source/blender/blenkernel/BKE_cryptomatte.hh index 6435b87df64..c663d97f7f8 100644 --- a/source/blender/blenkernel/BKE_cryptomatte.hh +++ b/source/blender/blenkernel/BKE_cryptomatte.hh @@ -8,6 +8,7 @@ #pragma once +#include #include #include @@ -80,8 +81,8 @@ struct CryptomatteHash { { uint32_t mantissa = hash & ((1 << 23) - 1); uint32_t exponent = (hash >> 23) & ((1 << 8) - 1); - exponent = MAX2(exponent, uint32_t(1)); - exponent = MIN2(exponent, uint32_t(254)); + exponent = std::max(exponent, uint32_t(1)); + exponent = std::min(exponent, uint32_t(254)); exponent = exponent << 23; uint32_t sign = (hash >> 31); sign = sign << 31; diff --git a/source/blender/blenkernel/intern/blendfile_link_append.cc b/source/blender/blenkernel/intern/blendfile_link_append.cc index 8f7056bbc3a..c33ffd11679 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.cc +++ b/source/blender/blenkernel/intern/blendfile_link_append.cc @@ -10,6 +10,7 @@ * collections/objects/object-data in current scene. */ +#include #include #include @@ -1656,7 +1657,7 @@ static void blendfile_library_relocate_remap(Main *bmain, old_id->name[dot_pos] = '~'; } else { - len = MIN2(len, MAX_ID_NAME - 7); + len = std::min(len, MAX_ID_NAME - 7); BLI_strncpy(&old_id->name[len], "~000", 7); } diff --git a/source/blender/blenkernel/intern/boids.cc b/source/blender/blenkernel/intern/boids.cc index 67d9c447da6..c3157334d5a 100644 --- a/source/blender/blenkernel/intern/boids.cc +++ b/source/blender/blenkernel/intern/boids.cc @@ -1181,7 +1181,7 @@ void boid_brain(BoidBrainData *bbd, int p, ParticleData *pa) if (len < val.jump_speed * mul || bbd->part->boids->options & BOID_ALLOW_FLIGHT) { jump = 1; - len = MIN2(len, val.jump_speed); + len = std::min(len, val.jump_speed); copy_v3_v3(jump_v, dir); jump_v[2] = z_v; @@ -1320,7 +1320,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) old_speed = len_v3(pa->prev_state.vel); if (bbd->wanted_speed < old_speed) { - new_speed = MAX2(bbd->wanted_speed, old_speed - val.max_acc); + new_speed = std::max(bbd->wanted_speed, old_speed - val.max_acc); } else { new_speed = std::min(bbd->wanted_speed, old_speed + val.max_acc); @@ -1346,7 +1346,7 @@ void boid_body(BoidBrainData *bbd, ParticleData *pa) /* finally constrain speed to max speed */ new_speed = normalize_v3(new_vel); - mul_v3_fl(new_vel, MIN2(new_speed, val.max_speed)); + mul_v3_fl(new_vel, std::min(new_speed, val.max_speed)); /* get acceleration from difference of velocities */ sub_v3_v3v3(acc, new_vel, pa->prev_state.vel); diff --git a/source/blender/blenkernel/intern/collision.cc b/source/blender/blenkernel/intern/collision.cc index 82859fcab72..6377fcd8bc3 100644 --- a/source/blender/blenkernel/intern/collision.cc +++ b/source/blender/blenkernel/intern/collision.cc @@ -6,6 +6,8 @@ * \ingroup bke */ +#include + #include "MEM_guardedalloc.h" #include "DNA_cloth_types.h" @@ -896,7 +898,7 @@ static int cloth_selfcollision_response_static(ClothModifierData *clmd, VECADDMUL(ib[2], collpair->normal, double(u3) * -impulse); if ((magrelVel < 0.1f * d * time_multiplier) && (d > ALMOST_ZERO)) { - repulse = MIN2(d / time_multiplier, 0.1f * d * time_multiplier - magrelVel); + repulse = std::min(d / time_multiplier, 0.1f * d * time_multiplier - magrelVel); if (impulse > ALMOST_ZERO) { repulse = min_ff(repulse, 5.0 * impulse); @@ -1720,7 +1722,7 @@ int cloth_bvh_collision( BKE_collision_objects_free(collobjs); - return MIN2(ret, 1); + return std::min(ret, 1); } BLI_INLINE void max_v3_v3v3(float r[3], const float a[3], const float b[3]) diff --git a/source/blender/blenkernel/intern/effect.cc b/source/blender/blenkernel/intern/effect.cc index 223877a410e..9dede98ec28 100644 --- a/source/blender/blenkernel/intern/effect.cc +++ b/source/blender/blenkernel/intern/effect.cc @@ -6,10 +6,10 @@ * \ingroup bke */ +#include +#include #include #include - -#include #include #include "MEM_guardedalloc.h" @@ -1075,8 +1075,8 @@ static void do_physical_effector(EffectorCache *eff, copy_v3_v3(force, point->vel); fac = normalize_v3(force) * point->vel_to_sec; - strength = MIN2(strength, 2.0f); - damp = MIN2(damp, 2.0f); + strength = std::min(strength, 2.0f); + damp = std::min(damp, 2.0f); mul_v3_fl(force, -efd->falloff * fac * (strength * fac + damp)); break; diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index 8a32fa5d205..28913e7349c 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -442,7 +442,7 @@ static void manta_set_domain_from_mesh(FluidDomainSettings *fds, } /* Define grid resolutions from longest domain side. */ - if (size[0] >= MAX2(size[1], size[2])) { + if (size[0] >= std::max(size[1], size[2])) { scale = res / size[0]; fds->scale = size[0] / fabsf(ob->scale[0]); fds->base_res[0] = res; @@ -793,8 +793,8 @@ static void bb_combineMaps(FluidObjectBB *output, output->influence[index_out]); } } - output->distances[index_out] = MIN2(bb2->distances[index_in], - output->distances[index_out]); + output->distances[index_out] = std::min(bb2->distances[index_in], + output->distances[index_out]); if (output->velocity && bb2->velocity) { /* Last sample replaces the velocity. */ output->velocity[index_out * 3] = ADD_IF_LOWER(output->velocity[index_out * 3], @@ -832,7 +832,7 @@ BLI_INLINE void apply_effector_fields(FluidEffectorSettings * /*fes*/, { /* Ensure that distance value is "joined" into the levelset. */ if (dest_phi_in) { - dest_phi_in[index] = MIN2(src_distance_value, dest_phi_in[index]); + dest_phi_in[index] = std::min(src_distance_value, dest_phi_in[index]); } /* Accumulate effector object count (important once effector object overlap). */ @@ -914,15 +914,15 @@ static void update_velocities(FluidEffectorSettings *fes, velocity_map[index * 3 + 2] = hit_vel[2]; break; case FLUID_EFFECTOR_GUIDE_MIN: - velocity_map[index * 3] = MIN2(abs_hit_vel[0], abs_vel[0]); - velocity_map[index * 3 + 1] = MIN2(abs_hit_vel[1], abs_vel[1]); - velocity_map[index * 3 + 2] = MIN2(abs_hit_vel[2], abs_vel[2]); + velocity_map[index * 3] = std::min(abs_hit_vel[0], abs_vel[0]); + velocity_map[index * 3 + 1] = std::min(abs_hit_vel[1], abs_vel[1]); + velocity_map[index * 3 + 2] = std::min(abs_hit_vel[2], abs_vel[2]); break; case FLUID_EFFECTOR_GUIDE_MAX: default: - velocity_map[index * 3] = MAX2(abs_hit_vel[0], abs_vel[0]); - velocity_map[index * 3 + 1] = MAX2(abs_hit_vel[1], abs_vel[1]); - velocity_map[index * 3 + 2] = MAX2(abs_hit_vel[2], abs_vel[2]); + velocity_map[index * 3] = std::max(abs_hit_vel[0], abs_vel[0]); + velocity_map[index * 3 + 1] = std::max(abs_hit_vel[1], abs_vel[1]); + velocity_map[index * 3 + 2] = std::max(abs_hit_vel[2], abs_vel[2]); break; } } @@ -1792,7 +1792,7 @@ static void update_distances(int index, } /* Update global distance array but ensure that older entries are not overridden. */ - distance_map[index] = MIN2(distance_map[index], min_dist); + distance_map[index] = std::min(distance_map[index], min_dist); /* Sanity check: Ensure that distances don't explode. */ CLAMP(distance_map[index], -PHI_MAX, PHI_MAX); @@ -1973,8 +1973,8 @@ static void sample_mesh(FluidFlowSettings *ffs, float convert_vel[3]; copy_v3_v3(convert_vel, ffs->vel_coord); float time_mult = 1.0 / (25.0f * DT_DEFAULT); - float size_mult = MAX3(base_res[0], base_res[1], base_res[2]) / - MAX3(global_size[0], global_size[1], global_size[2]); + float size_mult = std::max({base_res[0], base_res[1], base_res[2]}) / + std::max({global_size[0], global_size[1], global_size[2]}); mul_v3_v3fl(convert_vel, ffs->vel_coord, size_mult * time_mult); velocity_map[index * 3] += convert_vel[0]; @@ -1990,7 +1990,7 @@ static void sample_mesh(FluidFlowSettings *ffs, } /* Apply final influence value but also consider volume initialization factor. */ - influence_map[index] = MAX2(volume_factor, emission_strength); + influence_map[index] = std::max(volume_factor, emission_strength); } struct EmitFromDMData { @@ -2269,7 +2269,7 @@ static void adaptive_domain_adjust( y - fds->res_min[1], fds->res[1], z - fds->res_min[2]); - max_den = (fuel) ? MAX2(density[index], fuel[index]) : density[index]; + max_den = (fuel) ? std::max(density[index], fuel[index]) : density[index]; /* Check high resolution bounds if max density isn't already high enough. */ if (max_den < fds->adapt_threshold && fds->flags & FLUID_DOMAIN_USE_NOISE && fds->fluid) { @@ -2283,7 +2283,7 @@ static void adaptive_domain_adjust( for (j = 0; j < block_size; j++) { for (k = 0; k < block_size; k++) { int big_index = manta_get_index(xx + i, wt_res[0], yy + j, wt_res[1], zz + k); - float den = (bigfuel) ? MAX2(bigdensity[big_index], bigfuel[big_index]) : + float den = (bigfuel) ? std::max(bigdensity[big_index], bigfuel[big_index]) : bigdensity[big_index]; if (den > max_den) { max_den = den; @@ -2433,7 +2433,7 @@ BLI_INLINE void apply_outflow_fields(int index, /* Set levelset value for liquid inflow. * Ensure that distance value is "joined" into the levelset. */ if (phiout) { - phiout[index] = MIN2(distance_value, phiout[index]); + phiout[index] = std::min(distance_value, phiout[index]); } /* Set smoke outflow, i.e. reset cell to zero. */ @@ -2478,7 +2478,7 @@ BLI_INLINE void apply_inflow_fields(FluidFlowSettings *ffs, /* Set levelset value for liquid inflow. * Ensure that distance value is "joined" into the levelset. */ if (phi_in) { - phi_in[index] = MIN2(distance_value, phi_in[index]); + phi_in[index] = std::min(distance_value, phi_in[index]); } /* Set emission value for smoke inflow. @@ -2504,13 +2504,13 @@ BLI_INLINE void apply_inflow_fields(FluidFlowSettings *ffs, if (absolute_flow) { if (density && density_in) { if (ffs->type != FLUID_FLOW_TYPE_FIRE && dens_flow > density[index]) { - /* Use MAX2 to preserve values from other emitters at this cell. */ + /* Use std::max to preserve values from other emitters at this cell. */ density_in[index] = std::max(dens_flow, density_in[index]); } } if (fuel && fuel_in) { if (ffs->type != FLUID_FLOW_TYPE_SMOKE && fuel_flow && fuel_flow > fuel[index]) { - /* Use MAX2 to preserve values from other emitters at this cell. */ + /* Use std::max to preserve values from other emitters at this cell. */ fuel_in[index] = std::max(fuel_flow, fuel_in[index]); } } @@ -3130,7 +3130,7 @@ static void update_effectors_task_cb(void *__restrict userdata, float voxel_center[3] = {0, 0, 0}, vel[3] = {0, 0, 0}, retvel[3] = {0, 0, 0}; const uint index = manta_get_index(x, fds->res[0], y, fds->res[1], z); - if ((data->fuel && MAX2(data->density[index], data->fuel[index]) < FLT_EPSILON) || + if ((data->fuel && std::max(data->density[index], data->fuel[index]) < FLT_EPSILON) || (data->density && data->density[index] < FLT_EPSILON) || (data->phi_obs_in && data->phi_obs_in[index] < 0.0f) || data->flags[index] & 2) /* Manta-flow convention: `2 == FlagObstacle`. */ @@ -3276,7 +3276,7 @@ static Mesh *create_liquid_geometry(FluidDomainSettings *fds, sub_v3_v3v3(size, max, min); /* Biggest dimension will be used for up-scaling. */ - float max_size = MAX3(size[0], size[1], size[2]); + float max_size = std::max({size[0], size[1], size[2]}); float co_scale[3]; co_scale[0] = max_size / ob->scale[0]; @@ -4379,8 +4379,8 @@ float BKE_fluid_get_velocity_at(Object *ob, float position[3], float velocity[3] if (fmd && (fmd->type & MOD_FLUID_TYPE_DOMAIN) && fmd->domain && fmd->domain->fluid) { FluidDomainSettings *fds = fmd->domain; float time_mult = 25.0f * DT_DEFAULT; - float size_mult = MAX3(fds->global_size[0], fds->global_size[1], fds->global_size[2]) / - MAX3(fds->base_res[0], fds->base_res[1], fds->base_res[2]); + float size_mult = std::max({fds->global_size[0], fds->global_size[1], fds->global_size[2]}) / + std::max({fds->base_res[0], fds->base_res[1], fds->base_res[2]}); float vel_mag; float density = 0.0f, fuel = 0.0f; float pos[3]; diff --git a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc index 3a1d2a606c9..9468b8fe4e9 100644 --- a/source/blender/blenkernel/intern/gpencil_geom_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_geom_legacy.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include #include #include #include @@ -1662,7 +1663,7 @@ float BKE_gpencil_stroke_segment_length(const bGPDstroke *gps, return 0.0f; } - int index = MAX2(start_index, 0) + 1; + int index = std::max(start_index, 0) + 1; int last_index = std::min(end_index, gps->totpoints - 1) + 1; float *last_pt = &gps->points[index - 1].x; @@ -1804,7 +1805,7 @@ bool BKE_gpencil_stroke_close(bGPDstroke *gps) } /* Calc number of points required using the average distance. */ - int tot_newpoints = MAX2(dist_close / dist_avg, 1); + int tot_newpoints = std::max(dist_close / dist_avg, 1); /* Resize stroke array. */ int old_tot = gps->totpoints; @@ -2531,7 +2532,7 @@ static void gpencil_generate_edgeloops(Object *ob, /* Create Stroke. */ bGPDstroke *gps_stroke = BKE_gpencil_stroke_add( - gpf_stroke, MAX2(stroke_mat_index, 0), array_len + 1, thickness * thickness, false); + gpf_stroke, std::max(stroke_mat_index, 0), array_len + 1, thickness * thickness, false); /* Create dvert data. */ if (use_vgroups && !dverts.is_empty()) { @@ -3710,7 +3711,7 @@ void BKE_gpencil_stroke_uniform_subdivide(bGPdata *gpd, (float *)&sp_next->vertex_color, 0.5f); if (sp->dw && sp_next->dw) { - new_sp->totweight = MIN2(sp->totweight, sp_next->totweight); + new_sp->totweight = std::min(sp->totweight, sp_next->totweight); new_sp->dw = (MDeformWeight *)MEM_callocN(sizeof(MDeformWeight) * new_sp->totweight, __func__); for (uint32_t i = 0; i < new_sp->totweight; ++i) { diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc b/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc index ca37a21f631..d3c31ec83ea 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include #include #include "MEM_guardedalloc.h" @@ -227,12 +228,13 @@ GpencilLineartLimitInfo BKE_gpencil_get_lineart_modifier_limits(const Object *ob if (md->type == eGpencilModifierType_Lineart) { LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md; if (is_first || (lmd->flags & LRT_GPENCIL_USE_CACHE)) { - info.min_level = MIN2(info.min_level, lmd->level_start); - info.max_level = MAX2(info.max_level, - (lmd->use_multiple_levels ? lmd->level_end : lmd->level_start)); + info.min_level = std::min(info.min_level, lmd->level_start); + info.max_level = std::max( + info.max_level, (lmd->use_multiple_levels ? lmd->level_end : lmd->level_start)); info.edge_types |= lmd->edge_types; - info.shadow_selection = MAX2(lmd->shadow_selection, info.shadow_selection); - info.silhouette_selection = MAX2(lmd->silhouette_selection, info.silhouette_selection); + info.shadow_selection = std::max(lmd->shadow_selection, info.shadow_selection); + info.silhouette_selection = std::max(lmd->silhouette_selection, + info.silhouette_selection); is_first = false; } } diff --git a/source/blender/blenkernel/intern/idprop_utils.cc b/source/blender/blenkernel/intern/idprop_utils.cc index 05a37e46570..c25e253d123 100644 --- a/source/blender/blenkernel/intern/idprop_utils.cc +++ b/source/blender/blenkernel/intern/idprop_utils.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include #include #include @@ -96,7 +97,7 @@ static void idp_repr_fn_recursive(ReprState *state, const IDProperty *prop) switch (prop->type) { case IDP_STRING: { - STR_APPEND_STR_LEN_QUOTE(IDP_String(prop), uint(MAX2(0, prop->len - 1))); + STR_APPEND_STR_LEN_QUOTE(IDP_String(prop), uint(std::max(0, prop->len - 1))); break; } case IDP_INT: { diff --git a/source/blender/blenkernel/intern/mask_evaluate.cc b/source/blender/blenkernel/intern/mask_evaluate.cc index a7fedbe7504..28bfe9e841e 100644 --- a/source/blender/blenkernel/intern/mask_evaluate.cc +++ b/source/blender/blenkernel/intern/mask_evaluate.cc @@ -388,7 +388,7 @@ void BKE_mask_spline_feather_collapse_inner_loops(MaskSpline *spline, max_delta_x /= max[0] - min[0]; max_delta_y /= max[1] - min[1]; - max_delta = MAX2(max_delta_x, max_delta_y); + max_delta = std::max(max_delta_x, max_delta_y); buckets_per_side = min_ii(512, 0.9f / max_delta); diff --git a/source/blender/blenkernel/intern/multires.cc b/source/blender/blenkernel/intern/multires.cc index 0a70a5c1426..4f112b8f8ca 100644 --- a/source/blender/blenkernel/intern/multires.cc +++ b/source/blender/blenkernel/intern/multires.cc @@ -358,11 +358,11 @@ void multires_set_tot_level(Object *ob, MultiresModifierData *mmd, int lvl) mmd->totlvl = lvl; if (ob->mode != OB_MODE_SCULPT) { - mmd->lvl = CLAMPIS(MAX2(mmd->lvl, lvl), 0, mmd->totlvl); + mmd->lvl = CLAMPIS(std::max(mmd->lvl, lvl), 0, mmd->totlvl); } - mmd->sculptlvl = CLAMPIS(MAX2(mmd->sculptlvl, lvl), 0, mmd->totlvl); - mmd->renderlvl = CLAMPIS(MAX2(mmd->renderlvl, lvl), 0, mmd->totlvl); + mmd->sculptlvl = CLAMPIS(std::max(mmd->sculptlvl, lvl), 0, mmd->totlvl); + mmd->renderlvl = CLAMPIS(std::max(mmd->renderlvl, lvl), 0, mmd->totlvl); } static void multires_ccg_mark_as_modified(SubdivCCG *subdiv_ccg, MultiresModifiedFlags flags) diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index 95dd3800627..7865e9f4fd0 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -9,6 +9,7 @@ /* Allow using deprecated functionality for .blend file I/O. */ #define DNA_DEPRECATED_ALLOW +#include #include #include #include @@ -2718,7 +2719,7 @@ static bool psys_thread_context_init_path(ParticleThreadContext *ctx, totchild = int(float(totchild) * float(part->disp) / 100.0f); } - totparent = MIN2(totparent, totchild); + totparent = std::min(totparent, totchild); if (totchild == 0) { return false; @@ -3356,7 +3357,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra, const bool use_re copy_v3_v3(rotmat[2], hairmat[0]); if (part->draw & PART_ABS_PATH_TIME) { - birthtime = MAX2(pind.birthtime, part->path_start); + birthtime = std::max(pind.birthtime, part->path_start); dietime = std::min(pind.dietime, part->path_end); } else { diff --git a/source/blender/blenkernel/intern/particle_distribute.cc b/source/blender/blenkernel/intern/particle_distribute.cc index abe5ad28cae..2834d4f5246 100644 --- a/source/blender/blenkernel/intern/particle_distribute.cc +++ b/source/blender/blenkernel/intern/particle_distribute.cc @@ -127,7 +127,7 @@ static void distribute_grid(Mesh *mesh, ParticleSystem *psys) size[(axis + 2) % 3] = int(ceil(delta[(axis + 2) % 3] / d)); /* float errors grrr. */ - size[(axis + 1) % 3] = MIN2(size[(axis + 1) % 3], res); + size[(axis + 1) % 3] = std::min(size[(axis + 1) % 3], res); size[(axis + 2) % 3] = std::min(size[(axis + 2) % 3], res); size[0] = std::max(size[0], 1); @@ -1122,7 +1122,7 @@ static int psys_thread_context_init_distribute(ParticleThreadContext *ctx, maxweight /= totarea; } else { - float min = 1.0f / float(MIN2(totelem, totpart)); + float min = 1.0f / float(std::min(totelem, totpart)); for (i = 0; i < totelem; i++) { element_weight[i] = min; } diff --git a/source/blender/blenkernel/intern/particle_system.cc b/source/blender/blenkernel/intern/particle_system.cc index f690b9cd920..e2f6dbfc933 100644 --- a/source/blender/blenkernel/intern/particle_system.cc +++ b/source/blender/blenkernel/intern/particle_system.cc @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -232,7 +233,7 @@ static void realloc_particles(ParticleSimulationData *sim, int new_totpart) } if (psys->particles) { - totsaved = MIN2(psys->totpart, totpart); + totsaved = std::min(psys->totpart, totpart); /* Save old pars. */ if (totsaved) { memcpy(newpars, psys->particles, totsaved * sizeof(ParticleData)); @@ -4404,7 +4405,8 @@ static void particles_fluid_step(ParticleSimulationData *sim, sub_v3_v3v3(size, max, min); /* Biggest dimension will be used for up-scaling. */ - max_size = MAX3(size[0] / float(upres), size[1] / float(upres), size[2] / float(upres)); + max_size = std::max( + {size[0] / float(upres), size[1] / float(upres), size[2] / float(upres)}); /* Set particle position. */ const float posParticle[3] = {posX, posY, posZ}; diff --git a/source/blender/blenkernel/intern/pointcache.cc b/source/blender/blenkernel/intern/pointcache.cc index 7b6a234891c..abc9554b8d0 100644 --- a/source/blender/blenkernel/intern/pointcache.cc +++ b/source/blender/blenkernel/intern/pointcache.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include #include #include #include @@ -408,7 +409,7 @@ static void ptcache_particle_interpolate(int index, return; } - cfra = MIN2(cfra, pa->dietime); + cfra = std::min(cfra, pa->dietime); cfra1 = std::min(cfra1, pa->dietime); cfra2 = std::min(cfra2, pa->dietime); @@ -442,7 +443,7 @@ static void ptcache_particle_interpolate(int index, } if (cfra > pa->time) { - cfra1 = MAX2(cfra1, pa->time); + cfra1 = std::max(cfra1, pa->time); } dfra = cfra2 - cfra1; @@ -2194,7 +2195,7 @@ static int ptcache_read(PTCacheID *pid, int cfra) if (totpoint != pid_totpoint) { pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh"); - totpoint = MIN2(totpoint, pid_totpoint); + totpoint = std::min(totpoint, pid_totpoint); } } @@ -2251,7 +2252,7 @@ static int ptcache_interpolate(PTCacheID *pid, float cfra, int cfra1, int cfra2) if (totpoint != pid_totpoint) { pid->error(pid->owner_id, pid->calldata, "Number of points in cache does not match mesh"); - totpoint = MIN2(totpoint, pid_totpoint); + totpoint = std::min(totpoint, pid_totpoint); } } @@ -3227,7 +3228,7 @@ void BKE_ptcache_bake(PTCacheBaker *baker) cache->flag |= PTCACHE_BAKING; } else { - endframe = MIN2(endframe, cache->endframe); + endframe = std::min(endframe, cache->endframe); } cache->flag &= ~PTCACHE_BAKED; @@ -3267,13 +3268,13 @@ void BKE_ptcache_bake(PTCacheBaker *baker) BKE_ptcache_id_clear(pid, PTCACHE_CLEAR_ALL, 0); } - startframe = MIN2(startframe, cache->startframe); + startframe = std::min(startframe, cache->startframe); if (bake || render) { cache->flag |= PTCACHE_BAKING; if (bake) { - endframe = MAX2(endframe, cache->endframe); + endframe = std::max(endframe, cache->endframe); } } diff --git a/source/blender/blenkernel/intern/rigidbody.cc b/source/blender/blenkernel/intern/rigidbody.cc index 56aead3de75..2500f290ce6 100644 --- a/source/blender/blenkernel/intern/rigidbody.cc +++ b/source/blender/blenkernel/intern/rigidbody.cc @@ -7,6 +7,7 @@ * \brief Blender-side interface and methods for dealing with Rigid Body simulations */ +#include #include #include #include @@ -505,7 +506,7 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw } else if (rbo->shape == RB_SHAPE_SPHERE) { /* take radius to the largest dimension to try and encompass everything */ - radius = MAX3(size[0], size[1], size[2]); + radius = std::max({size[0], size[1], size[2]}); } /* create new shape */ @@ -531,7 +532,7 @@ static rbCollisionShape *rigidbody_validate_sim_shape_helper(RigidBodyWorld *rbw case RB_SHAPE_CONVEXH: /* try to embed collision margin */ - has_volume = (MIN3(size[0], size[1], size[2]) > 0.0f); + has_volume = (std::min({size[0], size[1], size[2]}) > 0.0f); if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && has_volume) { hull_margin = 0.04f; @@ -636,7 +637,7 @@ void BKE_rigidbody_calc_volume(Object *ob, float *r_vol) if (ELEM(rbo->shape, RB_SHAPE_CAPSULE, RB_SHAPE_CYLINDER, RB_SHAPE_CONE)) { /* take radius as largest x/y dimension, and height as z-dimension */ - radius = MAX2(size[0], size[1]) * 0.5f; + radius = std::max(size[0], size[1]) * 0.5f; height = size[2]; } else if (rbo->shape == RB_SHAPE_SPHERE) { @@ -1790,7 +1791,8 @@ static void rigidbody_update_sim_ob(Depsgraph *depsgraph, Object *ob, RigidBodyO /* compensate for embedded convex hull collision margin */ if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && rbo->shape == RB_SHAPE_CONVEXH) { RB_shape_set_margin(static_cast(rbo->shared->physics_shape), - RBO_GET_MARGIN(rbo) * MIN3(new_scale[0], new_scale[1], new_scale[2])); + RBO_GET_MARGIN(rbo) * + std::min({new_scale[0], new_scale[1], new_scale[2]})); } } } @@ -2026,7 +2028,7 @@ static void rigidbody_update_kinematic_obj_substep(ListBase *substep_targets, fl /* compensate for embedded convex hull collision margin */ if (!(rbo->flag & RBO_FLAG_USE_MARGIN) && rbo->shape == RB_SHAPE_CONVEXH) { RB_shape_set_margin(static_cast(rbo->shared->physics_shape), - RBO_GET_MARGIN(rbo) * MIN3(scale[0], scale[1], scale[2])); + RBO_GET_MARGIN(rbo) * std::min({scale[0], scale[1], scale[2]})); } } } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 8d0f3898802..a994edb4c01 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -994,7 +994,7 @@ static bool seq_foreach_path_callback(Sequence *seq, void *user_data) if (bpath_data->flag & BKE_BPATH_FOREACH_PATH_SKIP_MULTIFILE) { /* only operate on one path */ - len = MIN2(1u, len); + len = std::min(1u, len); } for (i = 0; i < len; i++, se++) { diff --git a/source/blender/blenkernel/intern/vfont.cc b/source/blender/blenkernel/intern/vfont.cc index 3ec770ca0ff..27639f1797a 100644 --- a/source/blender/blenkernel/intern/vfont.cc +++ b/source/blender/blenkernel/intern/vfont.cc @@ -6,6 +6,7 @@ * \ingroup bke */ +#include #include #include #include @@ -1131,7 +1132,7 @@ static bool vfont_to_curve(Object *ob, current_line_length += twidth; } else { - longest_line_length = MAX2(current_line_length, longest_line_length); + longest_line_length = std::max(current_line_length, longest_line_length); current_line_length = 0.0f; } @@ -1190,7 +1191,7 @@ static bool vfont_to_curve(Object *ob, } current_line_length += xof + twidth - MARGIN_X_MIN; - longest_line_length = MAX2(current_line_length, longest_line_length); + longest_line_length = std::max(current_line_length, longest_line_length); cu->lines = 1; for (i = 0; i <= slen; i++) { diff --git a/source/blender/blenlib/BLI_index_mask.hh b/source/blender/blenlib/BLI_index_mask.hh index 9e132a23f83..10efe6d3141 100644 --- a/source/blender/blenlib/BLI_index_mask.hh +++ b/source/blender/blenlib/BLI_index_mask.hh @@ -142,8 +142,8 @@ using IndexMaskSegment = OffsetSpan; * various sources. Those generally need additional memory which is provided with by an * #IndexMaskMemory. * - * Some of the `IndexMask::from_*` functions are have an `IndexMask universe` input. When - * provided, the function will only consider the indices in the "universe". The term comes from + * Some of the `IndexMask::from_*` functions have an `IndexMask universe` input. When provided, + * the function will only consider the indices in the "universe". The term comes from * mathematics: https://en.wikipedia.org/wiki/Universe_(mathematics). * * Iteration: @@ -472,7 +472,7 @@ inline void init_empty_mask(IndexMaskData &data) data.indices_num_ = 0; data.segments_num_ = 0; data.cumulative_segment_sizes_ = cumulative_sizes_for_empty_mask; - /* Intentionally leave some pointer uninitialized which must not be accessed on empty masks + /* Intentionally leave some pointers uninitialized which must not be accessed on empty masks * anyway. */ } diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 25ed1e27fec..6ba1db047b8 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -32,76 +32,9 @@ extern "C" { /** \name Min/Max Macros * \{ */ -/* useful for finding bad use of min/max */ -#if 0 -/* gcc only */ -# define _TYPECHECK(a, b) ((void)(((typeof(a) *)0) == ((typeof(b) *)0))) -# define MIN2(x, y) (_TYPECHECK(x, y), (((x) < (y) ? (x) : (y)))) -# define MAX2(x, y) (_TYPECHECK(x, y), (((x) > (y) ? (x) : (y)))) -#endif - -/* min/max */ -#if defined(__GNUC__) || defined(__clang__) - -# define MIN2(a, b) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - ((a_) < (b_) ? (a_) : (b_)); \ - }) - -# define MAX2(a, b) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - ((a_) > (b_) ? (a_) : (b_)); \ - }) - -# define MIN3(a, b, c) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - typeof(c) c_ = (c); \ - ((a_ < b_) ? ((a_ < c_) ? a_ : c_) : ((b_ < c_) ? b_ : c_)); \ - }) - -# define MAX3(a, b, c) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - typeof(c) c_ = (c); \ - ((a_ > b_) ? ((a_ > c_) ? a_ : c_) : ((b_ > c_) ? b_ : c_)); \ - }) - -# define MIN4(a, b, c, d) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - typeof(c) c_ = (c); \ - typeof(d) d_ = (d); \ - ((a_ < b_) ? ((a_ < c_) ? ((a_ < d_) ? a_ : d_) : ((c_ < d_) ? c_ : d_)) : \ - ((b_ < c_) ? ((b_ < d_) ? b_ : d_) : ((c_ < d_) ? c_ : d_))); \ - }) - -# define MAX4(a, b, c, d) \ - __extension__({ \ - typeof(a) a_ = (a); \ - typeof(b) b_ = (b); \ - typeof(c) c_ = (c); \ - typeof(d) d_ = (d); \ - ((a_ > b_) ? ((a_ > c_) ? ((a_ > d_) ? a_ : d_) : ((c_ > d_) ? c_ : d_)) : \ - ((b_ > c_) ? ((b_ > d_) ? b_ : d_) : ((c_ > d_) ? c_ : d_))); \ - }) - -#else +#ifndef __cplusplus # define MIN2(a, b) ((a) < (b) ? (a) : (b)) # define MAX2(a, b) ((a) > (b) ? (a) : (b)) - -# define MIN3(a, b, c) (MIN2(MIN2((a), (b)), (c))) -# define MIN4(a, b, c, d) (MIN2(MIN2((a), (b)), MIN2((c), (d)))) - -# define MAX3(a, b, c) (MAX2(MAX2((a), (b)), (c))) -# define MAX4(a, b, c, d) (MAX2(MAX2((a), (b)), MAX2((c), (d)))) #endif #define INIT_MINMAX(min, max) \ diff --git a/source/blender/blenlib/intern/array_store.cc b/source/blender/blenlib/intern/array_store.cc index c9fb44dad87..9a1c02ddc76 100644 --- a/source/blender/blenlib/intern/array_store.cc +++ b/source/blender/blenlib/intern/array_store.cc @@ -87,6 +87,7 @@ * Otherwise new chunks are created. */ +#include #include #include @@ -158,11 +159,11 @@ struct BChunkList; # define BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_32BITS 4 # define BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_16BITS 5 /** - * Singe bytes (or boolean) arrays need a higher number of steps + * Single bytes (or boolean) arrays need a higher number of steps * because the resulting values are not unique enough to result in evenly distributed values. * Use more accumulation when the size of the structs is small, see: #105046. * - * With 6 -> 22, one byte each - means an array of booleans can be combine into 22 bits + * With 6 -> 22, one byte each - means an array of booleans can be combined into 22 bits * representing 4,194,303 different combinations. */ # define BCHUNK_HASH_TABLE_ACCUMULATE_STEPS_8BITS 6 @@ -479,7 +480,7 @@ static void bchunk_list_ensure_min_size_last(const BArrayInfo *info, BChunk *chunk_curr = cref->link; BChunk *chunk_prev = cref->prev->link; - if (MIN2(chunk_prev->data_len, chunk_curr->data_len) < info->chunk_byte_size_min) { + if (std::min(chunk_prev->data_len, chunk_curr->data_len) < info->chunk_byte_size_min) { const size_t data_merge_len = chunk_prev->data_len + chunk_curr->data_len; /* We could pass, but no need. */ if (data_merge_len <= info->chunk_byte_size_max) { @@ -632,7 +633,7 @@ static void bchunk_list_append_data(const BArrayInfo *info, BChunkRef *cref = static_cast(chunk_list->chunk_refs.last); BChunk *chunk_prev = cref->link; - if (MIN2(chunk_prev->data_len, data_len) < info->chunk_byte_size_min) { + if (std::min(chunk_prev->data_len, data_len) < info->chunk_byte_size_min) { const size_t data_merge_len = chunk_prev->data_len + data_len; /* Re-allocate for single user. */ if (cref->link->users == 1) { @@ -1004,7 +1005,7 @@ static hash_key key_from_chunk_ref(const BArrayInfo *info, const BChunkRef *cref { hash_key key; BChunk *chunk = cref->link; - const size_t data_hash_len = MIN2(chunk->data_len, BCHUNK_HASH_LEN * info->chunk_stride); + const size_t data_hash_len = std::min(chunk->data_len, BCHUNK_HASH_LEN * info->chunk_stride); # ifdef USE_HASH_TABLE_KEY_CACHE key = chunk->key; @@ -1039,7 +1040,7 @@ static const BChunkRef *table_lookup(const BArrayInfo *info, const size_t data_hash_len = BCHUNK_HASH_LEN * info->chunk_stride; /* TODO: cache. */ const size_t size_left = data_len - offset; - const hash_key key = hash_data(&data[offset], MIN2(data_hash_len, size_left)); + const hash_key key = hash_data(&data[offset], std::min(data_hash_len, size_left)); const uint key_index = (uint)(key % (hash_key)table_len); for (BTableRef *tref = table[key_index]; tref; tref = tref->next) { const BChunkRef *cref = tref->cref; @@ -1501,7 +1502,7 @@ BArrayStore *BLI_array_store_create(uint stride, uint chunk_count) bs->info.chunk_byte_size = chunk_count * stride; #ifdef USE_MERGE_CHUNKS - bs->info.chunk_byte_size_min = MAX2(1u, chunk_count / BCHUNK_SIZE_MIN_DIV) * stride; + bs->info.chunk_byte_size_min = std::max(1u, chunk_count / BCHUNK_SIZE_MIN_DIV) * stride; bs->info.chunk_byte_size_max = (chunk_count * BCHUNK_SIZE_MAX_MUL) * stride; #endif @@ -1531,7 +1532,7 @@ BArrayStore *BLI_array_store_create(uint stride, uint chunk_count) bs->info.accum_read_ahead_bytes = bs->info.accum_read_ahead_len * stride; #else - bs->info.accum_read_ahead_bytes = MIN2((size_t)BCHUNK_HASH_LEN, chunk_count) * stride; + bs->info.accum_read_ahead_bytes = std::min((size_t)BCHUNK_HASH_LEN, chunk_count) * stride; #endif bs->memory.chunk_list = BLI_mempool_create(sizeof(BChunkList), 0, 512, BLI_MEMPOOL_NOP); diff --git a/source/blender/blenlib/intern/fileops_c.cc b/source/blender/blenlib/intern/fileops_c.cc index 0af70d107ac..1d0b5e45a63 100644 --- a/source/blender/blenlib/intern/fileops_c.cc +++ b/source/blender/blenlib/intern/fileops_c.cc @@ -6,6 +6,7 @@ * \ingroup bli */ +#include #include /* malloc */ #include @@ -106,7 +107,7 @@ int64_t BLI_read(int fd, void *buf, size_t nbytes) buf, #ifdef WIN32 /* Read must not exceed INT_MAX on WIN32, clamp. */ - MIN2(nbytes, INT_MAX) + std::min(nbytes, INT_MAX) #else nbytes #endif diff --git a/source/blender/blenlib/intern/math_base_safe_inline.c b/source/blender/blenlib/intern/math_base_safe_inline.c index 652281eb66a..aba423e9da3 100644 --- a/source/blender/blenlib/intern/math_base_safe_inline.c +++ b/source/blender/blenlib/intern/math_base_safe_inline.c @@ -37,7 +37,7 @@ MINLINE float safe_logf(float a, float base) MINLINE float safe_sqrtf(float a) { - return sqrtf(MAX2(a, 0.0f)); + return sqrtf(max_ff(a, 0.0f)); } MINLINE float safe_inverse_sqrtf(float a) diff --git a/source/blender/blenlib/intern/path_util.cc b/source/blender/blenlib/intern/path_util.cc index 1fff28dc765..0a91702897f 100644 --- a/source/blender/blenlib/intern/path_util.cc +++ b/source/blender/blenlib/intern/path_util.cc @@ -104,7 +104,7 @@ int BLI_path_sequence_decode(const char *path, BLI_strncpy(tail, &path[nume + 1], tail_maxncpy); } if (head) { - BLI_strncpy(head, path, MIN2(head_maxncpy, nums + 1)); + BLI_strncpy(head, path, std::min(head_maxncpy, nums + 1)); } if (r_digits_len) { *r_digits_len = nume - nums + 1; @@ -119,7 +119,7 @@ int BLI_path_sequence_decode(const char *path, if (head) { /* Name_end points to last character of head, * make it +1 so null-terminator is nicely placed. */ - BLI_strncpy(head, path, MIN2(head_maxncpy, name_end + 1)); + BLI_strncpy(head, path, std::min(head_maxncpy, name_end + 1)); } if (r_digits_len) { *r_digits_len = 0; diff --git a/source/blender/blenlib/intern/string_utf8.cc b/source/blender/blenlib/intern/string_utf8.cc index 6721469b5ec..611af9de89b 100644 --- a/source/blender/blenlib/intern/string_utf8.cc +++ b/source/blender/blenlib/intern/string_utf8.cc @@ -10,6 +10,7 @@ * \ingroup bli */ +#include #include #include #include @@ -1069,7 +1070,7 @@ int BLI_str_utf8_offset_from_index(const char *str, const size_t str_len, const int BLI_str_utf8_offset_to_column(const char *str, const size_t str_len, const int offset_target) { BLI_assert(offset_target >= 0); - const size_t offset_target_clamp = MIN2(size_t(offset_target), str_len); + const size_t offset_target_clamp = std::min(size_t(offset_target), str_len); size_t offset = 0; int column = 0; while (offset < offset_target_clamp) { @@ -1101,7 +1102,7 @@ int BLI_str_utf8_offset_to_column_with_tabs(const char *str, const int tab_width) { BLI_assert(offset_target >= 0); - const size_t offset_target_clamp = MIN2(size_t(offset_target), str_len); + const size_t offset_target_clamp = std::min(size_t(offset_target), str_len); size_t offset = 0; int column = 0; while (offset < offset_target_clamp) { diff --git a/source/blender/blenlib/tests/BLI_string_test.cc b/source/blender/blenlib/tests/BLI_string_test.cc index a9b5f32a8f3..ed7a22c3de3 100644 --- a/source/blender/blenlib/tests/BLI_string_test.cc +++ b/source/blender/blenlib/tests/BLI_string_test.cc @@ -53,7 +53,7 @@ TEST(string, StrCopyUTF8_ASCII_Truncate) char dst[sizeof(src)]; \ memset(dst, 0xff, sizeof(dst)); \ BLI_strncpy_utf8(dst, src, maxncpy); \ - int len_expect = MIN2(sizeof(src), maxncpy) - 1; \ + int len_expect = std::min(sizeof(src), maxncpy) - 1; \ src[len_expect] = '\0'; /* To be able to use `EXPECT_STREQ`. */ \ EXPECT_EQ(strlen(dst), len_expect); \ EXPECT_STREQ(dst, src); \ diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index bdd942d0667..3b317b4fdbd 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -698,7 +698,7 @@ static BHeadN *get_bhead(FileData *fd) bh8_from_bh4(&bhead, &bhead4); } else { - /* MIN2 is only to quiet '-Warray-bounds' compiler warning. */ + /* std::min is only to quiet '-Warray-bounds' compiler warning. */ BLI_assert(sizeof(bhead) == sizeof(bhead4)); memcpy(&bhead, &bhead4, std::min(sizeof(bhead), sizeof(bhead4))); } @@ -721,7 +721,7 @@ static BHeadN *get_bhead(FileData *fd) bh4_from_bh8(&bhead, &bhead8, (fd->flags & FD_FLAGS_SWITCH_ENDIAN) != 0); } else { - /* MIN2 is only to quiet `-Warray-bounds` compiler warning. */ + /* std::min is only to quiet `-Warray-bounds` compiler warning. */ BLI_assert(sizeof(bhead) == sizeof(bhead8)); memcpy(&bhead, &bhead8, std::min(sizeof(bhead), sizeof(bhead8))); } diff --git a/source/blender/blenloader/intern/versioning_280.cc b/source/blender/blenloader/intern/versioning_280.cc index 31b9c08dbec..19d36e0af8e 100644 --- a/source/blender/blenloader/intern/versioning_280.cc +++ b/source/blender/blenloader/intern/versioning_280.cc @@ -9,6 +9,7 @@ /* allow readfile to use deprecated functionality */ #define DNA_DEPRECATED_ALLOW +#include #include #include @@ -3312,8 +3313,8 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) /* Calculate window width/height from screen vertices */ int win_width = 0, win_height = 0; LISTBASE_FOREACH (ScrVert *, vert, &screen->vertbase) { - win_width = MAX2(win_width, vert->vec.x); - win_height = MAX2(win_height, vert->vec.y); + win_width = std::max(win_width, vert->vec.x); + win_height = std::max(win_height, vert->vec.y); } for (ScrArea *area = static_cast(screen->areabase.first), *area_next; area; diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index c845bd22193..03d07c483e8 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -8,6 +8,8 @@ /* allow readfile to use deprecated functionality */ #define DNA_DEPRECATED_ALLOW +#include + #include "BLI_listbase.h" #include "BLI_math_matrix.h" #include "BLI_math_rotation.h" @@ -227,8 +229,8 @@ static void seq_convert_transform_crop(const Scene *scene, old_image_center_y = image_size_y / 2 - c->bottom + t->yofs; /* Preserve original image size. */ - t->scale_x = t->scale_y = MAX2(float(image_size_x) / float(scene->r.xsch), - float(image_size_y) / float(scene->r.ysch)); + t->scale_x = t->scale_y = std::max(float(image_size_x) / float(scene->r.xsch), + float(image_size_y) / float(scene->r.ysch)); /* Convert crop. */ if ((seq->flag & use_crop_flag) != 0) { @@ -311,8 +313,8 @@ static void seq_convert_transform_crop_2(const Scene *scene, } /* Calculate scale factor, so image fits in preview area with original aspect ratio. */ - const float scale_to_fit_factor = MIN2(float(scene->r.xsch) / float(image_size_x), - float(scene->r.ysch) / float(image_size_y)); + const float scale_to_fit_factor = std::min(float(scene->r.xsch) / float(image_size_x), + float(scene->r.ysch) / float(image_size_y)); t->scale_x *= scale_to_fit_factor; t->scale_y *= scale_to_fit_factor; c->top /= scale_to_fit_factor; diff --git a/source/blender/blenloader/intern/versioning_legacy.cc b/source/blender/blenloader/intern/versioning_legacy.cc index b477c676a11..bb2269be4a8 100644 --- a/source/blender/blenloader/intern/versioning_legacy.cc +++ b/source/blender/blenloader/intern/versioning_legacy.cc @@ -6,6 +6,7 @@ * \ingroup blenloader */ +#include #include #ifndef WIN32 @@ -1323,8 +1324,8 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) SubsurfModifierData *smd = (SubsurfModifierData *)BKE_modifier_new( eModifierType_Subsurf); - smd->levels = MAX2(1, mesh->subdiv); - smd->renderLevels = MAX2(1, mesh->subdivr); + smd->levels = std::max(1, mesh->subdiv); + smd->renderLevels = std::max(1, mesh->subdivr); smd->subdivType = mesh->subsurftype; smd->modifier.mode = 0; diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index f4b7ebb0f6a..12ad6a0be57 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -438,8 +438,8 @@ inline void ExecutionGroup::determine_chunk_rect(rcti *r_rect, else { const uint minx = x_chunk * chunk_size_ + viewer_border_.xmin; const uint miny = y_chunk * chunk_size_ + viewer_border_.ymin; - const uint width = MIN2(uint(viewer_border_.xmax), width_); - const uint height = MIN2(uint(viewer_border_.ymax), height_); + const uint width = std::min(uint(viewer_border_.xmax), width_); + const uint height = std::min(uint(viewer_border_.ymax), height_); BLI_rcti_init(r_rect, std::min(minx, width_), std::min(minx + chunk_size_, width), diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cc b/source/blender/compositor/intern/COM_MemoryBuffer.cc index 2665b314bbf..db6940f062a 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cc +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cc @@ -407,8 +407,8 @@ void MemoryBuffer::fill(const rcti &area, void MemoryBuffer::fill_from(const MemoryBuffer &src) { rcti overlap; - overlap.xmin = MAX2(rect_.xmin, src.rect_.xmin); - overlap.xmax = MIN2(rect_.xmax, src.rect_.xmax); + overlap.xmin = std::max(rect_.xmin, src.rect_.xmin); + overlap.xmax = std::min(rect_.xmax, src.rect_.xmax); overlap.ymin = std::max(rect_.ymin, src.rect_.ymin); overlap.ymax = std::min(rect_.ymax, src.rect_.ymax); copy_from(&src, overlap); diff --git a/source/blender/compositor/operations/COM_BokehBlurOperation.cc b/source/blender/compositor/operations/COM_BokehBlurOperation.cc index e07743ec1b3..e4a2bb40353 100644 --- a/source/blender/compositor/operations/COM_BokehBlurOperation.cc +++ b/source/blender/compositor/operations/COM_BokehBlurOperation.cc @@ -106,8 +106,8 @@ void BokehBlurOperation::execute_pixel(float output[4], int x, int y, void *data int maxx = x + pixel_size; miny = std::max(miny, input_rect.ymin); minx = std::max(minx, input_rect.xmin); - maxy = MIN2(maxy, input_rect.ymax); - maxx = MIN2(maxx, input_rect.xmax); + maxy = std::min(maxy, input_rect.ymax); + maxx = std::min(maxx, input_rect.xmax); int step = get_step(); int offsetadd = get_offset_add() * COM_DATA_TYPE_COLOR_CHANNELS; @@ -340,9 +340,9 @@ void BokehBlurOperation::update_memory_buffer_partial(MemoryBuffer *output, multiplier_accum[3] = 1.0f; } const int miny = std::max(y - pixel_size, image_rect.ymin); - const int maxy = MIN2(y + pixel_size, image_rect.ymax); + const int maxy = std::min(y + pixel_size, image_rect.ymax); const int minx = std::max(x - pixel_size, image_rect.xmin); - const int maxx = MIN2(x + pixel_size, image_rect.xmax); + const int maxx = std::min(x + pixel_size, image_rect.xmax); const int step = get_step(); const int elem_stride = image_input->elem_stride * step; const int row_stride = image_input->row_stride * step; diff --git a/source/blender/compositor/operations/COM_BoxMaskOperation.cc b/source/blender/compositor/operations/COM_BoxMaskOperation.cc index d6f873bd7dc..55f68fefe27 100644 --- a/source/blender/compositor/operations/COM_BoxMaskOperation.cc +++ b/source/blender/compositor/operations/COM_BoxMaskOperation.cc @@ -34,8 +34,8 @@ void BoxMaskOperation::execute_pixel_sampled(float output[4], float input_mask[4]; float input_value[4]; - float rx = x / MAX2(this->get_width() - 1.0f, FLT_EPSILON); - float ry = y / MAX2(this->get_height() - 1.0f, FLT_EPSILON); + float rx = x / std::max(this->get_width() - 1.0f, FLT_EPSILON); + float ry = y / std::max(this->get_height() - 1.0f, FLT_EPSILON); const float dy = (ry - data_->y) / aspect_ratio_; const float dx = rx - data_->x; @@ -130,8 +130,8 @@ void BoxMaskOperation::apply_mask(MemoryBuffer *output, Span inputs, MaskFunc mask_func) { - const float op_last_x = MAX2(this->get_width() - 1.0f, FLT_EPSILON); - const float op_last_y = MAX2(this->get_height() - 1.0f, FLT_EPSILON); + const float op_last_x = std::max(this->get_width() - 1.0f, FLT_EPSILON); + const float op_last_y = std::max(this->get_height() - 1.0f, FLT_EPSILON); const float half_w = data_->width / 2.0f + FLT_EPSILON; const float half_h = data_->height / 2.0f + FLT_EPSILON; for (BuffersIterator it = output->iterate_with(inputs, area); !it.is_end(); ++it) { diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc index e6d100ffb56..eb256c4d4ea 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cc +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cc @@ -115,7 +115,7 @@ void ChannelMatteOperation::update_memory_buffer_partial(MemoryBuffer *output, const float *color = it.in(0); /* Matte operation. */ - float alpha = color[ids_[0]] - MAX2(color[ids_[1]], color[ids_[2]]); + float alpha = color[ids_[0]] - std::max(color[ids_[1]], color[ids_[2]]); /* Flip because 0.0 is transparent, not 1.0. */ alpha = 1.0f - alpha; @@ -136,7 +136,7 @@ void ChannelMatteOperation::update_memory_buffer_partial(MemoryBuffer *output, */ /* Don't make something that was more transparent less transparent. */ - *it.out = MIN2(alpha, color[3]); + *it.out = std::min(alpha, color[3]); } } diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index 6c0f5e89d3d..1274004f3e8 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -27,12 +27,12 @@ class ChannelMatteOperation : public MultiThreadedOperation { /** * ids to use for the operations (max and simple) - * alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]]) + * alpha = in[ids[0]] - std::max(in[ids[1]], in[ids[2]]) * the simple operation is using: * alpha = in[ids[0]] - in[ids[1]] * but to use the same formula and operation for both we do: * ids[2] = ids[1] - * alpha = in[ids[0]] - MAX2(in[ids[1]], in[ids[2]]) + * alpha = in[ids[0]] - std::max(in[ids[1]], in[ids[2]]) */ int ids_[3]; diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc index 7cfd9f4f4d8..8968b009ce0 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.cc @@ -47,7 +47,7 @@ void ColorBalanceASCCDLOperation::execute_pixel_sampled(float output[4], input_color_operation_->read_sampled(input_color, x, y, sampler); float fac = value[0]; - fac = MIN2(1.0f, fac); + fac = std::min(1.0f, fac); const float mfac = 1.0f - fac; output[0] = mfac * input_color[0] + @@ -64,7 +64,7 @@ void ColorBalanceASCCDLOperation::update_memory_buffer_row(PixelCursor &p) for (; p.out < p.row_end; p.next()) { const float *in_factor = p.ins[0]; const float *in_color = p.ins[1]; - const float fac = MIN2(1.0f, in_factor[0]); + const float fac = std::min(1.0f, in_factor[0]); const float fac_m = 1.0f - fac; p.out[0] = fac_m * in_color[0] + fac * colorbalance_cdl(in_color[0], offset_[0], power_[0], slope_[0]); diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc index 29ffbff7195..9b0e4466bba 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.cc @@ -71,7 +71,7 @@ void ColorBalanceLGGOperation::update_memory_buffer_row(PixelCursor &p) for (; p.out < p.row_end; p.next()) { const float *in_factor = p.ins[0]; const float *in_color = p.ins[1]; - const float fac = MIN2(1.0f, in_factor[0]); + const float fac = std::min(1.0f, in_factor[0]); const float fac_m = 1.0f - fac; p.out[0] = fac_m * in_color[0] + fac * colorbalance_lgg(in_color[0], lift_[0], gamma_inv_[0], gain_[0]); diff --git a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc index 2520277729d..08b350c9d6c 100644 --- a/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc +++ b/source/blender/compositor/operations/COM_ColorCorrectionOperation.cc @@ -54,7 +54,7 @@ void ColorCorrectionOperation::execute_pixel_sampled(float output[4], float r, g, b; float value = input_mask[0]; - value = MIN2(1.0f, value); + value = std::min(1.0f, value); const float mvalue = 1.0f - value; float level_shadows = 0.0; @@ -204,7 +204,7 @@ void ColorCorrectionOperation::update_memory_buffer_row(PixelCursor &p) b = color_correct_powf_safe(b * gain + lift, inv_gamma, b); /* Mix with mask. */ - const float value = MIN2(1.0f, in_mask[0]); + const float value = std::min(1.0f, in_mask[0]); const float value_ = 1.0f - value; r = value_ * in_color[0] + value * r; g = value_ * in_color[1] + value * g; diff --git a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cc b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cc index 4e956bdc50d..cdfeb9b5ac6 100644 --- a/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cc +++ b/source/blender/compositor/operations/COM_ConvolutionEdgeFilterOperation.cc @@ -74,10 +74,10 @@ void ConvolutionEdgeFilterOperation::execute_pixel(float output[4], int x, int y output[3] = in2[3]; /* Make sure we don't return negative color. */ - output[0] = MAX2(output[0], 0.0f); - output[1] = MAX2(output[1], 0.0f); - output[2] = MAX2(output[2], 0.0f); - output[3] = MAX2(output[3], 0.0f); + output[0] = std::max(output[0], 0.0f); + output[1] = std::max(output[1], 0.0f); + output[2] = std::max(output[2], 0.0f); + output[3] = std::max(output[3], 0.0f); } void ConvolutionEdgeFilterOperation::update_memory_buffer_partial(MemoryBuffer *output, diff --git a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc index 78040661cf1..42728282bef 100644 --- a/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc +++ b/source/blender/compositor/operations/COM_ConvolutionFilterOperation.cc @@ -90,10 +90,10 @@ void ConvolutionFilterOperation::execute_pixel(float output[4], int x, int y, vo output[3] = output[3] * value[0] + in2[3] * mval; /* Make sure we don't return negative color. */ - output[0] = MAX2(output[0], 0.0f); - output[1] = MAX2(output[1], 0.0f); - output[2] = MAX2(output[2], 0.0f); - output[3] = MAX2(output[3], 0.0f); + output[0] = std::max(output[0], 0.0f); + output[1] = std::max(output[1], 0.0f); + output[2] = std::max(output[2], 0.0f); + output[3] = std::max(output[3], 0.0f); } bool ConvolutionFilterOperation::determine_depending_area_of_interest( diff --git a/source/blender/compositor/operations/COM_EllipseMaskOperation.cc b/source/blender/compositor/operations/COM_EllipseMaskOperation.cc index f11c9a69386..3379b6a7cf3 100644 --- a/source/blender/compositor/operations/COM_EllipseMaskOperation.cc +++ b/source/blender/compositor/operations/COM_EllipseMaskOperation.cc @@ -34,8 +34,8 @@ void EllipseMaskOperation::execute_pixel_sampled(float output[4], float input_mask[4]; float input_value[4]; - float rx = x / MAX2(this->get_width() - 1.0f, FLT_EPSILON); - float ry = y / MAX2(this->get_height() - 1.0f, FLT_EPSILON); + float rx = x / std::max(this->get_width() - 1.0f, FLT_EPSILON); + float ry = y / std::max(this->get_height() - 1.0f, FLT_EPSILON); const float dy = (ry - data_->y) / aspect_ratio_; const float dx = rx - data_->x; @@ -138,8 +138,8 @@ void EllipseMaskOperation::apply_mask(MemoryBuffer *output, { const MemoryBuffer *input_mask = inputs[0]; const MemoryBuffer *input_value = inputs[1]; - const float op_last_x = MAX2(this->get_width() - 1.0f, FLT_EPSILON); - const float op_last_y = MAX2(this->get_height() - 1.0f, FLT_EPSILON); + const float op_last_x = std::max(this->get_width() - 1.0f, FLT_EPSILON); + const float op_last_y = std::max(this->get_height() - 1.0f, FLT_EPSILON); const float half_w = data_->width / 2.0f; const float half_h = data_->height / 2.0f; const float tx = half_w * half_w; diff --git a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc index 1e8c2689a76..94f257f4834 100644 --- a/source/blender/compositor/operations/COM_GlareThresholdOperation.cc +++ b/source/blender/compositor/operations/COM_GlareThresholdOperation.cc @@ -44,9 +44,9 @@ void GlareThresholdOperation::execute_pixel_sampled(float output[4], output[1] -= threshold; output[2] -= threshold; - output[0] = MAX2(output[0], 0.0f); - output[1] = MAX2(output[1], 0.0f); - output[2] = MAX2(output[2], 0.0f); + output[0] = std::max(output[0], 0.0f); + output[1] = std::max(output[1], 0.0f); + output[2] = std::max(output[2], 0.0f); } else { zero_v3(output); diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc index 5469501dccd..99f90946ae0 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cc @@ -42,7 +42,8 @@ void LuminanceMatteOperation::execute_pixel_sampled(float output[4], float alpha; /* one line thread-friend algorithm: - * output[0] = MIN2(input_value[3], MIN2(1.0f, MAX2(0.0f, ((luminance - low) / (high - low)))); + * output[0] = std::min(input_value[3], std::min(1.0f, std::max(0.0f, ((luminance - low) / (high + * - low)))); */ /* test range */ @@ -73,7 +74,8 @@ void LuminanceMatteOperation::update_memory_buffer_partial(MemoryBuffer *output, const float luminance = IMB_colormanagement_get_luminance(color); /* One line thread-friend algorithm: - * `it.out[0] = MIN2(color[3], MIN2(1.0f, MAX2(0.0f, ((luminance - low) / (high - low))));` + * `it.out[0] = std::min(color[3], std::min(1.0f, std::max(0.0f, ((luminance - low) / (high - + * low))));` */ /* Test range. */ @@ -95,7 +97,7 @@ void LuminanceMatteOperation::update_memory_buffer_partial(MemoryBuffer *output, */ /* Don't make something that was more transparent less transparent. */ - it.out[0] = MIN2(alpha, color[3]); + it.out[0] = std::min(alpha, color[3]); } } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index 22009fac60e..498231771be 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -83,7 +83,7 @@ class MaskOperation : public MultiThreadedOperation { void set_motion_blur_samples(int samples) { - raster_mask_handle_tot_ = MIN2(MAX2(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX); + raster_mask_handle_tot_ = std::min(std::max(1, samples), CMP_NODE_MASK_MBLUR_SAMPLES_MAX); } void set_motion_blur_shutter(float shutter) { diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cc b/source/blender/compositor/operations/COM_MathBaseOperation.cc index 5d65014f888..35cd7caf605 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.cc +++ b/source/blender/compositor/operations/COM_MathBaseOperation.cc @@ -468,7 +468,7 @@ void MathMinimumOperation::execute_pixel_sampled(float output[4], input_value1_operation_->read_sampled(input_value1, x, y, sampler); input_value2_operation_->read_sampled(input_value2, x, y, sampler); - output[0] = MIN2(input_value1[0], input_value2[0]); + output[0] = std::min(input_value1[0], input_value2[0]); clamp_if_needed(output); } @@ -476,7 +476,7 @@ void MathMinimumOperation::execute_pixel_sampled(float output[4], void MathMinimumOperation::update_memory_buffer_partial(BuffersIterator &it) { for (; !it.is_end(); ++it) { - *it.out = MIN2(*it.in(0), *it.in(1)); + *it.out = std::min(*it.in(0), *it.in(1)); clamp_when_enabled(it.out); } } @@ -492,7 +492,7 @@ void MathMaximumOperation::execute_pixel_sampled(float output[4], input_value1_operation_->read_sampled(input_value1, x, y, sampler); input_value2_operation_->read_sampled(input_value2, x, y, sampler); - output[0] = MAX2(input_value1[0], input_value2[0]); + output[0] = std::max(input_value1[0], input_value2[0]); clamp_if_needed(output); } @@ -500,7 +500,7 @@ void MathMaximumOperation::execute_pixel_sampled(float output[4], void MathMaximumOperation::update_memory_buffer_partial(BuffersIterator &it) { for (; !it.is_end(); ++it) { - *it.out = MAX2(*it.in(0), *it.in(1)); + *it.out = std::max(*it.in(0), *it.in(1)); clamp_when_enabled(it.out); } } @@ -1007,7 +1007,7 @@ void MathCompareOperation::execute_pixel_sampled(float output[4], void MathCompareOperation::update_memory_buffer_partial(BuffersIterator &it) { for (; !it.is_end(); ++it) { - *it.out = (fabsf(*it.in(0) - *it.in(1)) <= MAX2(*it.in(2), 1e-5f)) ? 1.0f : 0.0f; + *it.out = (fabsf(*it.in(0) - *it.in(1)) <= std::max(*it.in(2), 1e-5f)) ? 1.0f : 0.0f; clamp_when_enabled(it.out); } } diff --git a/source/blender/compositor/operations/COM_MixOperation.cc b/source/blender/compositor/operations/COM_MixOperation.cc index 25c3870207a..707067caf7c 100644 --- a/source/blender/compositor/operations/COM_MixOperation.cc +++ b/source/blender/compositor/operations/COM_MixOperation.cc @@ -803,9 +803,9 @@ void MixGlareOperation::execute_pixel_sampled(float output[4], input_weight = 1.0f - value; glare_weight = 1.0f; } - output[0] = input_weight * MAX2(input_color1[0], 0.0f) + glare_weight * input_color2[0]; - output[1] = input_weight * MAX2(input_color1[1], 0.0f) + glare_weight * input_color2[1]; - output[2] = input_weight * MAX2(input_color1[2], 0.0f) + glare_weight * input_color2[2]; + output[0] = input_weight * std::max(input_color1[0], 0.0f) + glare_weight * input_color2[0]; + output[1] = input_weight * std::max(input_color1[1], 0.0f) + glare_weight * input_color2[1]; + output[2] = input_weight * std::max(input_color1[2], 0.0f) + glare_weight * input_color2[2]; output[3] = input_color1[3]; clamp_if_needed(output); @@ -828,9 +828,9 @@ void MixGlareOperation::update_memory_buffer_row(PixelCursor &p) input_weight = 1.0f - value; glare_weight = 1.0f; } - p.out[0] = input_weight * MAX2(p.color1[0], 0.0f) + glare_weight * p.color2[0]; - p.out[1] = input_weight * MAX2(p.color1[1], 0.0f) + glare_weight * p.color2[1]; - p.out[2] = input_weight * MAX2(p.color1[2], 0.0f) + glare_weight * p.color2[2]; + p.out[0] = input_weight * std::max(p.color1[0], 0.0f) + glare_weight * p.color2[0]; + p.out[1] = input_weight * std::max(p.color1[1], 0.0f) + glare_weight * p.color2[1]; + p.out[2] = input_weight * std::max(p.color1[2], 0.0f) + glare_weight * p.color2[2]; p.out[3] = p.color1[3]; clamp_if_needed(p.out); @@ -963,13 +963,13 @@ void MixLightenOperation::update_memory_buffer_row(PixelCursor &p) } float tmp = value * p.color2[0]; - p.out[0] = MAX2(tmp, p.color1[0]); + p.out[0] = std::max(tmp, p.color1[0]); tmp = value * p.color2[1]; - p.out[1] = MAX2(tmp, p.color1[1]); + p.out[1] = std::max(tmp, p.color1[1]); tmp = value * p.color2[2]; - p.out[2] = MAX2(tmp, p.color1[2]); + p.out[2] = std::max(tmp, p.color1[2]); p.out[3] = p.color1[3]; diff --git a/source/blender/compositor/operations/COM_RotateOperation.cc b/source/blender/compositor/operations/COM_RotateOperation.cc index 9b5104885ec..d4d69364204 100644 --- a/source/blender/compositor/operations/COM_RotateOperation.cc +++ b/source/blender/compositor/operations/COM_RotateOperation.cc @@ -57,10 +57,10 @@ void RotateOperation::get_area_rotation_bounds(const rcti &area, const float y2 = center_y + (sine * dxmax + cosine * dymin); const float y3 = center_y + (sine * dxmin + cosine * dymax); const float y4 = center_y + (sine * dxmax + cosine * dymax); - const float minx = MIN2(x1, MIN2(x2, MIN2(x3, x4))); - const float maxx = std::max(x1, MAX2(x2, std::max(x3, x4))); - const float miny = MIN2(y1, std::min(y2, MIN2(y3, y4))); - const float maxy = std::max(y1, MAX2(y2, std::max(y3, y4))); + const float minx = std::min(x1, std::min(x2, std::min(x3, x4))); + const float maxx = std::max(x1, std::max(x2, std::max(x3, x4))); + const float miny = std::min(y1, std::min(y2, std::min(y3, y4))); + const float maxy = std::max(y1, std::max(y2, std::max(y3, y4))); r_bounds.xmin = floor(minx); r_bounds.xmax = ceil(maxx); diff --git a/source/blender/compositor/operations/COM_ScaleOperation.h b/source/blender/compositor/operations/COM_ScaleOperation.h index dfcf08542af..25895ba7a26 100644 --- a/source/blender/compositor/operations/COM_ScaleOperation.h +++ b/source/blender/compositor/operations/COM_ScaleOperation.h @@ -54,14 +54,14 @@ class ScaleOperation : public BaseScaleOperation { static float scale_coord(const float coord, const float center, const float relative_scale) { - return center + (coord - center) * MAX2(relative_scale, MIN_RELATIVE_SCALE); + return center + (coord - center) * std::max(relative_scale, MIN_RELATIVE_SCALE); } static float scale_coord_inverted(const float coord, const float center, const float relative_scale) { - return center + (coord - center) / MAX2(relative_scale, MIN_RELATIVE_SCALE); + return center + (coord - center) / std::max(relative_scale, MIN_RELATIVE_SCALE); } static void get_scale_offset(const rcti &input_canvas, diff --git a/source/blender/compositor/operations/COM_TonemapOperation.cc b/source/blender/compositor/operations/COM_TonemapOperation.cc index baba168e9d4..949f5ff4229 100644 --- a/source/blender/compositor/operations/COM_TonemapOperation.cc +++ b/source/blender/compositor/operations/COM_TonemapOperation.cc @@ -41,7 +41,7 @@ void TonemapOperation::execute_pixel(float output[4], int x, int y, void *data) const float igm = avg->igm; if (igm != 0.0f) { output[0] = powf(std::max(output[0], 0.0f), igm); - output[1] = powf(MAX2(output[1], 0.0f), igm); + output[1] = powf(std::max(output[1], 0.0f), igm); output[2] = powf(std::max(output[2], 0.0f), igm); } } @@ -115,7 +115,7 @@ void *TonemapOperation::initialize_tile_data(rcti *rect) float L = IMB_colormanagement_get_luminance(bc); Lav += L; add_v3_v3(cav, bc); - lsum += logf(MAX2(L, 0.0f) + 1e-5f); + lsum += logf(std::max(L, 0.0f) + 1e-5f); maxl = (L > maxl) ? L : maxl; minl = (L < minl) ? L : minl; bc += 4; @@ -164,9 +164,9 @@ static Luminance calc_area_luminance(const MemoryBuffer *input, const rcti &area const float lu = IMB_colormanagement_get_luminance(elem); lum.sum += lu; add_v3_v3(lum.color_sum, elem); - lum.log_sum += logf(MAX2(lu, 0.0f) + 1e-5f); - lum.max = MAX2(lu, lum.max); - lum.min = MIN2(lu, lum.min); + lum.log_sum += logf(std::max(lu, 0.0f) + 1e-5f); + lum.max = std::max(lu, lum.max); + lum.min = std::min(lu, lum.min); lum.num_pixels++; } return lum; @@ -235,8 +235,8 @@ void TonemapOperation::update_memory_buffer_partial(MemoryBuffer *output, it.out[1] /= ((dg == 0.0f) ? 1.0f : dg); it.out[2] /= ((db == 0.0f) ? 1.0f : db); if (igm != 0.0f) { - it.out[0] = powf(MAX2(it.out[0], 0.0f), igm); - it.out[1] = powf(MAX2(it.out[1], 0.0f), igm); + it.out[0] = powf(std::max(it.out[0], 0.0f), igm); + it.out[1] = powf(std::max(it.out[1], 0.0f), igm); it.out[2] = powf(std::max(it.out[2], 0.0f), igm); } } diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cc b/source/blender/compositor/operations/COM_VectorBlurOperation.cc index e155629bc19..c3311bea5c9 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cc +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cc @@ -906,7 +906,7 @@ void zbuf_accumulate_vecblur(NodeBlurData *nbd, dz2[3] += bfac * dr->colpoin[3]; *rw += bfac; - *rm = MAX2(*rm, bfac); + *rm = std::max(*rm, bfac); } } } diff --git a/source/blender/datatoc/datatoc.cc b/source/blender/datatoc/datatoc.cc index 4147b1a0af3..bb1d7c2f2fd 100644 --- a/source/blender/datatoc/datatoc.cc +++ b/source/blender/datatoc/datatoc.cc @@ -6,15 +6,13 @@ * \ingroup datatoc */ +#include #include #include #include /* #define VERBOSE */ -#define MAX2(x, y) ((x) > (y) ? (x) : (y)) -#define MAX3(x, y, z) MAX2(MAX2((x), (y)), (z)) - #define STRPREFIX(a, b) (strncmp((a), (b), strlen(b)) == 0) static char *arg_basename(char *string) @@ -30,7 +28,7 @@ static char *arg_basename(char *string) lfslash++; } - return MAX3(string, lfslash, lbslash); + return std::max({string, lfslash, lbslash}); } /** diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.cc b/source/blender/draw/engines/eevee/eevee_lightcache.cc index ad1d9474d2f..f43b920340d 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.cc +++ b/source/blender/draw/engines/eevee/eevee_lightcache.cc @@ -1098,8 +1098,8 @@ static void compute_cell_id(EEVEE_LightGrid *egrid, probe->grid_resolution_z; /* Add one for level 0 */ - int max_lvl = int(floorf(log2f( - float(MAX3(probe->grid_resolution_x, probe->grid_resolution_y, probe->grid_resolution_z))))); + int max_lvl = int(floorf(log2f(float( + std::max({probe->grid_resolution_x, probe->grid_resolution_y, probe->grid_resolution_z}))))); int visited_cells = 0; *r_stride = 0; diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index 94ce41a9bec..db684932130 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -6,6 +6,8 @@ * \ingroup draw */ +#include + #include "BLI_listbase.h" #include "BLI_rect.h" #include "BLI_string.h" @@ -178,7 +180,7 @@ void DRW_stats_reset() timer->time_average = timer->time_average * (1.0 - GPU_TIMER_FALLOFF) + time * GPU_TIMER_FALLOFF; - timer->time_average = MIN2(timer->time_average, 1000000000); + timer->time_average = std::min(timer->time_average, uint64_t(1000000000)); } else { timer->time_average = lvl_time[timer->lvl + 1]; diff --git a/source/blender/editors/animation/keyframes_keylist.cc b/source/blender/editors/animation/keyframes_keylist.cc index 3104a0bd43c..089ed42b567 100644 --- a/source/blender/editors/animation/keyframes_keylist.cc +++ b/source/blender/editors/animation/keyframes_keylist.cc @@ -885,7 +885,7 @@ static void update_keyblocks(AnimKeylist *keylist, BezTriple *bezt, const int be int max_curve = 0; LISTBASE_FOREACH (ActKeyColumn *, col, &keylist->key_columns) { - max_curve = MAX2(max_curve, col->totcurve); + max_curve = std::max(max_curve, int(col->totcurve)); } /* Propagate blocks to inserted keys. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_data.cc b/source/blender/editors/gpencil_legacy/gpencil_data.cc index 22cf6fe6378..af80482fc31 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_data.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_data.cc @@ -8,6 +8,7 @@ * Operators for dealing with GP data-blocks and layers. */ +#include #include #include #include @@ -2729,7 +2730,7 @@ static int gpencil_vertex_group_normalize_all_exec(bContext *C, wmOperator *op) } /* Normalize weights. */ - float fac = MAX2(0, (1.0f - sum_lock) / sum_unlock); + float fac = std::max(0.0f, (1.0f - sum_lock) / sum_unlock); for (v = 0; v < defbase_tot; v++) { /* Get vertex group. */ diff --git a/source/blender/editors/gpencil_legacy/gpencil_utils.cc b/source/blender/editors/gpencil_legacy/gpencil_utils.cc index a3b65d5bb6a..b4d4396c710 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_utils.cc +++ b/source/blender/editors/gpencil_legacy/gpencil_utils.cc @@ -6,6 +6,7 @@ * \ingroup edgpencil */ +#include #include #include #include @@ -1770,7 +1771,7 @@ float ED_gpencil_cursor_radius(bContext *C, int x, int y) point2D.m_xy[0] = float(x + 64); gpencil_stroke_convertcoords_tpoint(scene, region, ob, &point2D, nullptr, p2); /* Clip extreme zoom level (and avoid division by zero). */ - distance = MAX2(len_v3v3(p1, p2), 0.001f); + distance = std::max(len_v3v3(p1, p2), 0.001f); /* Handle layer thickness change. */ float brush_size = float(brush->size); diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index a9046f85954..dc8c0115adc 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include #include @@ -798,10 +799,10 @@ static ImBuf *create_mono_icon_with_border(ImBuf *buf, const int blur_size = 2 / resolution_divider; for (int bx = 0; bx < icon_width; bx++) { const int asx = std::max(bx - blur_size, 0); - const int aex = MIN2(bx + blur_size + 1, icon_width); + const int aex = std::min(bx + blur_size + 1, icon_width); for (int by = 0; by < icon_height; by++) { const int asy = std::max(by - blur_size, 0); - const int aey = MIN2(by + blur_size + 1, icon_height); + const int aey = std::min(by + blur_size + 1, icon_height); /* blur alpha channel */ const int write_offset = by * (ICON_GRID_W + 2 * ICON_MONO_BORDER_OUTSET) + bx; @@ -2584,7 +2585,7 @@ ImBuf *UI_icon_alert_imbuf_get(eAlertIcon icon) return nullptr; #else const int ALERT_IMG_SIZE = 256; - icon = eAlertIcon(MIN2(icon, ALERT_ICON_MAX - 1)); + icon = eAlertIcon(std::min(icon, ALERT_ICON_MAX - 1)); const int left = icon * ALERT_IMG_SIZE; const rcti crop = {left, left + ALERT_IMG_SIZE - 1, 0, ALERT_IMG_SIZE - 1}; ImBuf *ibuf = IMB_ibImageFromMemory((const uchar *)datatoc_alert_icons_png, diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 3919328fdb2..4c1e03063b8 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include #include @@ -4302,7 +4303,7 @@ static void ui_litem_estimate_column_flow(uiLayout *litem) int totitem = 0; LISTBASE_FOREACH (uiItem *, item, &litem->items) { ui_item_size(item, &itemw, &itemh); - maxw = MAX2(maxw, itemw); + maxw = std::max(maxw, itemw); toth += itemh; totitem++; } @@ -6382,7 +6383,7 @@ uiLayout *uiItemsAlertBox(uiBlock *block, const int size, const eAlertIcon icon) { const uiStyle *style = UI_style_get_dpi(); const short icon_size = 64 * UI_SCALE_FAC; - const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points); + const int text_points_max = std::max(style->widget.points, style->widgetlabel.points); const int dialog_width = icon_size + (text_points_max * size * UI_SCALE_FAC); /* By default, the space between icon and text/buttons will be equal to the 'columnspace', * this extra padding will add some space by increasing the left column width, diff --git a/source/blender/editors/interface/interface_region_menu_popup.cc b/source/blender/editors/interface/interface_region_menu_popup.cc index 8e1473fb373..7e9b80e9ec3 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.cc +++ b/source/blender/editors/interface/interface_region_menu_popup.cc @@ -8,6 +8,7 @@ * PopUp Menu Region */ +#include #include #include #include @@ -592,7 +593,7 @@ void UI_popup_menu_reports(bContext *C, ReportList *reports) msg_next = strchr(msg, '\n'); if (msg_next) { msg_next++; - BLI_strncpy(buf, msg, MIN2(sizeof(buf), msg_next - msg)); + BLI_strncpy(buf, msg, std::min(sizeof(buf), size_t(msg_next - msg))); msg = buf; } uiItemL(layout, msg, icon); diff --git a/source/blender/editors/interface/interface_region_tooltip.cc b/source/blender/editors/interface/interface_region_tooltip.cc index 888f7dcd215..454b869d66d 100644 --- a/source/blender/editors/interface/interface_region_tooltip.cc +++ b/source/blender/editors/interface/interface_region_tooltip.cc @@ -17,6 +17,7 @@ * For now it's not a priority, so leave as-is. */ +#include #include #include #include diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index f168a415190..99702c80329 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include @@ -1006,7 +1007,8 @@ static void ui_template_list_layout_draw(const bContext *C, const int size_x = UI_preview_tile_size_x(); const int size_y = show_names ? UI_preview_tile_size_y() : UI_preview_tile_size_y_no_label(); - const int cols_per_row = MAX2((uiLayoutGetWidth(box) - V2D_SCROLL_WIDTH) / size_x, 1); + const int cols_per_row = std::max(int((uiLayoutGetWidth(box) - V2D_SCROLL_WIDTH) / size_x), + 1); uiLayout *grid = uiLayoutGridFlow(row, true, cols_per_row, true, true, true); TemplateListLayoutDrawData adjusted_layout_data = *layout_data; diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index 9a4504736ba..863b2a15734 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include #include @@ -7272,7 +7273,7 @@ static void uiTemplateRecentFiles_tooltip_func(bContext * /*C*/, uiTooltipData * } if (thumb) { - float scale = (72.0f * UI_SCALE_FAC) / float(MAX2(thumb->x, thumb->y)); + float scale = (72.0f * UI_SCALE_FAC) / float(std::max(thumb->x, thumb->y)); short size[2] = {short(float(thumb->x) * scale), short(float(thumb->y) * scale)}; UI_tooltip_text_field_add(tip, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL); UI_tooltip_text_field_add(tip, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL); diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 4b0d22e5c05..373d466fb57 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include #include @@ -2846,7 +2847,7 @@ static void ui_hsv_cursor(const float x, immUniform1f("outlineWidth", U.pixelsize); /* Alpha of outline colors just strong enough to give good contrast. */ - const float fg = MIN2(1.0f - hsv[2] + 0.2, 0.8f); + const float fg = std::min(1.0f - hsv[2] + 0.2f, 0.8f); const float bg = hsv[2] / 2.0f; immUniform4f("outlineColor", 0.0f, 0.0f, 0.0f, bg); diff --git a/source/blender/editors/interface/view2d_draw.cc b/source/blender/editors/interface/view2d_draw.cc index 6c5f42a45bd..d9fec3d8a02 100644 --- a/source/blender/editors/interface/view2d_draw.cc +++ b/source/blender/editors/interface/view2d_draw.cc @@ -6,6 +6,7 @@ * \ingroup edinterface */ +#include #include #include #include @@ -148,7 +149,7 @@ static void get_parallel_lines_draw_steps(const ParallelLinesSet *lines, lines->offset; if (region_start <= *r_first && region_end >= *r_first) { - *r_steps = MAX2(0, floorf((region_end - *r_first) / lines->distance)) + 1; + *r_steps = std::max(0.0f, floorf((region_end - *r_first) / lines->distance)) + 1; } else { *r_steps = 0; diff --git a/source/blender/editors/mask/mask_add.cc b/source/blender/editors/mask/mask_add.cc index a62e46c486c..e731303aa0d 100644 --- a/source/blender/editors/mask/mask_add.cc +++ b/source/blender/editors/mask/mask_add.cc @@ -6,6 +6,8 @@ * \ingroup edmask */ +#include + #include "MEM_guardedalloc.h" #include "BKE_context.hh" @@ -85,13 +87,13 @@ static void setup_vertex_point(Mask *mask, current_point = &spline->points[point_index]; if (current_point->bezt.h1 != HD_VECT || current_point->bezt.h2 != HD_VECT) { - bezt->h1 = bezt->h2 = MAX2(current_point->bezt.h2, current_point->bezt.h1); + bezt->h1 = bezt->h2 = std::max(current_point->bezt.h2, current_point->bezt.h1); break; } } } else { - bezt->h1 = bezt->h2 = MAX2(reference_point->bezt.h2, reference_point->bezt.h1); + bezt->h1 = bezt->h2 = std::max(reference_point->bezt.h2, reference_point->bezt.h1); } reference_parent_point = reference_point; @@ -121,12 +123,12 @@ static void setup_vertex_point(Mask *mask, } /* handle type */ - char handle_type = 0; + uint8_t handle_type = 0; if (prev_point) { handle_type = prev_point->bezt.h2; } if (next_point) { - handle_type = MAX2(next_point->bezt.h2, handle_type); + handle_type = std::max(next_point->bezt.h2, handle_type); } bezt->h1 = bezt->h2 = handle_type; diff --git a/source/blender/editors/mesh/meshtools.cc b/source/blender/editors/mesh/meshtools.cc index ae2da39834e..70b44aa5aaf 100644 --- a/source/blender/editors/mesh/meshtools.cc +++ b/source/blender/editors/mesh/meshtools.cc @@ -9,6 +9,8 @@ * tools operating on meshes */ +#include + #include "MEM_guardedalloc.h" #include "BLI_math_matrix.h" @@ -1049,12 +1051,12 @@ static uint mirror_facehash(const void *ptr) uint v0, v1; if (mf->v4) { - v0 = MIN4(mf->v1, mf->v2, mf->v3, mf->v4); - v1 = MAX4(mf->v1, mf->v2, mf->v3, mf->v4); + v0 = std::min({mf->v1, mf->v2, mf->v3, mf->v4}); + v1 = std::max({mf->v1, mf->v2, mf->v3, mf->v4}); } else { - v0 = MIN3(mf->v1, mf->v2, mf->v3); - v1 = MAX3(mf->v1, mf->v2, mf->v3); + v0 = std::min({mf->v1, mf->v2, mf->v3}); + v1 = std::min({mf->v1, mf->v2, mf->v3}); } return ((v0 * 39) ^ (v1 * 31)); diff --git a/source/blender/editors/physics/particle_edit.cc b/source/blender/editors/physics/particle_edit.cc index c3b06b3c762..3ce666f2fc2 100644 --- a/source/blender/editors/physics/particle_edit.cc +++ b/source/blender/editors/physics/particle_edit.cc @@ -6,6 +6,7 @@ * \ingroup edphys */ +#include #include #include #include @@ -4637,7 +4638,7 @@ static int brush_add(const bContext *C, PEData *data, short number) mul_v3_fl(key3[0].co, weight[0]); /* TODO: interpolating the weight would be nicer */ - thkey->weight = (ppa->hair + MIN2(k, ppa->totkey - 1))->weight; + thkey->weight = (ppa->hair + std::min(k, ppa->totkey - 1))->weight; if (maxw > 1) { key3[1].time = key3[0].time; diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index c6ace64a283..3c49a45e2f4 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -8,6 +8,7 @@ /* global includes */ +#include #include #include #include @@ -1383,8 +1384,8 @@ static void icon_copy_rect(ImBuf *ibuf, uint w, uint h, uint *rect) } /* Scaling down must never assign zero width/height, see: #89868. */ - ex = MAX2(1, short(scaledx)); - ey = MAX2(1, short(scaledy)); + ex = std::max(short(1), short(scaledx)); + ey = std::max(short(1), short(scaledy)); dx = (w - ex) / 2; dy = (h - ey) / 2; diff --git a/source/blender/editors/screen/screen_edit.cc b/source/blender/editors/screen/screen_edit.cc index 0a068a24da6..3bffdc3e62c 100644 --- a/source/blender/editors/screen/screen_edit.cc +++ b/source/blender/editors/screen/screen_edit.cc @@ -286,8 +286,8 @@ eScreenDir area_getorientation(ScrArea *sa_a, ScrArea *sa_b) short overlapy = std::min(top_a, top_b) - std::max(bottom_a, bottom_b); /* Minimum overlap required. */ - const short minx = MIN3(AREAJOINTOLERANCEX, right_a - left_a, right_b - left_b); - const short miny = MIN3(AREAJOINTOLERANCEY, top_a - bottom_a, top_b - bottom_b); + const short minx = std::min({int(AREAJOINTOLERANCEX), right_a - left_a, right_b - left_b}); + const short miny = std::min({int(AREAJOINTOLERANCEY), top_a - bottom_a, top_b - bottom_b}); if (top_a == bottom_b && overlapx >= minx) { return eScreenDir(1); /* sa_a to bottom of sa_b = N */ diff --git a/source/blender/editors/screen/screen_geometry.cc b/source/blender/editors/screen/screen_geometry.cc index 712d9efa671..08dd4c9072b 100644 --- a/source/blender/editors/screen/screen_geometry.cc +++ b/source/blender/editors/screen/screen_geometry.cc @@ -84,7 +84,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map, if (screen_geom_edge_is_horizontal(se)) { if ((se->v1->vec.y > bounds_rect->ymin) && (se->v1->vec.y < (bounds_rect->ymax - 1))) { short min, max; - min = MIN2(se->v1->vec.x, se->v2->vec.x); + min = std::min(se->v1->vec.x, se->v2->vec.x); max = std::max(se->v1->vec.x, se->v2->vec.x); if (abs(my - se->v1->vec.y) <= safety && mx >= min && mx <= max) { @@ -95,7 +95,7 @@ ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map, else { if ((se->v1->vec.x > bounds_rect->xmin) && (se->v1->vec.x < (bounds_rect->xmax - 1))) { short min, max; - min = MIN2(se->v1->vec.y, se->v2->vec.y); + min = std::min(se->v1->vec.y, se->v2->vec.y); max = std::max(se->v1->vec.y, se->v2->vec.y); if (abs(mx - se->v1->vec.x) <= safety && my >= min && my <= max) { diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.cc b/source/blender/editors/sculpt_paint/paint_image_2d.cc index ef192a7216d..4ec5527136d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.cc +++ b/source/blender/editors/sculpt_paint/paint_image_2d.cc @@ -692,7 +692,7 @@ static void brush_painter_2d_refresh_cache(ImagePaintState *s, Brush *brush = painter->brush; BrushPainterCache *cache = &tile->cache; /* Adding 4 pixels of padding for brush anti-aliasing. */ - const int diameter = MAX2(1, size * 2) + 4; + const int diameter = std::max(1, int(size * 2)) + 4; bool do_random = false; bool do_partial_update = false; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index d54964050da..92493a2e737 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -7,6 +7,7 @@ * \brief Functions to paint images in 2D and 3D. */ +#include #include #include #include @@ -1375,7 +1376,7 @@ static void uv_image_outset(const ProjPaintState *ps, len_fact = UNLIKELY(len_fact < FLT_EPSILON) ? FLT_MAX : (1.0f / len_fact); /* Clamp the length factor, see: #62236. */ - len_fact = MIN2(len_fact, 10.0f); + len_fact = std::min(len_fact, 10.0f); mul_v2_fl(no, ps->seam_bleed_px * len_fact); diff --git a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc index 9d28a15550a..4e58d7a45b9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_brush_types.cc +++ b/source/blender/editors/sculpt_paint/sculpt_brush_types.cc @@ -799,10 +799,10 @@ static void calc_clay_surface_task_cb(Object *ob, float plane_dist = dist_signed_to_plane_v3(vd.co, plane); float plane_dist_abs = fabsf(plane_dist); if (plane_dist > 0.0f) { - csd->plane_dist[0] = MIN2(csd->plane_dist[0], plane_dist_abs); + csd->plane_dist[0] = std::min(csd->plane_dist[0], plane_dist_abs); } else { - csd->plane_dist[1] = MIN2(csd->plane_dist[1], plane_dist_abs); + csd->plane_dist[1] = std::min(csd->plane_dist[1], plane_dist_abs); } BKE_pbvh_vertex_iter_end; } diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index 0fbe15aefe0..b70e682fd3e 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -311,7 +311,7 @@ static void file_draw_tooltip_custom_func(bContext * /*C*/, uiTooltipData *tip, } if (thumb && params->display != FILE_IMGDISPLAY) { - float scale = (96.0f * UI_SCALE_FAC) / float(MAX2(thumb->x, thumb->y)); + float scale = (96.0f * UI_SCALE_FAC) / float(std::max(thumb->x, thumb->y)); short size[2] = {short(float(thumb->x) * scale), short(float(thumb->y) * scale)}; UI_tooltip_text_field_add(tip, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL); UI_tooltip_text_field_add(tip, {}, {}, UI_TIP_STYLE_SPACER, UI_TIP_LC_NORMAL); @@ -1281,7 +1281,8 @@ void file_draw_list(const bContext *C, ARegion *region) if (do_drag) { const uiStyle *style = UI_style_get(); const int str_width = UI_fontstyle_string_width(&style->widget, file->name); - const int drag_width = MIN2(str_width + icon_ofs, column_width - ATTRIBUTE_COLUMN_PADDING); + const int drag_width = std::min(str_width + icon_ofs, + int(column_width - ATTRIBUTE_COLUMN_PADDING)); if (drag_width > 0) { uiBut *drag_but = uiDefBut(block, UI_BTYPE_LABEL, diff --git a/source/blender/editors/space_file/file_ops.cc b/source/blender/editors/space_file/file_ops.cc index ccd7ee7aaf0..80fb292f8f7 100644 --- a/source/blender/editors/space_file/file_ops.cc +++ b/source/blender/editors/space_file/file_ops.cc @@ -792,7 +792,7 @@ static bool file_walk_select_selection_set(bContext *C, /* do the actual selection */ if (fill) { - FileSelection sel = {MIN2(active, last_sel), MAX2(active, last_sel)}; + FileSelection sel = {std::min(active, last_sel), std::max(active, last_sel)}; /* fill selection between last and first selected file */ filelist_entries_select_index_range_set( diff --git a/source/blender/editors/space_file/fsmenu.cc b/source/blender/editors/space_file/fsmenu.cc index 7af53b59189..1d1c324d466 100644 --- a/source/blender/editors/space_file/fsmenu.cc +++ b/source/blender/editors/space_file/fsmenu.cc @@ -6,6 +6,7 @@ * \ingroup spfile */ +#include #include #include #include @@ -163,7 +164,7 @@ static void fsmenu_entry_generate_name(FSMenuEntry *fsentry, char *name, size_t len += 1; } - BLI_strncpy(name, &fsentry->path[offset], MIN2(len, name_size)); + BLI_strncpy(name, &fsentry->path[offset], std::min(size_t(len), name_size)); if (!name[0]) { name[0] = '/'; name[1] = '\0'; diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 19bb4b8ff39..efee9e7b260 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -998,7 +998,7 @@ static void node_update_hidden(bNode &node, uiBlock &block) } float hiddenrad = HIDDEN_RAD; - float tot = MAX2(totin, totout); + float tot = std::max(totin, totout); if (tot > 4) { hiddenrad += 5.0f * float(tot - 4); } diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index c71b3754188..19b544437a8 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -91,7 +91,7 @@ static void outliner_tree_dimensions_impl(SpaceOutliner *space_outliner, int *height) { LISTBASE_FOREACH (TreeElement *, te, lb) { - *width = MAX2(*width, te->xend); + *width = std::max(*width, int(te->xend)); if (height != nullptr) { *height += UI_UNIT_Y; } diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 081d7dd5f85..0a36afe996f 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -6,6 +6,7 @@ * \ingroup spoutliner */ +#include #include #include @@ -691,7 +692,7 @@ static void outliner_restore_scrolling_position(SpaceOutliner *space_outliner, int ys_new = te_new->ys; int ys_old = focus->ys; - float y_move = MIN2(ys_new - ys_old, -v2d->cur.ymax); + float y_move = std::min(float(ys_new - ys_old), -v2d->cur.ymax); BLI_rctf_translate(&v2d->cur, 0, y_move); } else { diff --git a/source/blender/editors/space_outliner/outliner_utils.cc b/source/blender/editors/space_outliner/outliner_utils.cc index aec0803bacc..ac652558b66 100644 --- a/source/blender/editors/space_outliner/outliner_utils.cc +++ b/source/blender/editors/space_outliner/outliner_utils.cc @@ -6,6 +6,7 @@ * \ingroup spoutliner */ +#include #include #include "BLI_listbase.h" @@ -421,7 +422,7 @@ void outliner_scroll_view(SpaceOutliner *space_outliner, ARegion *region, int de { int tree_width, tree_height; outliner_tree_dimensions(space_outliner, &tree_width, &tree_height); - int y_min = MIN2(region->v2d.cur.ymin, -tree_height); + int y_min = std::min(int(region->v2d.cur.ymin), -tree_height); region->v2d.cur.ymax += delta_y; region->v2d.cur.ymin += delta_y; diff --git a/source/blender/editors/space_text/text_draw.cc b/source/blender/editors/space_text/text_draw.cc index 0f41bbaef53..7b57806d7bf 100644 --- a/source/blender/editors/space_text/text_draw.cc +++ b/source/blender/editors/space_text/text_draw.cc @@ -6,6 +6,8 @@ * \ingroup sptext */ +#include + #include "MEM_guardedalloc.h" #include "BLF_api.h" @@ -271,7 +273,7 @@ void space_text_wrap_offset( while (chars--) { if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); if (chop && linep == linein && i >= cursin) { if (i == cursin) { @@ -348,7 +350,7 @@ void space_text_wrap_offset_in_line( while (chars--) { if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); if (chop && i >= cursin) { if (i == cursin) { @@ -939,7 +941,7 @@ static void calc_text_rcts(SpaceText *st, ARegion *region, rcti *scroll, rcti *b st, region, static_cast(st->text->lines.first), st->text->curl); sell_off = space_text_get_span_wrap( st, region, static_cast(st->text->lines.first), st->text->sell); - lhlstart = MIN2(curl_off, sell_off); + lhlstart = std::min(curl_off, sell_off); lhlend = std::max(curl_off, sell_off); if (ltexth > 0) { @@ -1672,7 +1674,7 @@ void space_text_update_character_width(SpaceText *st) text_font_begin(&tdc); st->runtime->cwidth_px = BLF_fixed_width(tdc.font_id); - st->runtime->cwidth_px = MAX2(st->runtime->cwidth_px, char(1)); + st->runtime->cwidth_px = std::max(st->runtime->cwidth_px, 1); text_font_end(&tdc); } diff --git a/source/blender/editors/space_text/text_ops.cc b/source/blender/editors/space_text/text_ops.cc index 47025682e07..61fe9b96a45 100644 --- a/source/blender/editors/space_text/text_ops.cc +++ b/source/blender/editors/space_text/text_ops.cc @@ -6,6 +6,7 @@ * \ingroup sptext */ +#include #include #include #include @@ -1790,7 +1791,7 @@ static int space_text_get_cursor_rel( curs = j; } if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); if (found) { /* exact cursor position was found, check if it's */ @@ -1985,7 +1986,7 @@ static void txt_wrap_move_bol(SpaceText *st, ARegion *region, const bool sel) while (chars--) { if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); *charp = endj; @@ -2072,7 +2073,7 @@ static void txt_wrap_move_eol(SpaceText *st, ARegion *region, const bool sel) while (chars--) { if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); if (chop) { endj = BLI_str_find_prev_char_utf8((*linep)->line + j, (*linep)->line) - (*linep)->line; @@ -3164,7 +3165,7 @@ static void space_text_cursor_set_to_pos_wrapped( curs = j; } if (i + columns - start > max) { - end = MIN2(end, i); + end = std::min(end, i); if (found) { /* exact cursor position was found, check if it's still on needed line diff --git a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc index 1d81b75d8b7..8198f2b5299 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc +++ b/source/blender/editors/space_view3d/view3d_gizmo_navigate_type.cc @@ -14,6 +14,8 @@ * - matrix_offset: used to store the orientation. */ +#include + #include "MEM_guardedalloc.h" #include "BLI_math_matrix.h" @@ -225,12 +227,12 @@ static void gizmo_axis_draw(const bContext *C, wmGizmo *gz) if (is_aligned_front) { interp_v4_v4v4( negative_color, blender::float4{1.0f, 1.0f, 1.0f, 1.0f}, axis_color[axis], 0.5f); - negative_color[3] = MIN2(depth + 1, 1.0f); + negative_color[3] = std::min(depth + 1, 1.0f); outline_color = negative_color; } else { interp_v4_v4v4(negative_color, view_color, axis_color[axis], 0.25f); - negative_color[3] = MIN2(depth + 1, 1.0f); + negative_color[3] = std::min(depth + 1, 1.0f); inner_color = negative_color; } } diff --git a/source/blender/editors/util/ed_util_imbuf.cc b/source/blender/editors/util/ed_util_imbuf.cc index 7ec839f98b5..ff93cc357ea 100644 --- a/source/blender/editors/util/ed_util_imbuf.cc +++ b/source/blender/editors/util/ed_util_imbuf.cc @@ -6,6 +6,8 @@ * \ingroup edutil */ +#include + #include "MEM_guardedalloc.h" #include "BLI_math_vector_types.hh" @@ -124,10 +126,10 @@ static void image_sample_rect_color_ubyte(const ImBuf *ibuf, } mul_v4_fl(r_col_linear, 1.0 / float(col_tot)); - r_col[0] = MIN2(col_accum_ub[0] / col_tot, 255); - r_col[1] = MIN2(col_accum_ub[1] / col_tot, 255); - r_col[2] = MIN2(col_accum_ub[2] / col_tot, 255); - r_col[3] = MIN2(col_accum_ub[3] / col_tot, 255); + r_col[0] = std::min(col_accum_ub[0] / col_tot, 255); + r_col[1] = std::min(col_accum_ub[1] / col_tot, 255); + r_col[2] = std::min(col_accum_ub[2] / col_tot, 255); + r_col[3] = std::min(col_accum_ub[3] / col_tot, 255); } static void image_sample_rect_color_float(ImBuf *ibuf, const rcti *rect, float r_col[4]) diff --git a/source/blender/geometry/intern/reverse_uv_sampler.cc b/source/blender/geometry/intern/reverse_uv_sampler.cc index c53ccb4cefe..fe1bb93d77c 100644 --- a/source/blender/geometry/intern/reverse_uv_sampler.cc +++ b/source/blender/geometry/intern/reverse_uv_sampler.cc @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include + #include "GEO_reverse_uv_sampler.hh" #include "BLI_math_geom.h" @@ -72,7 +74,7 @@ ReverseUVSampler::Result ReverseUVSampler::sample(const float2 &query_uv) const const float x_dist = std::max(-bary_weights.x, bary_weights.x - 1.0f); const float y_dist = std::max(-bary_weights.y, bary_weights.y - 1.0f); const float z_dist = std::max(-bary_weights.z, bary_weights.z - 1.0f); - const float dist = MAX3(x_dist, y_dist, z_dist); + const float dist = std::max({x_dist, y_dist, z_dist}); if (dist <= 0.0f && best_dist <= 0.0f) { const float worse_dist = std::max(dist, best_dist); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc index 0314cf68d0c..6715e3a330e 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_build.cc @@ -6,7 +6,7 @@ * \ingroup modifiers */ -#include /* For `min/max`. */ +#include #include #include #include @@ -809,7 +809,7 @@ static void generate_geometry(GpencilModifierData *md, if (gpf->next) { /* Use the next frame or upper bound as end frame, whichever is lower/closer */ - end_frame = MIN2(end_frame, gpf->next->framenum); + end_frame = std::min(end_frame, float(gpf->next->framenum)); } /* Early exit if current frame is outside start/end bounds */ diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc index 256366fb4ad..ba838550d5f 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.cc @@ -6,6 +6,7 @@ * \ingroup modifiers */ +#include #include #include @@ -143,7 +144,7 @@ static bool stroke_dash(const bGPDstroke *gps, continue; } - const int size = MIN2(gps->totpoints - new_stroke_offset, seg); + const int size = std::min(gps->totpoints - new_stroke_offset, seg); if (size == 0) { continue; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc index e7546fd619e..32ce86ae53b 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_weight_proximity.cc @@ -108,8 +108,8 @@ static void deform_stroke(GpencilModifierData *md, return; } - const float dist_max = MAX2(mmd->dist_start, mmd->dist_end); - const float dist_min = MIN2(mmd->dist_start, mmd->dist_end); + const float dist_max = std::max(mmd->dist_start, mmd->dist_end); + const float dist_min = std::min(mmd->dist_start, mmd->dist_end); const int target_def_nr = BKE_object_defgroup_name_index(ob, mmd->target_vgname); if (target_def_nr == -1) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h index 891b4c6431e..e9882aed214 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/MOD_lineart.h @@ -13,6 +13,7 @@ #include "BLI_math_vector.h" #include "BLI_threads.h" +#include #include #ifdef __cplusplus @@ -743,7 +744,7 @@ BLI_INLINE int lineart_intersect_seg_seg(const double a1[2], if (LRT_DOUBLE_CLOSE_ENOUGH(b1[0], b2[0])) { y = interpd(a2[1], a1[1], ratio); - if (y > MAX2(b1[1], b2[1]) || y < MIN2(b1[1], b2[1])) { + if (y > std::max(b1[1], b2[1]) || y < std::min(b1[1], b2[1])) { return 0; } } diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc index 3e1e72aa9da..7028b7bf092 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_chain.cc @@ -1372,7 +1372,7 @@ void MOD_lineart_chain_offset_towards_camera(LineartData *ld, float dist, bool u sub_v3_v3v3(dir, cam, eci->gpos); float orig_len = len_v3(dir); normalize_v3(dir); - mul_v3_fl(dir, MIN2(dist, orig_len - ld->conf.near_clip)); + mul_v3_fl(dir, std::min(dist, orig_len - ld->conf.near_clip)); add_v3_v3(eci->gpos, dir); } } diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc index 35e8ce7e168..533cb576dc5 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_cpu.cc @@ -6,6 +6,8 @@ * \ingroup editors */ +#include + #include "MOD_gpencil_legacy_lineart.h" #include "MOD_lineart.h" @@ -344,7 +346,7 @@ void lineart_edge_cut(LineartData *ld, continue; } - min_occ = MIN2(min_occ, seg->occlusion); + min_occ = std::min(min_occ, seg->occlusion); prev_seg = seg; } @@ -2843,11 +2845,11 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t *FBC1 = tri->v[1]->fbcoord, *FBC2 = tri->v[2]->fbcoord; /* Overlapping not possible, return early. */ - if ((MAX3(FBC0[0], FBC1[0], FBC2[0]) < MIN2(LFBC[0], RFBC[0])) || - (MIN3(FBC0[0], FBC1[0], FBC2[0]) > MAX2(LFBC[0], RFBC[0])) || - (MAX3(FBC0[1], FBC1[1], FBC2[1]) < MIN2(LFBC[1], RFBC[1])) || - (MIN3(FBC0[1], FBC1[1], FBC2[1]) > MAX2(LFBC[1], RFBC[1])) || - (MIN3(FBC0[3], FBC1[3], FBC2[3]) > MAX2(LFBC[3], RFBC[3]))) + if ((std::max({FBC0[0], FBC1[0], FBC2[0]}) < std::min(LFBC[0], RFBC[0])) || + (std::min({FBC0[0], FBC1[0], FBC2[0]}) > std::max(LFBC[0], RFBC[0])) || + (std::max({FBC0[1], FBC1[1], FBC2[1]}) < std::min(LFBC[1], RFBC[1])) || + (std::min({FBC0[1], FBC1[1], FBC2[1]}) > std::max(LFBC[1], RFBC[1])) || + (std::min({FBC0[3], FBC1[3], FBC2[3]}) > std::max(LFBC[3], RFBC[3]))) { return false; } @@ -3067,8 +3069,8 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t /* Determine the start and end point of image space cut on a line. */ if (dot_1f <= 0 && dot_2f <= 0 && (dot_v1 || dot_v2)) { - *from = MAX2(0, cross_ratios[cross_v1]); - *to = MIN2(1, cross_ratios[cross_v2]); + *from = std::max(0.0, cross_ratios[cross_v1]); + *to = std::min(1.0, cross_ratios[cross_v2]); if (*from >= *to) { return false; } @@ -3076,14 +3078,14 @@ static bool lineart_triangle_edge_image_space_occlusion(const LineartTriangle *t } if (dot_1f >= 0 && dot_2f <= 0 && (dot_v1 || dot_v2)) { *from = std::max(cut, cross_ratios[cross_v1]); - *to = MIN2(1, cross_ratios[cross_v2]); + *to = std::min(1.0, cross_ratios[cross_v2]); if (*from >= *to) { return false; } return true; } if (dot_1f <= 0 && dot_2f >= 0 && (dot_v1 || dot_v2)) { - *from = MAX2(0, cross_ratios[cross_v1]); + *from = std::max(0.0, cross_ratios[cross_v1]); *to = std::min(cut, cross_ratios[cross_v2]); if (*from >= *to) { return false; @@ -3346,7 +3348,7 @@ static bool lineart_schedule_new_triangle_task(LineartIsecThread *th) while (remaining > 0 && eln) { int remaining_this_eln = eln->element_count - ld->isect_scheduled_up_to_index; - int added_count = MIN2(remaining, remaining_this_eln); + int added_count = std::min(remaining, remaining_this_eln); remaining -= added_count; if (remaining || added_count == remaining_this_eln) { eln = eln->next; @@ -3441,12 +3443,12 @@ static void lineart_triangle_intersect_in_bounding_area(LineartTriangle *tri, *RG2 = testing_triangle->v[2]->gloc; /* Bounding box not overlapping or triangles share edges, not potential of intersecting. */ - if ((MIN3(G0[2], G1[2], G2[2]) > MAX3(RG0[2], RG1[2], RG2[2])) || - (MAX3(G0[2], G1[2], G2[2]) < MIN3(RG0[2], RG1[2], RG2[2])) || - (MIN3(G0[0], G1[0], G2[0]) > MAX3(RG0[0], RG1[0], RG2[0])) || - (MAX3(G0[0], G1[0], G2[0]) < MIN3(RG0[0], RG1[0], RG2[0])) || - (MIN3(G0[1], G1[1], G2[1]) > MAX3(RG0[1], RG1[1], RG2[1])) || - (MAX3(G0[1], G1[1], G2[1]) < MIN3(RG0[1], RG1[1], RG2[1])) || + if ((std::min({G0[2], G1[2], G2[2]}) > std::max({RG0[2], RG1[2], RG2[2]})) || + (std::max({G0[2], G1[2], G2[2]}) < std::min({RG0[2], RG1[2], RG2[2]})) || + (std::min({G0[0], G1[0], G2[0]}) > std::max({RG0[0], RG1[0], RG2[0]})) || + (std::max({G0[0], G1[0], G2[0]}) < std::min({RG0[0], RG1[0], RG2[0]})) || + (std::min({G0[1], G1[1], G2[1]}) > std::max({RG0[1], RG1[1], RG2[1]})) || + (std::max({G0[1], G1[1], G2[1]}) < std::min({RG0[1], RG1[1], RG2[1]})) || lineart_triangle_share_edge(tri, testing_triangle)) { continue; @@ -4029,10 +4031,10 @@ static void lineart_bounding_area_split(LineartData *ld, LineartTriangle *tri = root->linked_triangles[i]; double b[4]; - b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[2] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); - b[3] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); + b[0] = std::min({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[1] = std::max({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[2] = std::max({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); + b[3] = std::min({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); /* Re-link triangles into child tiles, not doing intersection lines during this because this * batch of triangles are all tested with each other for intersections. */ @@ -4068,8 +4070,9 @@ static bool lineart_bounding_area_edge_intersect(LineartData * /*fb*/, double converted[4]; double c1, c; - if (((converted[0] = ba->l) > MAX2(l[0], r[0])) || ((converted[1] = ba->r) < MIN2(l[0], r[0])) || - ((converted[2] = ba->b) > MAX2(l[1], r[1])) || + if (((converted[0] = ba->l) > std::max(l[0], r[0])) || + ((converted[1] = ba->r) < std::min(l[0], r[0])) || + ((converted[2] = ba->b) > std::max(l[1], r[1])) || ((converted[3] = ba->u) < std::min(l[1], r[1]))) { return false; @@ -4177,10 +4180,10 @@ static void lineart_bounding_area_link_triangle(LineartData *ld, double *B1 = l_r_u_b; double b[4]; if (!l_r_u_b) { - b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[2] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); - b[3] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); + b[0] = std::min({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[1] = std::max({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[2] = std::max({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); + b[3] = std::min({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); B1 = b; } for (int iba = 0; iba < 4; iba++) { @@ -4409,10 +4412,10 @@ static bool lineart_get_triangle_bounding_areas( return false; } - b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]); - b[2] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); - b[3] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]); + b[0] = std::min({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[1] = std::max({tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]}); + b[2] = std::min({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); + b[3] = std::max({tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]}); if (b[0] > 1 || b[1] < -1 || b[2] > 1 || b[3] < -1) { return false; @@ -4453,9 +4456,9 @@ static bool lineart_get_edge_bounding_areas( return false; } - b[0] = MIN2(e->v1->fbcoord[0], e->v2->fbcoord[0]); + b[0] = std::min(e->v1->fbcoord[0], e->v2->fbcoord[0]); b[1] = std::max(e->v1->fbcoord[0], e->v2->fbcoord[0]); - b[2] = MIN2(e->v1->fbcoord[1], e->v2->fbcoord[1]); + b[2] = std::min(e->v1->fbcoord[1], e->v2->fbcoord[1]); b[3] = std::max(e->v1->fbcoord[1], e->v2->fbcoord[1]); if (b[0] > 1 || b[1] < -1 || b[2] > 1 || b[3] < -1) { @@ -4799,7 +4802,7 @@ LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *self, ux = x + (uy - y) / k; r1 = ratiod(fbcoord1[0], fbcoord2[0], rx); r2 = ratiod(fbcoord1[0], fbcoord2[0], ux); - if (MIN2(r1, r2) > 1) { + if (std::min(r1, r2) > 1) { return nullptr; } @@ -4832,7 +4835,7 @@ LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *self, bx = x + (by - y) / k; r1 = ratiod(fbcoord1[0], fbcoord2[0], rx); r2 = ratiod(fbcoord1[0], fbcoord2[0], bx); - if (MIN2(r1, r2) > 1) { + if (std::min(r1, r2) > 1) { return nullptr; } if (r1 <= r2) { @@ -4884,7 +4887,7 @@ LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *self, ux = x + (uy - y) / k; r1 = ratiod(fbcoord1[0], fbcoord2[0], lx); r2 = ratiod(fbcoord1[0], fbcoord2[0], ux); - if (MIN2(r1, r2) > 1) { + if (std::min(r1, r2) > 1) { return nullptr; } if (r1 <= r2) { @@ -4915,7 +4918,7 @@ LineartBoundingArea *lineart_bounding_area_next(LineartBoundingArea *self, bx = x + (by - y) / k; r1 = ratiod(fbcoord1[0], fbcoord2[0], lx); r2 = ratiod(fbcoord1[0], fbcoord2[0], bx); - if (MIN2(r1, r2) > 1) { + if (std::min(r1, r2) > 1) { return nullptr; } if (r1 <= r2) { diff --git a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc index eec9a8594e8..8382603be90 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc +++ b/source/blender/gpencil_modifiers_legacy/intern/lineart/lineart_shadow.cc @@ -736,10 +736,10 @@ static bool lineart_shadow_cast_onto_triangle(LineartData *ld, /* Bound box check. Because we have already done occlusion in the shadow camera, so any visual * intersection found in this function must mean that the triangle is behind the given line so it * will always project a shadow, hence no need to do depth bound-box check. */ - if ((MAX3(FBC0[0], FBC1[0], FBC2[0]) < MIN2(LFBC[0], RFBC[0])) || - (MIN3(FBC0[0], FBC1[0], FBC2[0]) > MAX2(LFBC[0], RFBC[0])) || - (MAX3(FBC0[1], FBC1[1], FBC2[1]) < MIN2(LFBC[1], RFBC[1])) || - (MIN3(FBC0[1], FBC1[1], FBC2[1]) > MAX2(LFBC[1], RFBC[1]))) + if ((std::max({FBC0[0], FBC1[0], FBC2[0]}) < std::min(LFBC[0], RFBC[0])) || + (std::min({FBC0[0], FBC1[0], FBC2[0]}) > std::max(LFBC[0], RFBC[0])) || + (std::max({FBC0[1], FBC1[1], FBC2[1]}) < std::min(LFBC[1], RFBC[1])) || + (std::min({FBC0[1], FBC1[1], FBC2[1]}) > std::max(LFBC[1], RFBC[1]))) { return false; } diff --git a/source/blender/gpu/intern/gpu_index_buffer.cc b/source/blender/gpu/intern/gpu_index_buffer.cc index 4b3103dbbe1..162f7cc3f20 100644 --- a/source/blender/gpu/intern/gpu_index_buffer.cc +++ b/source/blender/gpu/intern/gpu_index_buffer.cc @@ -186,8 +186,8 @@ void GPU_indexbuf_set_line_verts(GPUIndexBufBuilder *builder, uint elem, uint v1 uint idx = elem * 2; builder->data[idx++] = v1; builder->data[idx++] = v2; - builder->index_min = MIN3(builder->index_min, v1, v2); - builder->index_max = MAX3(builder->index_max, v1, v2); + builder->index_min = std::min({builder->index_min, v1, v2}); + builder->index_max = std::max({builder->index_max, v1, v2}); builder->index_len = std::max(builder->index_len, idx); } @@ -204,8 +204,8 @@ void GPU_indexbuf_set_tri_verts(GPUIndexBufBuilder *builder, uint elem, uint v1, builder->data[idx++] = v2; builder->data[idx++] = v3; - builder->index_min = MIN4(builder->index_min, v1, v2, v3); - builder->index_max = MAX4(builder->index_max, v1, v2, v3); + builder->index_min = std::min({builder->index_min, v1, v2, v3}); + builder->index_max = std::max({builder->index_max, v1, v2, v3}); builder->index_len = std::max(builder->index_len, idx); } @@ -390,7 +390,7 @@ void IndexBuf::squeeze_indices_short(uint min_idx, 0xFFFFu : (max_idx - min_idx); for (uint i = 0; i < index_len_; i++) { - ushort_idx[i] = uint16_t(MIN2(clamp_max_idx, uint_idx[i] - min_idx)); + ushort_idx[i] = std::min(clamp_max_idx, uint_idx[i] - min_idx); } } else { diff --git a/source/blender/gpu/intern/gpu_material.cc b/source/blender/gpu/intern/gpu_material.cc index 99700c62a8e..4d4c8652f75 100644 --- a/source/blender/gpu/intern/gpu_material.cc +++ b/source/blender/gpu/intern/gpu_material.cc @@ -8,6 +8,7 @@ * Manages materials, lights and textures. */ +#include #include #include @@ -433,8 +434,8 @@ static void compute_sss_kernel(GPUSssKernelData *kd, const float radii[3], int s { float rad[3]; /* Minimum radius */ - rad[0] = MAX2(radii[0], 1e-15f); - rad[1] = MAX2(radii[1], 1e-15f); + rad[0] = std::max(radii[0], 1e-15f); + rad[1] = std::max(radii[1], 1e-15f); rad[2] = std::max(radii[2], 1e-15f); kd->avg_inv_radius = 3.0f / (rad[0] + rad[1] + rad[2]); @@ -448,7 +449,7 @@ static void compute_sss_kernel(GPUSssKernelData *kd, const float radii[3], int s /* XXX 0.6f Out of nowhere to match cycles! Empirical! Can be tweak better. */ mul_v3_v3fl(d, l, 0.6f / s); mul_v3_v3fl(rad, d, BURLEY_TRUNCATE); - kd->max_radius = MAX3(rad[0], rad[1], rad[2]); + kd->max_radius = std::max({rad[0], rad[1], rad[2]}); copy_v3_v3(kd->param, d); diff --git a/source/blender/ikplugin/intern/iksolver_plugin.cc b/source/blender/ikplugin/intern/iksolver_plugin.cc index 9f573b58356..4a658cffa62 100644 --- a/source/blender/ikplugin/intern/iksolver_plugin.cc +++ b/source/blender/ikplugin/intern/iksolver_plugin.cc @@ -6,6 +6,8 @@ * \ingroup ikplugin */ +#include + #include "MEM_guardedalloc.h" #include "BIK_api.h" @@ -142,11 +144,11 @@ static void initialize_posetree(Object * /*ob*/, bPoseChannel *pchan_tip) BLI_addtail(&pchan_root->iktree, tree); } else { - tree->iterations = MAX2(data->iterations, tree->iterations); + tree->iterations = std::max(data->iterations, tree->iterations); tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); /* Skip common pose channels and add remaining. */ - const int size = MIN2(segcount, tree->totchannel); + const int size = std::min(segcount, tree->totchannel); int a, t; a = t = 0; while (a < size && t < tree->totchannel) { diff --git a/source/blender/ikplugin/intern/itasc_plugin.cc b/source/blender/ikplugin/intern/itasc_plugin.cc index 5ec04ac7fd4..545ddc379bc 100644 --- a/source/blender/ikplugin/intern/itasc_plugin.cc +++ b/source/blender/ikplugin/intern/itasc_plugin.cc @@ -6,6 +6,7 @@ * \ingroup ikplugin */ +#include #include #include #include @@ -299,11 +300,11 @@ static int initialize_chain(Object *ob, bPoseChannel *pchan_tip, bConstraint *co treecount = 1; } else { - tree->iterations = MAX2(data->iterations, tree->iterations); + tree->iterations = std::max(data->iterations, tree->iterations); tree->stretch = tree->stretch && !(data->flag & CONSTRAINT_IK_STRETCH); /* Skip common pose channels and add remaining. */ - size = MIN2(segcount, tree->totchannel); + size = std::min(segcount, tree->totchannel); a = t = 0; while (a < size && t < tree->totchannel) { /* locate first matching channel */ diff --git a/source/blender/imbuf/CMakeLists.txt b/source/blender/imbuf/CMakeLists.txt index 69facb59ea6..82094cfcaf7 100644 --- a/source/blender/imbuf/CMakeLists.txt +++ b/source/blender/imbuf/CMakeLists.txt @@ -191,6 +191,10 @@ if(WIN32) ) endif() +if(WIN32) + add_definitions(-DNOMINMAX) +endif() + # no need to compile object files for inline headers. set_source_files_properties( intern/colormanagement_inline.cc diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc index 330a9d78523..2a1e4b87177 100644 --- a/source/blender/imbuf/intern/anim_movie.cc +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -1050,7 +1050,7 @@ static int match_format(const char *name, AVFormatContext *pFormatCtx) namelen = strlen(name); while ((p = strchr(names, ','))) { - len = MAX2(p - names, namelen); + len = std::max(int(p - names), namelen); if (!BLI_strncasecmp(name, names, len)) { return 1; } @@ -1174,7 +1174,7 @@ static int ffmpeg_generic_seek_workaround(anim *anim, /* Step backward frame by frame until we find the key frame we are looking for. */ while (current_pts != 0) { current_pts = *requested_pts - int64_t(round(offset * ffmpeg_steps_per_frame_get(anim))); - current_pts = MAX2(current_pts, 0); + current_pts = std::max(current_pts, int64_t(0)); /* Seek to timestamp. */ if (av_seek_frame(anim->pFormatCtx, anim->videoStream, current_pts, AVSEEK_FLAG_BACKWARD) < 0) diff --git a/source/blender/imbuf/intern/jpeg.cc b/source/blender/imbuf/intern/jpeg.cc index 82d8f43322f..61a4b91bcb2 100644 --- a/source/blender/imbuf/intern/jpeg.cc +++ b/source/blender/imbuf/intern/jpeg.cc @@ -7,6 +7,7 @@ */ /* This little block needed for linking to Blender... */ +#include #include #include @@ -428,7 +429,7 @@ static ImBuf *ibJpegImageFromCinfo( } ibuf->ftype = IMB_FTYPE_JPG; - ibuf->foptions.quality = MIN2(ibuf_quality, 100); + ibuf->foptions.quality = std::min(ibuf_quality, 100); } jpeg_destroy((j_common_ptr)cinfo); } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 7823950f49e..e6f627c096c 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -2260,7 +2260,7 @@ ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath, for (int w = 0; w < dest_w; w++) { /* For each destination pixel find single corresponding source pixel. */ - int source_x = int(MIN2((w / scale_factor), dw.max.x - 1)); + int source_x = int(std::min((w / scale_factor), dw.max.x - 1)); float *dest_px = &ibuf->float_buffer.data[(h * dest_w + w) * 4]; dest_px[0] = pixels[source_x].r; dest_px[1] = pixels[source_x].g; diff --git a/source/blender/imbuf/intern/stereoimbuf.cc b/source/blender/imbuf/intern/stereoimbuf.cc index 114aac9747a..8aaf1b835ee 100644 --- a/source/blender/imbuf/intern/stereoimbuf.cc +++ b/source/blender/imbuf/intern/stereoimbuf.cc @@ -6,6 +6,7 @@ * \ingroup imbuf */ +#include #include #include "IMB_imbuf.hh" @@ -100,7 +101,7 @@ static void imb_stereo3d_write_anaglyph(const Stereo3DData *s3d, enum eStereo3dA to[0] = from[r][0]; to[1] = from[g][1]; to[2] = from[b][2]; - to[3] = MAX2(from[0][3], from[1][3]); + to[3] = std::max(from[0][3], from[1][3]); } } } diff --git a/source/blender/imbuf/intern/thumbs.cc b/source/blender/imbuf/intern/thumbs.cc index d5ccdba87b6..4aa16b373b9 100644 --- a/source/blender/imbuf/intern/thumbs.cc +++ b/source/blender/imbuf/intern/thumbs.cc @@ -6,6 +6,7 @@ * \ingroup imbuf */ +#include #include #include @@ -412,10 +413,10 @@ static ImBuf *thumb_create_ex(const char *file_path, } if (img->x > tsize || img->y > tsize) { - float scale = MIN2(float(tsize) / float(img->x), float(tsize) / float(img->y)); + float scale = std::min(float(tsize) / float(img->x), float(tsize) / float(img->y)); /* Scaling down must never assign zero width/height, see: #89868. */ - short ex = MAX2(1, short(img->x * scale)); - short ey = MAX2(1, short(img->y * scale)); + short ex = std::max(short(1), short(img->x * scale)); + short ey = std::max(short(1), short(img->y * scale)); /* Save some time by only scaling byte buffer. */ if (img->float_buffer.data) { if (img->byte_buffer.data == nullptr) { diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc index a9b884ee3e6..686c82dfadc 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_pdf.cc @@ -6,6 +6,8 @@ * \ingroup bgpencil */ +#include + #include "BLI_math_color.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" @@ -245,7 +247,7 @@ void GpencilExporterPDF::export_stroke_to_polyline(bGPDlayer *gpl, HPDF_Page_SetLineJoin(page_, HPDF_ROUND_JOIN); const float defined_width = (gps->thickness * avg_pressure) + gpl->line_change; const float estimated_width = (radius * 2.0f) + gpl->line_change; - const float final_width = (avg_pressure == 1.0f) ? MAX2(defined_width, estimated_width) : + const float final_width = (avg_pressure == 1.0f) ? std::max(defined_width, estimated_width) : estimated_width; HPDF_Page_SetLineWidth(page_, std::max(final_width, 1.0f)); } diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 4921b003c32..6ecb1c40167 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -6,6 +6,8 @@ * \ingroup bgpencil */ +#include + #include "BLI_math_color.h" #include "BLI_math_matrix.h" #include "BLI_math_vector.h" @@ -313,7 +315,7 @@ void GpencilExporterSVG::export_stroke_to_polyline(bGPDlayer *gpl, if (is_stroke && !do_fill) { const float defined_width = (gps->thickness * avg_pressure) + gpl->line_change; const float estimated_width = (radius * 2.0f) + gpl->line_change; - const float final_width = (avg_pressure == 1.0f) ? MAX2(defined_width, estimated_width) : + const float final_width = (avg_pressure == 1.0f) ? std::max(defined_width, estimated_width) : estimated_width; node_gps.append_attribute("stroke-width").set_value(std::max(final_width, 1.0f)); } diff --git a/source/blender/makesdna/intern/dna_genfile.cc b/source/blender/makesdna/intern/dna_genfile.cc index 20e224968cc..6247701516c 100644 --- a/source/blender/makesdna/intern/dna_genfile.cc +++ b/source/blender/makesdna/intern/dna_genfile.cc @@ -12,6 +12,7 @@ * SDNA and the SDNA of the current (running) version of Blender. */ +#include #include #include #include @@ -1328,7 +1329,7 @@ static void init_reconstruct_step_for_member(const SDNA *oldsdna, const int new_array_length = newsdna->names_array_len[new_member->name]; const int old_array_length = oldsdna->names_array_len[old_member->name]; - const int shared_array_length = MIN2(new_array_length, old_array_length); + const int shared_array_length = std::min(new_array_length, old_array_length); const char *new_type_name = newsdna->types[new_member->type]; const char *old_type_name = oldsdna->types[old_member->type]; diff --git a/source/blender/makesdna/intern/makesdna.cc b/source/blender/makesdna/intern/makesdna.cc index 38f9bdcfdcc..1f103abf706 100644 --- a/source/blender/makesdna/intern/makesdna.cc +++ b/source/blender/makesdna/intern/makesdna.cc @@ -26,6 +26,7 @@ #define DNA_DEPRECATED_ALLOW +#include #include #include #include @@ -1042,8 +1043,8 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char size_native += sizeof(void *) * mul; size_32 += 4 * mul; size_64 += 8 * mul; - max_align_32 = MAX2(max_align_32, 4); - max_align_64 = MAX2(max_align_64, 8); + max_align_32 = std::max(max_align_32, 4); + max_align_64 = std::max(max_align_64, 8); } else if (cp[0] == '[') { /* parsing can cause names "var" and "[3]" @@ -1097,8 +1098,8 @@ static int calculate_struct_sizes(int firststruct, FILE *file_verify, const char size_native += mul * types_size_native[type]; size_32 += mul * types_size_32[type]; size_64 += mul * types_size_64[type]; - max_align_32 = MAX2(max_align_32, types_align_32[type]); - max_align_64 = MAX2(max_align_64, types_align_64[type]); + max_align_32 = std::max(max_align_32, types_align_32[type]); + max_align_64 = std::max(max_align_64, types_align_64[type]); } else { size_native = 0; diff --git a/source/blender/makesrna/intern/makesrna.cc b/source/blender/makesrna/intern/makesrna.cc index 722c71e053c..1d0193670c2 100644 --- a/source/blender/makesrna/intern/makesrna.cc +++ b/source/blender/makesrna/intern/makesrna.cc @@ -6,6 +6,7 @@ * \ingroup RNA */ +#include #include #include #include @@ -85,7 +86,7 @@ static const char *path_basename(const char *path) lfslash++; } - return MAX3(path, lfslash, lbslash); + return std::max({path, lfslash, lbslash}); } /* forward declarations */ diff --git a/source/blender/makesrna/intern/rna_action.cc b/source/blender/makesrna/intern/rna_action.cc index 93803e36d00..d723edd0c54 100644 --- a/source/blender/makesrna/intern/rna_action.cc +++ b/source/blender/makesrna/intern/rna_action.cc @@ -30,6 +30,8 @@ #ifdef RNA_RUNTIME +# include + # include "BLI_math_base.h" # include "BKE_fcurve.h" @@ -224,7 +226,7 @@ static void rna_Action_active_pose_marker_set(PointerRNA *ptr, static int rna_Action_active_pose_marker_index_get(PointerRNA *ptr) { bAction *act = (bAction *)ptr->data; - return MAX2(act->active_marker - 1, 0); + return std::max(act->active_marker - 1, 0); } static void rna_Action_active_pose_marker_index_set(PointerRNA *ptr, int value) diff --git a/source/blender/makesrna/intern/rna_animation.cc b/source/blender/makesrna/intern/rna_animation.cc index e57082cd685..fd7f6e3b328 100644 --- a/source/blender/makesrna/intern/rna_animation.cc +++ b/source/blender/makesrna/intern/rna_animation.cc @@ -87,6 +87,8 @@ const EnumPropertyItem rna_enum_keying_flag_api_items[] = { #ifdef RNA_RUNTIME +# include + # include "BLI_math_base.h" # include "BKE_anim_data.h" @@ -503,7 +505,7 @@ static void rna_KeyingSet_active_ksPath_set(PointerRNA *ptr, static int rna_KeyingSet_active_ksPath_index_get(PointerRNA *ptr) { KeyingSet *ks = (KeyingSet *)ptr->data; - return MAX2(ks->active_path - 1, 0); + return std::max(ks->active_path - 1, 0); } static void rna_KeyingSet_active_ksPath_index_set(PointerRNA *ptr, int value) diff --git a/source/blender/makesrna/intern/rna_armature.cc b/source/blender/makesrna/intern/rna_armature.cc index 480f4535e70..0599559fd4a 100644 --- a/source/blender/makesrna/intern/rna_armature.cc +++ b/source/blender/makesrna/intern/rna_armature.cc @@ -1459,7 +1459,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_update(prop, 0, "rna_Armature_update_data"); } RNA_def_property_float_sdna(prop, nullptr, "rad_head"); - /* XXX: range is 0 to limit, where `limit = 10000.0f * MAX2(1.0, view3d->grid)`. */ + /* XXX: range is 0 to limit, where `limit = 10000.0f * std::max(1.0, view3d->grid)`. */ // RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text( @@ -1473,7 +1473,7 @@ static void rna_def_bone_common(StructRNA *srna, int editbone) RNA_def_property_update(prop, 0, "rna_Armature_update_data"); } RNA_def_property_float_sdna(prop, nullptr, "rad_tail"); - /* XXX range is 0 to limit, where limit = `10000.0f * MAX2(1.0, view3d->grid)`. */ + /* XXX range is 0 to limit, where limit = `10000.0f * std::max(1.0, view3d->grid)`. */ // RNA_def_property_range(prop, 0, 1000); RNA_def_property_ui_range(prop, 0.01, 100, 0.1, 3); RNA_def_property_ui_text( diff --git a/source/blender/makesrna/intern/rna_asset.cc b/source/blender/makesrna/intern/rna_asset.cc index 34a7b7cc37b..1fd05dd3ba4 100644 --- a/source/blender/makesrna/intern/rna_asset.cc +++ b/source/blender/makesrna/intern/rna_asset.cc @@ -41,6 +41,8 @@ const EnumPropertyItem rna_enum_asset_library_type_items[] = { #ifdef RNA_RUNTIME +# include + # include "AS_asset_library.h" # include "AS_asset_representation.hh" @@ -307,7 +309,7 @@ static void rna_AssetMetaData_active_tag_range( { const AssetMetaData *asset_data = static_cast(ptr->data); *min = *softmin = 0; - *max = *softmax = MAX2(asset_data->tot_tags - 1, 0); + *max = *softmax = std::max(int(asset_data->tot_tags - 1), 0); } static void rna_AssetMetaData_catalog_id_get(PointerRNA *ptr, char *value) diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc index 31fbf3f7480..464894c9aa9 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc +++ b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.cc @@ -271,6 +271,8 @@ static const EnumPropertyItem modifier_noise_random_mode_items[] = { #ifdef RNA_RUNTIME +# include + # include "DNA_curve_types.h" # include "DNA_fluid_types.h" # include "DNA_material_types.h" @@ -488,7 +490,7 @@ static void rna_TimeModifier_start_frame_set(PointerRNA *ptr, int value) tmd->sfra = value; if (tmd->sfra >= tmd->efra) { - tmd->efra = MIN2(tmd->sfra, MAXFRAME); + tmd->efra = std::min(tmd->sfra, MAXFRAME); } } @@ -499,7 +501,7 @@ static void rna_TimeModifier_end_frame_set(PointerRNA *ptr, int value) tmd->efra = value; if (tmd->sfra >= tmd->efra) { - tmd->sfra = MAX2(tmd->efra, MINFRAME); + tmd->sfra = std::max(tmd->efra, MINFRAME); } } @@ -795,7 +797,7 @@ static void rna_Lineart_start_level_set(PointerRNA *ptr, int value) CLAMP(value, 0, 128); lmd->level_start = value; - lmd->level_end = MAX2(value, lmd->level_end); + lmd->level_end = std::max(value, lmd->level_end); } static void rna_Lineart_end_level_set(PointerRNA *ptr, int value) @@ -804,7 +806,7 @@ static void rna_Lineart_end_level_set(PointerRNA *ptr, int value) CLAMP(value, 0, 128); lmd->level_end = value; - lmd->level_start = MIN2(value, lmd->level_start); + lmd->level_start = std::min(value, lmd->level_start); } static void rna_GpencilDash_segments_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_key.cc b/source/blender/makesrna/intern/rna_key.cc index 27773b862ff..08f282ff491 100644 --- a/source/blender/makesrna/intern/rna_key.cc +++ b/source/blender/makesrna/intern/rna_key.cc @@ -38,6 +38,7 @@ const EnumPropertyItem rna_enum_keyblock_type_items[] = { #ifdef RNA_RUNTIME +# include # include # include "DNA_object_types.h" @@ -491,11 +492,11 @@ static void rna_ShapeKey_NurbInfo_step(NurbInfo *r_info, rna_ShapeKey_NurbInfo_init(r_info, nu); if (input_elem) { - r_info->nurb_index = MIN2(r_info->nurb_size, *p_raw_index / r_info->nurb_elem_step); + r_info->nurb_index = std::min(r_info->nurb_size, *p_raw_index / r_info->nurb_elem_step); *p_raw_index -= r_info->nurb_size * r_info->nurb_elem_step; } else { - r_info->nurb_index = MIN2(r_info->nurb_size, *p_raw_index); + r_info->nurb_index = std::min(r_info->nurb_size, *p_raw_index); *p_raw_index -= r_info->nurb_size; } diff --git a/source/blender/makesrna/intern/rna_mask.cc b/source/blender/makesrna/intern/rna_mask.cc index be870ac103d..5244f2c8194 100644 --- a/source/blender/makesrna/intern/rna_mask.cc +++ b/source/blender/makesrna/intern/rna_mask.cc @@ -35,6 +35,8 @@ #ifdef RNA_RUNTIME +# include + # include "DNA_movieclip_types.h" # include "BKE_mask.h" @@ -461,7 +463,7 @@ static void rna_Mask_start_frame_set(PointerRNA *ptr, int value) data->sfra = value; if (data->sfra >= data->efra) { - data->efra = MIN2(data->sfra, MAXFRAME); + data->efra = std::min(data->sfra, MAXFRAME); } } @@ -472,7 +474,7 @@ static void rna_Mask_end_frame_set(PointerRNA *ptr, int value) data->efra = value; if (data->sfra >= data->efra) { - data->sfra = MAX2(data->efra, MINFRAME); + data->sfra = std::max(data->efra, MINFRAME); } } diff --git a/source/blender/makesrna/intern/rna_mesh_utils.hh b/source/blender/makesrna/intern/rna_mesh_utils.hh index e2b867d0035..f56a99eb3c0 100644 --- a/source/blender/makesrna/intern/rna_mesh_utils.hh +++ b/source/blender/makesrna/intern/rna_mesh_utils.hh @@ -53,7 +53,7 @@ *max = data ? CustomData_number_of_layers(data, layer_type) - \ CustomData_number_of_anonymous_layers(data, layer_type) - 1 : \ 0; \ - *max = MAX2(0, *max); \ + *max = std::max(0, *max); \ } /* Define the accessors for special CustomDataLayers in the collection diff --git a/source/blender/makesrna/intern/rna_object.cc b/source/blender/makesrna/intern/rna_object.cc index eb80ed94e87..6c212f01ebf 100644 --- a/source/blender/makesrna/intern/rna_object.cc +++ b/source/blender/makesrna/intern/rna_object.cc @@ -314,6 +314,8 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { #ifdef RNA_RUNTIME +# include + # include "DNA_ID.h" # include "DNA_constraint_types.h" # include "DNA_gpencil_legacy_types.h" @@ -1096,7 +1098,7 @@ void rna_object_vcollayer_name_set(PointerRNA *ptr, static int rna_Object_active_material_index_get(PointerRNA *ptr) { Object *ob = reinterpret_cast(ptr->owner_id); - return MAX2(ob->actcol - 1, 0); + return std::max(ob->actcol - 1, 0); } static void rna_Object_active_material_index_set(PointerRNA *ptr, int value) @@ -1544,7 +1546,7 @@ static int rna_Object_active_shape_key_index_get(PointerRNA *ptr) { Object *ob = reinterpret_cast(ptr->owner_id); - return MAX2(ob->shapenr - 1, 0); + return std::max(ob->shapenr - 1, 0); } static void rna_Object_active_shape_key_index_set(PointerRNA *ptr, int value) diff --git a/source/blender/makesrna/intern/rna_scene.cc b/source/blender/makesrna/intern/rna_scene.cc index 008ce861099..647609d13a4 100644 --- a/source/blender/makesrna/intern/rna_scene.cc +++ b/source/blender/makesrna/intern/rna_scene.cc @@ -707,6 +707,8 @@ const EnumPropertyItem rna_enum_grease_pencil_selectmode_items[] = { #ifdef RNA_RUNTIME +# include + # include "BLI_string_utils.hh" # include "DNA_anim_types.h" @@ -1053,7 +1055,7 @@ static void rna_Scene_start_frame_set(PointerRNA *ptr, int value) data->r.sfra = value; if (value > data->r.efra) { - data->r.efra = MIN2(value, MAXFRAME); + data->r.efra = std::min(value, MAXFRAME); } } @@ -1064,7 +1066,7 @@ static void rna_Scene_end_frame_set(PointerRNA *ptr, int value) data->r.efra = value; if (data->r.sfra > value) { - data->r.sfra = MAX2(value, MINFRAME); + data->r.sfra = std::max(value, MINFRAME); } } @@ -1100,7 +1102,7 @@ static void rna_Scene_preview_range_start_frame_set(PointerRNA *ptr, int value) data->r.psfra = value; if (value > data->r.pefra) { - data->r.pefra = MIN2(value, MAXFRAME); + data->r.pefra = std::min(value, MAXFRAME); } } @@ -1118,7 +1120,7 @@ static void rna_Scene_preview_range_end_frame_set(PointerRNA *ptr, int value) data->r.pefra = value; if (data->r.psfra > value) { - data->r.psfra = MAX2(value, MINAFRAME); + data->r.psfra = std::max(value, MINAFRAME); } } diff --git a/source/blender/makesrna/intern/rna_sequencer.cc b/source/blender/makesrna/intern/rna_sequencer.cc index 773cac5650a..decdf2abd20 100644 --- a/source/blender/makesrna/intern/rna_sequencer.cc +++ b/source/blender/makesrna/intern/rna_sequencer.cc @@ -111,6 +111,8 @@ const EnumPropertyItem rna_enum_strip_color_items[] = { #ifdef RNA_RUNTIME +# include + # include "BKE_global.h" # include "BKE_idprop.h" # include "BKE_movieclip.h" @@ -501,7 +503,7 @@ static void rna_Sequence_anim_startofs_final_set(PointerRNA *ptr, int value) Sequence *seq = (Sequence *)ptr->data; Scene *scene = (Scene *)ptr->owner_id; - seq->anim_startofs = MIN2(value, seq->len + seq->anim_startofs); + seq->anim_startofs = std::min(value, seq->len + seq->anim_startofs); SEQ_add_reload_new_file(G.main, scene, seq, false); do_sequence_frame_change_update(scene, seq); @@ -512,7 +514,7 @@ static void rna_Sequence_anim_endofs_final_set(PointerRNA *ptr, int value) Sequence *seq = (Sequence *)ptr->data; Scene *scene = (Scene *)ptr->owner_id; - seq->anim_endofs = MIN2(value, seq->len + seq->anim_endofs); + seq->anim_endofs = std::min(value, seq->len + seq->anim_endofs); SEQ_add_reload_new_file(G.main, scene, seq, false); do_sequence_frame_change_update(scene, seq); diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.cc b/source/blender/modifiers/intern/MOD_surfacedeform.cc index d932e3277f5..cd8568d92ea 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.cc +++ b/source/blender/modifiers/intern/MOD_surfacedeform.cc @@ -1367,7 +1367,7 @@ static void deformVert(void *__restrict userdata, int max_verts = 0; for (int j = 0; j < sdbind_num; j++) { - max_verts = MAX2(max_verts, sdbind[j].verts_num); + max_verts = std::max(max_verts, int(sdbind[j].verts_num)); } /* Allocate a `coords_buffer` that fits all the temp-data. */ diff --git a/source/blender/python/generic/idprop_py_api.cc b/source/blender/python/generic/idprop_py_api.cc index db8c2c673fe..99c0f5a3f90 100644 --- a/source/blender/python/generic/idprop_py_api.cc +++ b/source/blender/python/generic/idprop_py_api.cc @@ -6,6 +6,8 @@ * \ingroup pygen */ +#include + #include #include "MEM_guardedalloc.h" @@ -1900,7 +1902,7 @@ static PyObject *BPy_IDArray_slice(BPy_IDArray *self, int begin, int end) end = prop->len + end + 1; } CLAMP(end, 0, prop->len); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); @@ -1949,7 +1951,7 @@ static int BPy_IDArray_ass_slice(BPy_IDArray *self, int begin, int end, PyObject CLAMP(begin, 0, prop->len); CLAMP(end, 0, prop->len); - begin = MIN2(begin, end); + begin = std::min(begin, end); size = (end - begin); alloc_len = size * elem_size; diff --git a/source/blender/python/generic/idprop_py_ui_api.cc b/source/blender/python/generic/idprop_py_ui_api.cc index 3494d7f7971..75fe1ddbfb8 100644 --- a/source/blender/python/generic/idprop_py_ui_api.cc +++ b/source/blender/python/generic/idprop_py_ui_api.cc @@ -501,12 +501,12 @@ static bool idprop_ui_data_update_float(IDProperty *idprop, PyObject *args, PyOb } if (args_contain_key(kwargs, "soft_min")) { ui_data.soft_min = soft_min; - ui_data.soft_min = MAX2(ui_data.soft_min, ui_data.min); + ui_data.soft_min = std::max(ui_data.soft_min, ui_data.min); ui_data.soft_max = std::max(ui_data.soft_min, ui_data.soft_max); } if (args_contain_key(kwargs, "soft_max")) { ui_data.soft_max = soft_max; - ui_data.soft_max = MIN2(ui_data.soft_max, ui_data.max); + ui_data.soft_max = std::min(ui_data.soft_max, ui_data.max); ui_data.soft_min = std::min(ui_data.soft_min, ui_data.soft_max); } if (args_contain_key(kwargs, "step")) { diff --git a/source/blender/python/intern/bpy_props.cc b/source/blender/python/intern/bpy_props.cc index 8b1d6557023..d6e549aaa15 100644 --- a/source/blender/python/intern/bpy_props.cc +++ b/source/blender/python/intern/bpy_props.cc @@ -13,6 +13,8 @@ /* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */ #define PY_SSIZE_T_CLEAN +#include + #include #include "RNA_types.hh" @@ -3268,7 +3270,7 @@ static PyObject *BPy_IntProperty(PyObject *self, PyObject *args, PyObject *kw) RNA_def_property_translation_context(prop, translation_context); } RNA_def_property_range(prop, min, max); - RNA_def_property_ui_range(prop, std::max(soft_min, min), MIN2(soft_max, max), step, 3); + RNA_def_property_ui_range(prop, std::max(soft_min, min), std::min(soft_max, max), step, 3); if (tags_enum.base.is_set) { RNA_def_property_tags(prop, tags_enum.base.value); @@ -3467,7 +3469,7 @@ static PyObject *BPy_IntVectorProperty(PyObject *self, PyObject *args, PyObject if (translation_context) { RNA_def_property_translation_context(prop, translation_context); } - RNA_def_property_ui_range(prop, std::max(soft_min, min), MIN2(soft_max, max), step, 3); + RNA_def_property_ui_range(prop, std::max(soft_min, min), std::min(soft_max, max), step, 3); if (tags_enum.base.is_set) { RNA_def_property_tags(prop, tags_enum.base.value); @@ -3643,7 +3645,8 @@ static PyObject *BPy_FloatProperty(PyObject *self, PyObject *args, PyObject *kw) if (translation_context) { RNA_def_property_translation_context(prop, translation_context); } - RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); + RNA_def_property_ui_range( + prop, std::max(soft_min, min), std::min(soft_max, max), step, precision); if (tags_enum.base.is_set) { RNA_def_property_tags(prop, tags_enum.base.value); @@ -3859,7 +3862,8 @@ static PyObject *BPy_FloatVectorProperty(PyObject *self, PyObject *args, PyObjec if (translation_context) { RNA_def_property_translation_context(prop, translation_context); } - RNA_def_property_ui_range(prop, MAX2(soft_min, min), MIN2(soft_max, max), step, precision); + RNA_def_property_ui_range( + prop, std::max(soft_min, min), std::min(soft_max, max), step, precision); if (tags_enum.base.is_set) { RNA_def_property_tags(prop, tags_enum.base.value); diff --git a/source/blender/python/mathutils/mathutils_Color.cc b/source/blender/python/mathutils/mathutils_Color.cc index 5f6cb997047..03f60079f3e 100644 --- a/source/blender/python/mathutils/mathutils_Color.cc +++ b/source/blender/python/mathutils/mathutils_Color.cc @@ -6,6 +6,8 @@ * \ingroup pymathutils */ +#include + #include #include "mathutils.h" @@ -431,7 +433,7 @@ static PyObject *Color_slice(ColorObject *self, int begin, int end) end = (COLOR_SIZE + 1) + end; } CLAMP(end, 0, COLOR_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { @@ -456,7 +458,7 @@ static int Color_ass_slice(ColorObject *self, int begin, int end, PyObject *seq) end = (COLOR_SIZE + 1) + end; } CLAMP(end, 0, COLOR_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); if ((size = mathutils_array_parse(col, 0, COLOR_SIZE, seq, "mathutils.Color[begin:end] = []")) == -1) diff --git a/source/blender/python/mathutils/mathutils_Euler.cc b/source/blender/python/mathutils/mathutils_Euler.cc index 6baea906683..c148ce38e2b 100644 --- a/source/blender/python/mathutils/mathutils_Euler.cc +++ b/source/blender/python/mathutils/mathutils_Euler.cc @@ -6,6 +6,8 @@ * \ingroup pymathutils */ +#include + #include #include "mathutils.h" @@ -517,7 +519,7 @@ static PyObject *Euler_slice(EulerObject *self, int begin, int end) end = (EULER_SIZE + 1) + end; } CLAMP(end, 0, EULER_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { @@ -542,7 +544,7 @@ static int Euler_ass_slice(EulerObject *self, int begin, int end, PyObject *seq) end = (EULER_SIZE + 1) + end; } CLAMP(end, 0, EULER_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); if ((size = mathutils_array_parse(eul, 0, EULER_SIZE, seq, "mathutils.Euler[begin:end] = []")) == -1) diff --git a/source/blender/python/mathutils/mathutils_Matrix.cc b/source/blender/python/mathutils/mathutils_Matrix.cc index 4d7a9c93250..c4f64ec71bc 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.cc +++ b/source/blender/python/mathutils/mathutils_Matrix.cc @@ -6,6 +6,8 @@ * \ingroup pymathutils */ +#include + #include #include "mathutils.h" @@ -2508,7 +2510,7 @@ static PyObject *Matrix_slice(MatrixObject *self, int begin, int end) CLAMP(begin, 0, self->row_num); CLAMP(end, 0, self->row_num); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { @@ -2532,7 +2534,7 @@ static int Matrix_ass_slice(MatrixObject *self, int begin, int end, PyObject *va CLAMP(begin, 0, self->row_num); CLAMP(end, 0, self->row_num); - begin = MIN2(begin, end); + begin = std::min(begin, end); /* non list/tuple cases */ if (!(value_fast = PySequence_Fast(value, "matrix[begin:end] = value"))) { diff --git a/source/blender/python/mathutils/mathutils_Quaternion.cc b/source/blender/python/mathutils/mathutils_Quaternion.cc index 9ac93931eec..0eb6f7d9de2 100644 --- a/source/blender/python/mathutils/mathutils_Quaternion.cc +++ b/source/blender/python/mathutils/mathutils_Quaternion.cc @@ -6,6 +6,8 @@ * \ingroup pymathutils */ +#include + #include #include "mathutils.h" @@ -969,7 +971,7 @@ static PyObject *Quaternion_slice(QuaternionObject *self, int begin, int end) end = (QUAT_SIZE + 1) + end; } CLAMP(end, 0, QUAT_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { @@ -994,7 +996,7 @@ static int Quaternion_ass_slice(QuaternionObject *self, int begin, int end, PyOb end = (QUAT_SIZE + 1) + end; } CLAMP(end, 0, QUAT_SIZE); - begin = MIN2(begin, end); + begin = std::min(begin, end); if ((size = mathutils_array_parse( quat, 0, QUAT_SIZE, seq, "mathutils.Quaternion[begin:end] = []")) == -1) diff --git a/source/blender/python/mathutils/mathutils_Vector.cc b/source/blender/python/mathutils/mathutils_Vector.cc index f38943c3361..34aa68ce8df 100644 --- a/source/blender/python/mathutils/mathutils_Vector.cc +++ b/source/blender/python/mathutils/mathutils_Vector.cc @@ -6,6 +6,8 @@ * \ingroup pymathutils */ +#include + #include #include "mathutils.h" @@ -1782,7 +1784,7 @@ static PyObject *Vector_slice(VectorObject *self, int begin, int end) end = self->vec_num + end + 1; } CLAMP(end, 0, self->vec_num); - begin = MIN2(begin, end); + begin = std::min(begin, end); tuple = PyTuple_New(end - begin); for (count = begin; count < end; count++) { @@ -1804,7 +1806,7 @@ static int Vector_ass_slice(VectorObject *self, int begin, int end, PyObject *se CLAMP(begin, 0, self->vec_num); CLAMP(end, 0, self->vec_num); - begin = MIN2(begin, end); + begin = std::min(begin, end); vec_num = (end - begin); if (mathutils_array_parse_alloc(&vec, vec_num, seq, "vector[begin:end] = [...]") == -1) { diff --git a/source/blender/render/intern/texture_image.cc b/source/blender/render/intern/texture_image.cc index a9d48b33831..ec564dd0e72 100644 --- a/source/blender/render/intern/texture_image.cc +++ b/source/blender/render/intern/texture_image.cc @@ -6,6 +6,7 @@ * \ingroup render */ +#include #include #include #include @@ -1035,7 +1036,7 @@ static int imagewraposa_aniso(Tex *tex, if (tex->imaflag & TEX_FILTER_MIN) { /* Make sure the filtersize is minimal in pixels * (normal, ref map can have miniature pixel dx/dy). */ - const float addval = (0.5f * tex->filtersize) / float(MIN2(ibuf->x, ibuf->y)); + const float addval = (0.5f * tex->filtersize) / float(std::min(ibuf->x, ibuf->y)); if (addval > minx) { minx = addval; } @@ -1438,7 +1439,7 @@ int imagewraposa(Tex *tex, if (tex->imaflag & TEX_FILTER_MIN) { /* Make sure the filtersize is minimal in pixels * (normal, ref map can have miniature pixel dx/dy). */ - float addval = (0.5f * tex->filtersize) / float(MIN2(ibuf->x, ibuf->y)); + float addval = (0.5f * tex->filtersize) / float(std::min(ibuf->x, ibuf->y)); if (addval > minx) { minx = addval; @@ -1641,7 +1642,7 @@ int imagewraposa(Tex *tex, maxd = 0.5f; } - pixsize = 1.0f / float(MIN2(ibuf->x, ibuf->y)); + pixsize = 1.0f / float(std::min(ibuf->x, ibuf->y)); curmap = 0; previbuf = curibuf = ibuf; @@ -1651,7 +1652,7 @@ int imagewraposa(Tex *tex, } previbuf = curibuf; curibuf = ibuf->mipmap[curmap]; - pixsize = 1.0f / float(MIN2(curibuf->x, curibuf->y)); + pixsize = 1.0f / float(std::min(curibuf->x, curibuf->y)); curmap++; } diff --git a/source/blender/sequencer/intern/sound.cc b/source/blender/sequencer/intern/sound.cc index c99086388eb..b551551aa76 100644 --- a/source/blender/sequencer/intern/sound.cc +++ b/source/blender/sequencer/intern/sound.cc @@ -8,6 +8,7 @@ * \ingroup bke */ +#include #include #include @@ -63,7 +64,7 @@ static bool sequencer_refresh_sound_length_recursive(Main *bmain, Scene *scene, int old = seq->len; float fac; - seq->len = MAX2(1, round((info.length - seq->sound->offset_time) * FPS)); + seq->len = std::max(1, int(round((info.length - seq->sound->offset_time) * FPS))); fac = float(seq->len) / float(old); old = seq->startofs; seq->startofs *= fac; diff --git a/source/blender/sequencer/intern/strip_add.cc b/source/blender/sequencer/intern/strip_add.cc index 3f63f32b44c..eba8243313a 100644 --- a/source/blender/sequencer/intern/strip_add.cc +++ b/source/blender/sequencer/intern/strip_add.cc @@ -8,6 +8,7 @@ * \ingroup bke */ +#include #include #include @@ -323,7 +324,7 @@ Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL * nearest frame as the audio track usually overshoots or undershoots the * end frame of the video by a little bit. * See #47135 for under shoot example. */ - seq->len = MAX2(1, round((info.length - sound->offset_time) * FPS)); + seq->len = std::max(1, int(round((info.length - sound->offset_time) * FPS))); Strip *strip = seq->strip; /* We only need 1 element to store the filename. */ diff --git a/source/blender/sequencer/intern/utils.cc b/source/blender/sequencer/intern/utils.cc index 577b8770220..c72c86fe515 100644 --- a/source/blender/sequencer/intern/utils.cc +++ b/source/blender/sequencer/intern/utils.cc @@ -8,6 +8,7 @@ * \ingroup bke */ +#include #include #include @@ -498,14 +499,14 @@ void SEQ_set_scale_to_fit(const Sequence *seq, switch (fit_method) { case SEQ_SCALE_TO_FIT: - transform->scale_x = transform->scale_y = MIN2(float(preview_width) / float(image_width), - float(preview_height) / float(image_height)); + transform->scale_x = transform->scale_y = std::min( + float(preview_width) / float(image_width), float(preview_height) / float(image_height)); break; case SEQ_SCALE_TO_FILL: - transform->scale_x = transform->scale_y = MAX2(float(preview_width) / float(image_width), - float(preview_height) / float(image_height)); + transform->scale_x = transform->scale_y = std::max( + float(preview_width) / float(image_width), float(preview_height) / float(image_height)); break; case SEQ_STRETCH_TO_FILL: transform->scale_x = float(preview_width) / float(image_width); diff --git a/source/blender/simulation/intern/implicit_blender.cc b/source/blender/simulation/intern/implicit_blender.cc index fed6298ec94..613e12ab0b4 100644 --- a/source/blender/simulation/intern/implicit_blender.cc +++ b/source/blender/simulation/intern/implicit_blender.cc @@ -1654,7 +1654,7 @@ BLI_INLINE void dfdx_damp(float to[3][3], // return (I - outerprod(dir, dir)) * (-damping * -(dot(dir, vel) / Max(length, rest))); mul_fvectorT_fvector(to, dir, dir); sub_fmatrix_fmatrix(to, I, to); - mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest)))); + mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / std::max(length, rest)))); } # endif diff --git a/source/blender/simulation/intern/implicit_eigen.cc b/source/blender/simulation/intern/implicit_eigen.cc index eb49a4eb16c..6bf489d53cd 100644 --- a/source/blender/simulation/intern/implicit_eigen.cc +++ b/source/blender/simulation/intern/implicit_eigen.cc @@ -873,7 +873,7 @@ BLI_INLINE void dfdx_damp(float to[3][3], // return (I - outerprod(dir, dir)) * (-damping * -(dot(dir, vel) / Max(length, rest))); mul_fvectorT_fvector(to, dir, dir); sub_fmatrix_fmatrix(to, I, to); - mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / MAX2(length, rest)))); + mul_fmatrix_S(to, (-damping * -(dot_v3v3(dir, vel) / std::max(length, rest)))); } # endif diff --git a/source/blender/windowmanager/intern/wm_operators.cc b/source/blender/windowmanager/intern/wm_operators.cc index 4d2e1d66dfc..6173b0d8137 100644 --- a/source/blender/windowmanager/intern/wm_operators.cc +++ b/source/blender/windowmanager/intern/wm_operators.cc @@ -9,6 +9,7 @@ * as well as some generic operators and shared operator properties. */ +#include #include #include #include @@ -1245,18 +1246,18 @@ static uiBlock *wm_block_confirm_create(bContext *C, ARegion *region, void *arg_ UI_block_flag_enable(block, block_flags); const uiStyle *style = UI_style_get_dpi(); - int text_width = MAX2( + int text_width = std::max( 120 * UI_SCALE_FAC, BLF_width(style->widget.uifont_id, confirm.title, ARRAY_SIZE(confirm.title))); if (confirm.message[0]) { - text_width = MAX2( + text_width = std::max( text_width, - BLF_width(style->widget.uifont_id, confirm.message, ARRAY_SIZE(confirm.message))); + int(BLF_width(style->widget.uifont_id, confirm.message, ARRAY_SIZE(confirm.message)))); } if (confirm.message2[0]) { - text_width = MAX2( + text_width = std::max( text_width, - BLF_width(style->widget.uifont_id, confirm.message2, ARRAY_SIZE(confirm.message2))); + int(BLF_width(style->widget.uifont_id, confirm.message2, ARRAY_SIZE(confirm.message2)))); } const bool small = confirm.size == WM_WARNING_SIZE_SMALL; diff --git a/source/blender/windowmanager/intern/wm_splash_screen.cc b/source/blender/windowmanager/intern/wm_splash_screen.cc index c034fe3222e..6958544c74d 100644 --- a/source/blender/windowmanager/intern/wm_splash_screen.cc +++ b/source/blender/windowmanager/intern/wm_splash_screen.cc @@ -14,6 +14,7 @@ * - Links to web sites. */ +#include #include #include "CLG_log.h" @@ -181,7 +182,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void * /*ar UI_block_flag_enable(block, UI_BLOCK_LOOP | UI_BLOCK_KEEP_OPEN | UI_BLOCK_NO_WIN_CLIP); UI_block_theme_style_set(block, UI_BLOCK_THEME_STYLE_POPUP); - const int text_points_max = MAX2(style->widget.points, style->widgetlabel.points); + const int text_points_max = std::max(style->widget.points, style->widgetlabel.points); int splash_width = text_points_max * 45 * UI_SCALE_FAC; CLAMP_MAX(splash_width, CTX_wm_window(C)->sizex * 0.7f); int splash_height;