Cleanup: replace CLAMP macros with functions

This commit is contained in:
2020-03-04 11:31:51 +11:00
parent 89b10b8d42
commit 38ed95fe8d
10 changed files with 12 additions and 35 deletions

View File

@@ -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[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[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; 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_v4(out, 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);
} }
else { else {
if (ipotype == COLBAND_INTERP_EASE) { if (ipotype == COLBAND_INTERP_EASE) {

View File

@@ -39,10 +39,7 @@ class MixBaseOperation : public NodeOperation {
inline void clampIfNeeded(float color[4]) inline void clampIfNeeded(float color[4])
{ {
if (m_useClamp) { if (m_useClamp) {
CLAMP(color[0], 0.0f, 1.0f); clamp_v4(color, 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);
} }
} }

View File

@@ -3296,8 +3296,7 @@ static void uv_from_jitter_v2(float uv[2])
uv[1] = 1.0f - uv[1]; uv[1] = 1.0f - uv[1];
} }
CLAMP(uv[0], 0.0f, 1.0f); clamp_v2(uv, 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
} }
BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange) BLI_INLINE float thickness_remap(float fac, float min, float max, float minmax_irange)

View File

@@ -682,8 +682,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2]
if (scd->constrain_mode != STENCIL_CONSTRAINT_X) { if (scd->constrain_mode != STENCIL_CONSTRAINT_X) {
mdiff[1] = factor * scd->init_sdim[1]; mdiff[1] = factor * scd->init_sdim[1];
} }
CLAMP(mdiff[0], 5.0f, 10000.0f); clamp_v2(mdiff, 5.0f, 10000.0f);
CLAMP(mdiff[1], 5.0f, 10000.0f);
copy_v2_v2(scd->dim_target, mdiff); copy_v2_v2(scd->dim_target, mdiff);
break; break;
} }

View File

@@ -202,10 +202,7 @@ void paint_get_tex_pixel_col(const MTex *mtex,
linearrgb_to_srgb_v3_v3(rgba, rgba); linearrgb_to_srgb_v3_v3(rgba, rgba);
CLAMP(rgba[0], 0.0f, 1.0f); clamp_v4(rgba, 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);
} }
void paint_stroke_operator_properties(wmOperatorType *ot) void paint_stroke_operator_properties(wmOperatorType *ot)

View File

@@ -743,9 +743,7 @@ static ImBuf *make_vectorscope_view_from_ibuf_float(ImBuf *ibuf)
memcpy(rgb, src1, 3 * sizeof(float)); memcpy(rgb, src1, 3 * sizeof(float));
CLAMP(rgb[0], 0.0f, 1.0f); clamp_v3(rgb, 0.0f, 1.0f);
CLAMP(rgb[1], 0.0f, 1.0f);
CLAMP(rgb[2], 0.0f, 1.0f);
rgb_to_yuv_normalized(rgb, yuv); rgb_to_yuv_normalized(rgb, yuv);

View File

@@ -1497,8 +1497,7 @@ static void uv_map_clip_correct_multi(const Scene *scene,
BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) { BM_ITER_ELEM (l, &liter, efa, BM_LOOPS_OF_FACE) {
luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset);
CLAMP(luv->uv[0], 0.0f, 1.0f); clamp_v2(luv->uv, 0.0f, 1.0f);
CLAMP(luv->uv[1], 0.0f, 1.0f);
} }
} }
} }

View File

@@ -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]; 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 here or else we can easily get off-range */
CLAMP(outF[0], 0.0f, 1.0f); clamp_v4(outF, 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);
} }
if (outI) { if (outI) {
/* sample including outside of edges of image */ /* sample including outside of edges of image */

View File

@@ -824,10 +824,7 @@ static int Color_hsv_set(ColorObject *self, PyObject *value, void *UNUSED(closur
return -1; return -1;
} }
CLAMP(hsv[0], 0.0f, 1.0f); clamp_v3(hsv, 0.0f, 1.0f);
CLAMP(hsv[1], 0.0f, 1.0f);
CLAMP(hsv[2], 0.0f, 1.0f);
hsv_to_rgb_v(hsv, self->col); hsv_to_rgb_v(hsv, self->col);
if (BaseMath_WriteCallback(self) == -1) { if (BaseMath_WriteCallback(self) == -1) {

View File

@@ -838,8 +838,7 @@ static void apply_heights_callback(DerivedMesh *lores_dm,
resolve_tri_uv_v2(uv, st, st0, st1, st2); resolve_tri_uv_v2(uv, st, st0, st1, st2);
} }
CLAMP(uv[0], 0.0f, 1.0f); clamp_v2(uv, 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
get_ccgdm_data( get_ccgdm_data(
lores_dm, hires_dm, height_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], p1, NULL); 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); resolve_tri_uv_v2(uv, st, st0, st1, st2);
} }
CLAMP(uv[0], 0.0f, 1.0f); clamp_v2(uv, 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
get_ccgdm_data( get_ccgdm_data(
lores_dm, hires_dm, normal_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], NULL, n); 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); resolve_tri_uv_v2(uv, st, st0, st1, st2);
} }
CLAMP(uv[0], 0.0f, 1.0f); clamp_v2(uv, 0.0f, 1.0f);
CLAMP(uv[1], 0.0f, 1.0f);
get_ccgdm_data( get_ccgdm_data(
lores_dm, hires_dm, ao_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], pos, nrm); lores_dm, hires_dm, ao_data->orig_index_mp_to_orig, lvl, lt, uv[0], uv[1], pos, nrm);