From 38ed95fe8d6f4c47c0c5f09ffecc987d75150dcc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 4 Mar 2020 11:31:51 +1100 Subject: Cleanup: replace CLAMP macros with functions --- source/blender/blenkernel/intern/colorband.c | 5 +---- source/blender/compositor/operations/COM_MixOperation.h | 5 +---- source/blender/draw/intern/draw_cache_extract_mesh.c | 3 +-- source/blender/editors/sculpt_paint/paint_ops.c | 3 +-- source/blender/editors/sculpt_paint/paint_utils.c | 5 +---- source/blender/editors/space_sequencer/sequencer_scopes.c | 4 +--- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 3 +-- source/blender/imbuf/intern/imageprocess.c | 5 +---- source/blender/python/mathutils/mathutils_Color.c | 5 +---- source/blender/render/intern/source/multires_bake.c | 9 +++------ 10 files changed, 12 insertions(+), 35 deletions(-) (limited to 'source/blender') diff --git a/source/blender/blenkernel/intern/colorband.c b/source/blender/blenkernel/intern/colorband.c index 8701f06d9dd..dd45d42d230 100644 --- a/source/blender/blenkernel/intern/colorband.c +++ b/source/blender/blenkernel/intern/colorband.c @@ -519,10 +519,7 @@ bool BKE_colorband_evaluate(const ColorBand *coba, float in, float out[4]) out[1] = t[3] * cbd3->g + t[2] * cbd2->g + t[1] * cbd1->g + t[0] * cbd0->g; out[2] = t[3] * cbd3->b + t[2] * cbd2->b + t[1] * cbd1->b + t[0] * cbd0->b; out[3] = t[3] * cbd3->a + t[2] * cbd2->a + t[1] * cbd1->a + t[0] * cbd0->a; - CLAMP(out[0], 0.0f, 1.0f); - CLAMP(out[1], 0.0f, 1.0f); - CLAMP(out[2], 0.0f, 1.0f); - CLAMP(out[3], 0.0f, 1.0f); + clamp_v4(out, 0.0f, 1.0f); } else { if (ipotype == COLBAND_INTERP_EASE) { diff --git a/source/blender/compositor/operations/COM_MixOperation.h b/source/blender/compositor/operations/COM_MixOperation.h index fbf60fb9d37..cea0e59b541 100644 --- a/source/blender/compositor/operations/COM_MixOperation.h +++ b/source/blender/compositor/operations/COM_MixOperation.h @@ -39,10 +39,7 @@ class MixBaseOperation : public NodeOperation { inline void clampIfNeeded(float color[4]) { if (m_useClamp) { - CLAMP(color[0], 0.0f, 1.0f); - CLAMP(color[1], 0.0f, 1.0f); - CLAMP(color[2], 0.0f, 1.0f); - CLAMP(color[3], 0.0f, 1.0f); + clamp_v4(color, 0.0f, 1.0f); } } diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index 88cb3f95f2e..4045995e1e6 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -3296,8 +3296,7 @@ static void uv_from_jitter_v2(float uv[2]) uv[1] = 1.0f - uv[1]; } - CLAMP(uv[0], 0.0f, 1.0f); - CLAMP(uv[1], 0.0f, 1.0f); + clamp_v2(uv, 0.0f, 1.0f); } BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange) diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index e58183bfc0f..5d73eb4a6a2 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -682,8 +682,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2] if (scd->constrain_mode != STENCIL_CONSTRAINT_X) { mdiff[1] = factor * scd->init_sdim[1]; } - CLAMP(mdiff[0], 5.0f, 10000.0f); - CLAMP(mdiff[1], 5.0f, 10000.0f); + clamp_v2(mdiff, 5.0f, 10000.0f); copy_v2_v2(scd->dim_target, mdiff); break; } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 37cc543872e..19d890eeac3 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -202,10 +202,7 @@ void paint_get_tex_pixel_col(const MTex *mtex, linearrgb_to_srgb_v3_v3(rgba, rgba); - CLAMP(rgba[0], 0.0f, 1.0f); - CLAMP(rgba[1], 0.0f, 1.0f); - CLAMP(rgba[2], 0.0f, 1.0f); - CLAMP(rgba[3], 0.0f, 1.0f); + clamp_v4(rgba, 0.0f, 1.0f); } void paint_stroke_operator_properties(wmOperatorType *ot) diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index c55d77800ff..4d492d74e82 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -743,9 +743,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf) memcpy(rgb, src1, 3 * sizeof(float)); - CLAMP(rgb[0], 0.0f, 1.0f); - CLAMP(rgb[1], 0.0f, 1.0f); - CLAMP(rgb[2], 0.0f, 1.0f); + clamp_v3(rgb, 0.0f, 1.0f); rgb_to_yuv_normalized(rgb, yuv); diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index eb568acc0dd..fb48b1377f1 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1497,8 +1497,7 @@ static void uv_map_clip_correct_multi(const Scene *scene, BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - CLAMP(luv->uv[0], 0.0f, 1.0f); - CLAMP(luv->uv[1], 0.0f, 1.0f); + clamp_v2(luv->uv, 0.0f, 1.0f); } } } diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index ec03a0a07b8..6a234232a35 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -190,10 +190,7 @@ void bilinear_interpolation_color_wrap( outF[3] = ma_mb * row1[3] + a_mb * row3[3] + ma_b * row2[3] + a_b * row4[3]; /* clamp here or else we can easily get off-range */ - CLAMP(outF[0], 0.0f, 1.0f); - CLAMP(outF[1], 0.0f, 1.0f); - CLAMP(outF[2], 0.0f, 1.0f); - CLAMP(outF[3], 0.0f, 1.0f); + clamp_v4(outF, 0.0f, 1.0f); } if (outI) { /* sample including outside of edges of image */ diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 59bddf01cae..bf7fe0472d0 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -824,10 +824,7 @@ static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closur return -1; } - CLAMP(hsv[0], 0.0f, 1.0f); - CLAMP(hsv[1], 0.0f, 1.0f); - CLAMP(hsv[2], 0.0f, 1.0f); - + clamp_v3(hsv, 0.0f, 1.0f); hsv_to_rgb_v(hsv, self->col); if (BaseMath_WriteCallback(self) == -1) { diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index 6fe4c080c2b..5421f487de5 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -838,8 +838,7 @@ static void apply_heights_callback(DerivedMesh *lores_dm, resolve_tri_uv_v2(uv, st, st0, st1, st2); } - CLAMP(uv[0], 0.0f, 1.0f); - CLAMP(uv[1], 0.0f, 1.0f); + clamp_v2(uv, 0.0f, 1.0f); get_ccgdm_data( lores_dm, hires_dm, height_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], p1, NULL); @@ -951,8 +950,7 @@ static void apply_tangmat_callback(DerivedMesh *lores_dm, resolve_tri_uv_v2(uv, st, st0, st1, st2); } - CLAMP(uv[0], 0.0f, 1.0f); - CLAMP(uv[1], 0.0f, 1.0f); + clamp_v2(uv, 0.0f, 1.0f); get_ccgdm_data( lores_dm, hires_dm, normal_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], NULL, n); @@ -1219,8 +1217,7 @@ static void apply_ao_callback(DerivedMesh *lores_dm, resolve_tri_uv_v2(uv, st, st0, st1, st2); } - CLAMP(uv[0], 0.0f, 1.0f); - CLAMP(uv[1], 0.0f, 1.0f); + clamp_v2(uv, 0.0f, 1.0f); get_ccgdm_data( lores_dm, hires_dm, ao_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], pos, nrm); -- cgit v1.2.3