Cleanup: use const variables & arguments

This commit is contained in:
Campbell Barton 2022-06-09 21:26:48 +10:00
parent 8a6cbcf386
commit ed15900473
14 changed files with 25 additions and 23 deletions

View File

@ -99,8 +99,8 @@ bool BLI_tridiagonal_solve_cyclic(
/* Degenerate case that works but can be simplified. */
if (count == 2) {
float a2[2] = {0, a[1] + c[1]};
float c2[2] = {a[0] + c[0], 0};
const float a2[2] = {0, a[1] + c[1]};
const float c2[2] = {a[0] + c[0], 0};
return BLI_tridiagonal_solve(a2, b, c2, d, r_x, count);
}

View File

@ -843,7 +843,7 @@ static bool insert_point_to_segment(const ViewContext *vc, const wmEvent *event)
{
Curve *cu = vc->obedit->data;
CutData cd = init_cut_data(event);
float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {UNPACK2(event->mval)};
const float threshold_dist_px = ED_view3d_select_dist_px() * SEL_DIST_FACTOR;
const bool near_spline = update_cut_data_for_all_nurbs(
vc, BKE_curve_editNurbs_get(cu), mval, threshold_dist_px, &cd);
@ -1134,7 +1134,7 @@ static bool is_spline_nearby(ViewContext *vc,
ListBase *nurbs = BKE_curve_editNurbs_get(cu);
CutData cd = init_cut_data(event);
float mval[2] = {UNPACK2(event->mval)};
const float mval[2] = {UNPACK2(event->mval)};
const bool nearby = update_cut_data_for_all_nurbs(vc, nurbs, mval, sel_dist, &cd);
if (nearby) {

View File

@ -1747,7 +1747,7 @@ static void gpencil_brush_cursor_draw(bContext *C, int x, int y, void *customdat
float darkcolor[3];
float radius = 3.0f;
int mval_i[2] = {x, y};
const int mval_i[2] = {x, y};
/* Check if cursor is in drawing region and has valid data-block. */
if ((!gpencil_check_cursor_region(C, mval_i)) || (gpd == NULL)) {
return;

View File

@ -60,7 +60,7 @@ bool ED_space_clip_get_position(struct SpaceClip *sc,
*/
bool ED_space_clip_color_sample(struct SpaceClip *sc,
struct ARegion *region,
int mval[2],
const int mval[2],
float r_col[3]);
void ED_clip_update_frame(const struct Main *mainp, int cfra);

View File

@ -64,8 +64,11 @@ bool ED_space_image_get_position(struct SpaceImage *sima,
/**
* Returns color in linear space, matching #ED_space_node_color_sample().
*/
bool ED_space_image_color_sample(
struct SpaceImage *sima, struct ARegion *region, int mval[2], float r_col[3], bool *r_is_data);
bool ED_space_image_color_sample(struct SpaceImage *sima,
struct ARegion *region,
const int mval[2],
float r_col[3],
bool *r_is_data);
struct ImBuf *ED_space_image_acquire_buffer(struct SpaceImage *sima, void **r_lock, int tile);
/**
* Get the #SpaceImage flag that is valid for the given ibuf.

View File

@ -130,7 +130,7 @@ void UI_draw_roundbox_4fv_ex(const rctf *rect,
void UI_draw_roundbox_3ub_alpha(
const rctf *rect, bool filled, float rad, const uchar col[3], uchar alpha)
{
float colv[4] = {
const float colv[4] = {
((float)col[0]) / 255,
((float)col[1]) / 255,
((float)col[2]) / 255,
@ -142,7 +142,7 @@ void UI_draw_roundbox_3ub_alpha(
void UI_draw_roundbox_3fv_alpha(
const rctf *rect, bool filled, float rad, const float col[3], float alpha)
{
float colv[4] = {col[0], col[1], col[2], alpha};
const float colv[4] = {col[0], col[1], col[2], alpha};
UI_draw_roundbox_4fv_ex(rect, (filled) ? colv : NULL, NULL, 1.0f, colv, U.pixelsize, rad);
}

View File

@ -329,7 +329,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceImage *sima = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_image_color_sample(sima, region, region_mval, r_col, NULL)) {
return;
@ -340,7 +340,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceNode *snode = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_node_color_sample(bmain, snode, region, region_mval, r_col)) {
return;
@ -351,7 +351,7 @@ void eyedropper_color_sample_fl(bContext *C, const int m_xy[2], float r_col[3])
ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mval);
if (region) {
SpaceClip *sc = area->spacedata.first;
int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
const int region_mval[2] = {mval[0] - region->winrct.xmin, mval[1] - region->winrct.ymin};
if (ED_space_clip_color_sample(sc, region, region_mval, r_col)) {
return;

View File

@ -7408,8 +7408,7 @@ static bool ui_numedit_but_CURVEPROFILE(uiBlock *block,
const float zoomy = BLI_rctf_size_y(&but->rect) / BLI_rctf_size_y(&profile->view_rect);
if (snap) {
float d[2] = {mx - data->dragstartx, data->dragstarty};
const float d[2] = {mx - data->dragstartx, data->dragstarty};
if (len_squared_v2(d) < (9.0f * U.dpi_fac)) {
snap = false;
}

View File

@ -1584,7 +1584,7 @@ static int sculpt_trim_gesture_box_invoke(bContext *C, wmOperator *op, const wmE
SculptSession *ss = ob->sculpt;
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
const float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
if (ss->gesture_initial_hit) {
@ -1625,7 +1625,7 @@ static int sculpt_trim_gesture_lasso_invoke(bContext *C, wmOperator *op, const w
SculptSession *ss = ob->sculpt;
SculptCursorGeometryInfo sgi;
float mouse[2] = {event->mval[0], event->mval[1]};
const float mouse[2] = {event->mval[0], event->mval[1]};
SCULPT_vertex_random_access_ensure(ss);
ss->gesture_initial_hit = SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false);
if (ss->gesture_initial_hit) {

View File

@ -272,7 +272,7 @@ bool ED_space_clip_get_position(struct SpaceClip *sc,
return true;
}
bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, int mval[2], float r_col[3])
bool ED_space_clip_color_sample(SpaceClip *sc, ARegion *region, const int mval[2], float r_col[3])
{
ImBuf *ibuf;
float fx, fy, co[2];

View File

@ -3204,7 +3204,7 @@ bool ED_space_image_get_position(SpaceImage *sima,
}
bool ED_space_image_color_sample(
SpaceImage *sima, ARegion *region, int mval[2], float r_col[3], bool *r_is_data)
SpaceImage *sima, ARegion *region, const int mval[2], float r_col[3], bool *r_is_data)
{
if (r_is_data) {
*r_is_data = false;

View File

@ -594,7 +594,7 @@ static char *view3d_mat_drop_tooltip(bContext *C,
{
const char *name = WM_drag_get_item_name(drag);
ARegion *region = CTX_wm_region(C);
int mval[2] = {
const int mval[2] = {
xy[0] - region->winrct.xmin,
xy[1] - region->winrct.ymin,
};

View File

@ -827,7 +827,7 @@ static void wm_drag_draw_icon(bContext *UNUSED(C),
x = xy[0] - (wm_drag_imbuf_icon_width_get(drag) / 2);
y = xy[1] - (wm_drag_imbuf_icon_height_get(drag) / 2);
float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
const float col[4] = {1.0f, 1.0f, 1.0f, 0.65f}; /* this blends texture */
IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_COLOR);
immDrawPixelsTexTiled_scaling(&state,
x,

View File

@ -1379,7 +1379,7 @@ static int wm_operator_invoke(bContext *C,
if (op->type->invoke && event) {
/* Temporarily write into `mval` (not technically `const` correct) but this is restored. */
int mval_prev[2] = {UNPACK2(event->mval)};
const int mval_prev[2] = {UNPACK2(event->mval)};
wm_region_mouse_co(C, (wmEvent *)event);
if (op->type->flag & OPTYPE_UNDO) {
@ -3393,7 +3393,7 @@ static int wm_handlers_do(bContext *C, wmEvent *event, ListBase *handlers)
else {
/* Position is where the actual click happens, for more
* accurate selecting in case the mouse drifts a little. */
int xy[2] = {UNPACK2(event->xy)};
const int xy[2] = {UNPACK2(event->xy)};
copy_v2_v2_int(event->xy, event->prev_press_xy);
event->val = KM_CLICK;