[Bf-blender-cvs] [ed159004739] master: Cleanup: use const variables & arguments

Campbell Barton noreply at git.blender.org
Thu Jun 9 13:34:12 CEST 2022


Commit: ed159004739c7331640a88ab3c4fe25e33c8ebc0
Author: Campbell Barton
Date:   Thu Jun 9 21:26:48 2022 +1000
Branches: master
https://developer.blender.org/rBed159004739c7331640a88ab3c4fe25e33c8ebc0

Cleanup: use const variables & arguments

===================================================================

M	source/blender/blenlib/intern/math_solvers.c
M	source/blender/editors/curve/editcurve_pen.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_clip.h
M	source/blender/editors/include/ED_image.h
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_eyedropper_color.c
M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/space_clip/clip_editor.c
M	source/blender/editors/space_image/image_ops.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/windowmanager/intern/wm_dragdrop.c
M	source/blender/windowmanager/intern/wm_event_system.cc

===================================================================

diff --git a/source/blender/blenlib/intern/math_solvers.c b/source/blender/blenlib/intern/math_solvers.c
index 2352d687061..b5650410a70 100644
--- a/source/blender/blenlib/intern/math_solvers.c
+++ b/source/blender/blenlib/intern/math_solvers.c
@@ -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);
   }
diff --git a/source/blender/editors/curve/editcurve_pen.c b/source/blender/editors/curve/editcurve_pen.c
index 4a1bc5243de..729ad46877a 100644
--- a/source/blender/editors/curve/editcurve_pen.c
+++ b/source/blender/editors/curve/editcurve_pen.c
@@ -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) {
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 9a9461913fc..4733da85291 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -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;
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 2c67b02611b..c5a45f8b73e 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -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);
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 89e396c8035..b16844c01ea 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -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.
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 18bad7949ee..d201820fbb6 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -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);
 }
 
diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c
index 895f8d0d840..241776fd761 100644
--- a/source/blender/editors/interface/interface_eyedropper_color.c
+++ b/source/blender/editors/interface/interface_eyedropper_color.c
@@ -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;
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index b06361c7e28..11d4a440a68 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -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;
     }
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index fb5e76b578f..48397922ca8 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -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) {
diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c
index 87e88d094d7..0b4eec4a835 100644
--- a/source/blender/editors/space_clip/clip_editor.c
+++ b/source/blender/editors/space_clip/clip_editor.c
@@ -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];
diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c
index 0761568e480..fa49e996c2a 100644
--- a/source/blender/editors/space_image/image_ops.c
+++ b/source/blender/editors/space_image/image_ops.c
@@ -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;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 48abe71e35f..9ed2fec96db 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -594,7 +594,7 @@ static char *view3d_mat_drop_tooltip(bContext *C,
 {
   const char *name = WM_drag_get_item_name(drag);
   

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list