Cleanup: use clamp_* from BLI_math (replace macro)
This commit is contained in:
@@ -1233,7 +1233,7 @@ bool BM_mesh_intersect(
|
||||
|
||||
if (BM_vert_in_edge(e, v_prev)) {
|
||||
BMEdge *e_split;
|
||||
v_prev = BM_edge_split(bm, e, v_prev, &e_split, CLAMPIS(fac, 0.0f, 1.0f));
|
||||
v_prev = BM_edge_split(bm, e, v_prev, &e_split, clamp_f(fac, 0.0f, 1.0f));
|
||||
BLI_assert(BM_vert_in_edge(e, v_end));
|
||||
|
||||
if (!BM_edge_exists(v_prev, vi) &&
|
||||
|
||||
@@ -54,7 +54,7 @@ void TimeNode::convertToOperations(NodeConverter &converter, const CompositorCon
|
||||
|
||||
curvemapping_initialize((CurveMapping *)node->storage);
|
||||
fac = curvemapping_evaluateF((CurveMapping *)node->storage, 0, fac);
|
||||
operation->setValue(CLAMPIS(fac, 0.0f, 1.0f));
|
||||
operation->setValue(clamp_f(fac, 0.0f, 1.0f));
|
||||
converter.addOperation(operation);
|
||||
|
||||
converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket());
|
||||
|
||||
@@ -5240,12 +5240,12 @@ static int ui_do_but_COLOR(
|
||||
rgb_to_hsv_compat_v(col, hsv);
|
||||
|
||||
if (event->type == WHEELDOWNMOUSE)
|
||||
hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] - 0.05f, 0.0f, 1.0f);
|
||||
else if (event->type == WHEELUPMOUSE)
|
||||
hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] + 0.05f, 0.0f, 1.0f);
|
||||
else {
|
||||
float fac = 0.005 * (event->y - event->prevy);
|
||||
hsv[2] = CLAMPIS(hsv[2] + fac, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] + fac, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
hsv_to_rgb_v(hsv, data->vec);
|
||||
@@ -5963,12 +5963,12 @@ static int ui_do_but_HSVCIRCLE(
|
||||
}
|
||||
/* XXX hardcoded keymap check.... */
|
||||
else if (event->type == WHEELDOWNMOUSE) {
|
||||
hsv[2] = CLAMPIS(hsv[2] - 0.05f, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] - 0.05f, 0.0f, 1.0f);
|
||||
ui_but_hsv_set(but); /* converts to rgb */
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
}
|
||||
else if (event->type == WHEELUPMOUSE) {
|
||||
hsv[2] = CLAMPIS(hsv[2] + 0.05f, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] + 0.05f, 0.0f, 1.0f);
|
||||
ui_but_hsv_set(but); /* converts to rgb */
|
||||
ui_numedit_apply(C, block, but, data);
|
||||
}
|
||||
|
||||
@@ -585,7 +585,7 @@ static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *blo
|
||||
|
||||
ui_rgb_to_color_picker_compat_v(rgb, hsv);
|
||||
|
||||
hsv[2] = CLAMPIS(hsv[2] + add, 0.0f, 1.0f);
|
||||
hsv[2] = clamp_f(hsv[2] + add, 0.0f, 1.0f);
|
||||
ui_color_picker_to_rgb_v(hsv, rgb);
|
||||
|
||||
if (use_display_colorspace)
|
||||
|
||||
@@ -2305,7 +2305,7 @@ void ui_hsvcircle_pos_from_vals(uiBut *but, const rcti *rect, float *hsv, float
|
||||
else
|
||||
radius_t = hsv[1];
|
||||
|
||||
radius = CLAMPIS(radius_t, 0.0f, 1.0f) * radius;
|
||||
radius = clamp_f(radius_t, 0.0f, 1.0f) * radius;
|
||||
*xpos = centx + cosf(-ang) * radius;
|
||||
*ypos = centy + sinf(-ang) * radius;
|
||||
}
|
||||
|
||||
@@ -1114,7 +1114,7 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event
|
||||
|
||||
/* some view2d's (graph) don't have min/max zoom, or extreme ones */
|
||||
if (v2d->maxzoom > 0.0f)
|
||||
zoomfac = CLAMPIS(0.001f * v2d->maxzoom, 0.001f, 0.01f);
|
||||
zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f);
|
||||
|
||||
/* x-axis transform */
|
||||
fac = zoomfac * (event->x - vzd->lastx);
|
||||
|
||||
@@ -771,7 +771,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
if (cuts != lcd->cuts) {
|
||||
/* allow zero so you can backspace and type in a value
|
||||
* otherwise 1 as minimum would make more sense */
|
||||
lcd->cuts = CLAMPIS(cuts, 0, SUBD_CUTS_MAX);
|
||||
lcd->cuts = clamp_i(cuts, 0, SUBD_CUTS_MAX);
|
||||
RNA_int_set(op->ptr, "number_cuts", (int)lcd->cuts);
|
||||
ringsel_find_edge(lcd, (int)lcd->cuts);
|
||||
show_cuts = true;
|
||||
@@ -779,7 +779,7 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
}
|
||||
|
||||
if (smoothness != lcd->smoothness) {
|
||||
lcd->smoothness = CLAMPIS(smoothness, -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
|
||||
lcd->smoothness = clamp_f(smoothness, -SUBD_SMOOTH_MAX, SUBD_SMOOTH_MAX);
|
||||
RNA_float_set(op->ptr, "smoothness", lcd->smoothness);
|
||||
show_cuts = true;
|
||||
ED_region_tag_redraw(lcd->ar);
|
||||
|
||||
@@ -1797,7 +1797,7 @@ static void view_zoom_to_window_xy_camera(
|
||||
{
|
||||
RegionView3D *rv3d = ar->regiondata;
|
||||
const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
|
||||
const float zoomfac_new = CLAMPIS(zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR);
|
||||
const float zoomfac_new = clamp_f(zoomfac * (1.0f / dfac), RV3D_CAMZOOM_MIN_FACTOR, RV3D_CAMZOOM_MAX_FACTOR);
|
||||
const float camzoom_new = BKE_screen_view3d_zoom_from_fac(zoomfac_new);
|
||||
|
||||
|
||||
|
||||
@@ -1399,7 +1399,7 @@ static PyObject *bpy_bmvert_copy_from_vert_interp(BPy_BMVert *self, PyObject *ar
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, CLAMPIS(fac, 0.0f, 1.0f));
|
||||
BM_data_interp_from_verts(bm, vert_array[0], vert_array[1], self->v, clamp_f(fac, 0.0f, 1.0f));
|
||||
|
||||
PyMem_FREE(vert_array);
|
||||
Py_RETURN_NONE;
|
||||
|
||||
@@ -1136,7 +1136,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
ret = -1;
|
||||
}
|
||||
else {
|
||||
*(float *)value = CLAMPIS(tmp_val, 0.0f, 1.0f);
|
||||
*(float *)value = clamp_f(tmp_val, 0.0f, 1.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1148,7 +1148,7 @@ int BPy_BMLayerItem_SetItem(BPy_BMElem *py_ele, BPy_BMLayerItem *py_layer, PyObj
|
||||
ret = -1;
|
||||
}
|
||||
else {
|
||||
*(float *)value = CLAMPIS(tmp_val, 0.0f, 1.0f);
|
||||
*(float *)value = clamp_f(tmp_val, 0.0f, 1.0f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "DNA_meshdata_types.h"
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math_base.h"
|
||||
#include "BLI_math_vector.h"
|
||||
|
||||
#include "BKE_deform.h"
|
||||
@@ -555,7 +556,7 @@ static int bpy_bmdeformvert_ass_subscript(BPy_BMDeformVert *self, PyObject *key,
|
||||
return -1;
|
||||
}
|
||||
|
||||
dw->weight = CLAMPIS(f, 0.0f, 1.0f);
|
||||
dw->weight = clamp_f(f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Python.h>
|
||||
|
||||
#include "BLI_utildefines.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
@@ -159,7 +160,7 @@ static PyObject *bpy_bm_utils_vert_collapse_faces(PyObject *UNUSED(self), PyObje
|
||||
|
||||
bm = py_edge->bm;
|
||||
|
||||
e_new = BM_vert_collapse_faces(bm, py_edge->e, py_vert->v, CLAMPIS(fac, 0.0f, 1.0f), true, do_join_faces, true);
|
||||
e_new = BM_vert_collapse_faces(bm, py_edge->e, py_vert->v, clamp_f(fac, 0.0f, 1.0f), true, do_join_faces, true);
|
||||
|
||||
if (e_new) {
|
||||
return BPy_BMEdge_CreatePyObject(bm, e_new);
|
||||
@@ -365,7 +366,7 @@ static PyObject *bpy_bm_utils_edge_split(PyObject *UNUSED(self), PyObject *args)
|
||||
|
||||
bm = py_edge->bm;
|
||||
|
||||
v_new = BM_edge_split(bm, py_edge->e, py_vert->v, &e_new, CLAMPIS(fac, 0.0f, 1.0f));
|
||||
v_new = BM_edge_split(bm, py_edge->e, py_vert->v, &e_new, clamp_f(fac, 0.0f, 1.0f));
|
||||
|
||||
if (v_new && e_new) {
|
||||
PyObject *ret = PyTuple_New(2);
|
||||
|
||||
Reference in New Issue
Block a user