diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-08-07 15:36:11 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-08-07 15:37:39 +0300 |
commit | b134434224254d4ac3fc73d023f2f6d914746690 (patch) | |
tree | b67d2c5aee982495d55848414c362665a37476b0 /source/blender/editors/sculpt_paint | |
parent | 3db67fd670535c0a709ec6e8204fcb730cd3eb0d (diff) |
Cleanup: declare arrays arrays where possible
Diffstat (limited to 'source/blender/editors/sculpt_paint')
13 files changed, 31 insertions, 29 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index c5f1063d494..e559d2120e2 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -1352,8 +1352,10 @@ static void paint_cursor_sculpt_session_update_and_init(PaintCursorContext *pcon ViewContext *vc = &pcontext->vc; SculptCursorGeometryInfo gi; - float mouse[2] = {pcontext->x - pcontext->region->winrct.xmin, - pcontext->y - pcontext->region->winrct.ymin}; + const float mouse[2] = { + pcontext->x - pcontext->region->winrct.xmin, + pcontext->y - pcontext->region->winrct.ymin, + }; /* This updates the active vertex, which is needed for most of the Sculpt/Vertex Colors tools to * work correctly */ @@ -1457,7 +1459,7 @@ static void paint_cursor_update_object_space_radius(PaintCursorContext *pcontext static void paint_cursor_drawing_setup_cursor_space(PaintCursorContext *pcontext) { float cursor_trans[4][4], cursor_rot[4][4]; - float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; + const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; copy_m4_m4(cursor_trans, pcontext->vc.obact->obmat); translate_m4(cursor_trans, pcontext->location[0], pcontext->location[1], pcontext->location[2]); diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 74e022bf84f..458f021ddb4 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -193,7 +193,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) PaintCurvePoint *pcp; wmWindow *window = CTX_wm_window(C); ARegion *region = CTX_wm_region(C); - float vec[3] = {loc[0], loc[1], 0.0}; + const float vec[3] = {loc[0], loc[1], 0.0}; int add_index; int i; @@ -251,7 +251,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) static int paintcurve_add_point_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - int loc[2] = {event->mval[0], event->mval[1]}; + const int loc[2] = {event->mval[0], event->mval[1]}; paintcurve_point_add(C, op, loc); RNA_int_set_array(op->ptr, "location", loc); return OPERATOR_FINISHED; @@ -480,7 +480,7 @@ static bool paintcurve_point_select( static int paintcurve_select_point_invoke(bContext *C, wmOperator *op, const wmEvent *event) { - int loc[2] = {UNPACK2(event->mval)}; + const int loc[2] = {UNPACK2(event->mval)}; bool toggle = RNA_boolean_get(op->ptr, "toggle"); bool extend = RNA_boolean_get(op->ptr, "extend"); if (paintcurve_point_select(C, op, loc, toggle, extend)) { diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 34c9cac67c8..431ab998f62 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1333,7 +1333,7 @@ void ED_imapaint_bucket_fill(struct bContext *C, ED_image_undo_push_begin(op->type->name, PAINT_MODE_TEXTURE_2D); - float mouse_init[2] = {mouse[0], mouse[1]}; + const float mouse_init[2] = {mouse[0], mouse[1]}; paint_2d_bucket_fill(C, color, NULL, mouse_init, NULL, NULL); ED_image_undo_push_end(); diff --git a/source/blender/editors/sculpt_paint/paint_image_2d.c b/source/blender/editors/sculpt_paint/paint_image_2d.c index 6d588d1450b..d614c800350 100644 --- a/source/blender/editors/sculpt_paint/paint_image_2d.c +++ b/source/blender/editors/sculpt_paint/paint_image_2d.c @@ -2163,7 +2163,7 @@ void paint_2d_gradient_fill( for (x_px = 0; x_px < ibuf->x; x_px++) { for (y_px = 0; y_px < ibuf->y; y_px++) { float f; - float p[2] = {x_px - image_init[0], y_px - image_init[1]}; + const float p[2] = {x_px - image_init[0], y_px - image_init[1]}; switch (br->gradient_fill_mode) { case BRUSH_GRADIENT_LINEAR: { @@ -2191,7 +2191,7 @@ void paint_2d_gradient_fill( for (x_px = 0; x_px < ibuf->x; x_px++) { for (y_px = 0; y_px < ibuf->y; y_px++) { float f; - float p[2] = {x_px - image_init[0], y_px - image_init[1]}; + const float p[2] = {x_px - image_init[0], y_px - image_init[1]}; switch (br->gradient_fill_mode) { case BRUSH_GRADIENT_LINEAR: { diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index af2762889e8..fa9a0854112 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3309,7 +3309,7 @@ static void project_paint_face_init(const ProjPaintState *ps, has_x_isect = 0; for (x = bounds_px.xmin; x < bounds_px.xmax; x++) { - float puv[2] = {(float)x, (float)y}; + const float puv[2] = {(float)x, (float)y}; bool in_bounds; // uv[0] = (((float)x) + 0.5f) / (float)ibuf->x; /* use offset uvs instead */ @@ -5756,7 +5756,7 @@ void paint_proj_stroke(const bContext *C, View3D *v3d = CTX_wm_view3d(C); ARegion *region = CTX_wm_region(C); float *cursor = scene->cursor.location; - int mval_i[2] = {(int)pos[0], (int)pos[1]}; + const int mval_i[2] = {(int)pos[0], (int)pos[1]}; view3d_operator_needs_opengl(C); @@ -6123,8 +6123,8 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - float pos[2] = {0.0, 0.0}; - float lastpos[2] = {0.0, 0.0}; + const float pos[2] = {0.0, 0.0}; + const float lastpos[2] = {0.0, 0.0}; int a; project_paint_op(&ps, lastpos, pos); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 0fe6e259d8d..43ff03ea7e2 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -913,7 +913,7 @@ static int stencil_control_invoke(bContext *C, wmOperator *op, const wmEvent *ev { Paint *paint = BKE_paint_get_active_from_context(C); Brush *br = BKE_paint_brush(paint); - float mvalf[2] = {event->mval[0], event->mval[1]}; + const float mvalf[2] = {event->mval[0], event->mval[1]}; ARegion *region = CTX_wm_region(C); StencilControlData *scd; int mask = RNA_enum_get(op->ptr, "texmode"); @@ -968,7 +968,7 @@ static void stencil_control_calculate(StencilControlData *scd, const int mval[2] #define PIXEL_MARGIN 5 float mdiff[2]; - float mvalf[2] = {mval[0], mval[1]}; + const float mvalf[2] = {mval[0], mval[1]}; switch (scd->mode) { case STENCIL_TRANSLATE: sub_v2_v2v2(mdiff, mvalf, scd->init_mouse); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 6c5d6f4ee4e..af5afa80eb8 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -169,7 +169,7 @@ float paint_get_tex_pixel(const MTex *mtex, float u, float v, struct ImagePool * { float intensity; float rgba_dummy[4]; - float co[3] = {u, v, 0.0f}; + const float co[3] = {u, v, 0.0f}; RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba_dummy); @@ -185,7 +185,7 @@ void paint_get_tex_pixel_col(const MTex *mtex, bool convert_to_linear, struct ColorSpace *colorspace) { - float co[3] = {u, v, 0.0f}; + const float co[3] = {u, v, 0.0f}; float intensity; const bool hasrgb = RE_texture_evaluate(mtex, co, thread, pool, false, false, &intensity, rgba); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 83d76c166ce..73014f9f2de 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -757,8 +757,8 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) int y_start = RNA_int_get(op->ptr, "ystart"); int x_end = RNA_int_get(op->ptr, "xend"); int y_end = RNA_int_get(op->ptr, "yend"); - float sco_start[2] = {x_start, y_start}; - float sco_end[2] = {x_end, y_end}; + const float sco_start[2] = {x_start, y_start}; + const float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index c0862795594..21fba6479e8 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -979,7 +979,7 @@ void SCULPT_cloth_simulation_limits_draw(const uint gpuattr, const float alpha) { float cursor_trans[4][4], cursor_rot[4][4]; - float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; + const float z_axis[4] = {0.0f, 0.0f, 1.0f, 0.0f}; float quat[4]; unit_m4(cursor_trans); translate_m4(cursor_trans, location[0], location[1], location[2]); diff --git a/source/blender/editors/sculpt_paint/sculpt_detail.c b/source/blender/editors/sculpt_paint/sculpt_detail.c index 463233fd6fb..e08f477c981 100644 --- a/source/blender/editors/sculpt_paint/sculpt_detail.c +++ b/source/blender/editors/sculpt_paint/sculpt_detail.c @@ -179,7 +179,7 @@ static void sample_detail_voxel(bContext *C, ViewContext *vc, int mx, int my) SCULPT_vertex_random_access_init(ss); /* Update the active vertex. */ - float mouse[2] = {mx, my}; + const float mouse[2] = {mx, my}; SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false); @@ -219,7 +219,7 @@ static void sample_detail_dyntopo(bContext *C, ViewContext *vc, ARegion *region, SCULPT_stroke_modifiers_check(C, ob, brush); - float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + const float mouse[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; float ray_start[3], ray_end[3], ray_normal[3]; float depth = SCULPT_raycast_init(vc, mouse, ray_start, ray_end, ray_normal, false); @@ -316,7 +316,7 @@ static int sculpt_sample_detail_size_modal(bContext *C, wmOperator *op, const wm switch (event->type) { case LEFTMOUSE: if (event->val == KM_PRESS) { - int ss_co[2] = {event->x, event->y}; + const int ss_co[2] = {event->x, event->y}; int mode = RNA_enum_get(op->ptr, "mode"); sample_detail(C, ss_co[0], ss_co[1], mode); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c index ba11988156c..e39cdc2db23 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.c @@ -82,7 +82,7 @@ void SCULPT_filter_cache_init(Object *ob, Sculpt *sd, const int undo_type) ss->filter_cache->random_seed = rand(); - float center[3] = {0.0f}; + const float center[3] = {0.0f}; SculptSearchSphereData search_data = { .original = true, .center = center, diff --git a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c index 60483cc168d..bc493a036f0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_mask_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_mask_expand.c @@ -174,7 +174,7 @@ static int sculpt_mask_expand_modal(bContext *C, wmOperator *op, const wmEvent * ARegion *region = CTX_wm_region(C); float prevclick_f[2]; copy_v2_v2(prevclick_f, op->customdata); - int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]}; + const int prevclick[2] = {(int)prevclick_f[0], (int)prevclick_f[1]}; int len = (int)len_v2v2_int(prevclick, event->mval); len = abs(len); int mask_speed = RNA_int_get(op->ptr, "mask_speed"); diff --git a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c index 35f916c8f90..e47a94dff90 100644 --- a/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c +++ b/source/blender/editors/sculpt_paint/sculpt_multiplane_scrape.c @@ -375,7 +375,7 @@ void SCULPT_do_multiplane_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, /* Calculate the final left and right scrape planes. */ float plane_no[3]; float plane_no_rot[3]; - float y_axis[3] = {0.0f, 1.0f, 0.0f}; + const float y_axis[3] = {0.0f, 1.0f, 0.0f}; float mat_inv[4][4]; invert_m4_m4(mat_inv, mat); @@ -418,11 +418,11 @@ void SCULPT_multiplane_scrape_preview_draw(const uint gpuattr, float offset = ss->cache->radius * 0.25f; - float p[3] = {0.0f, 0.0f, ss->cache->radius}; - float y_axis[3] = {0.0f, 1.0f, 0.0f}; + const float p[3] = {0.0f, 0.0f, ss->cache->radius}; + const float y_axis[3] = {0.0f, 1.0f, 0.0f}; float p_l[3]; float p_r[3]; - float area_center[3] = {0.0f, 0.0f, 0.0f}; + const float area_center[3] = {0.0f, 0.0f, 0.0f}; rotate_v3_v3v3fl(p_r, p, y_axis, DEG2RADF((angle + 180) * 0.5f)); rotate_v3_v3v3fl(p_l, p, y_axis, DEG2RADF(-(angle + 180) * 0.5f)); |