From b134434224254d4ac3fc73d023f2f6d914746690 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 7 Aug 2020 22:36:11 +1000 Subject: Cleanup: declare arrays arrays where possible --- source/blender/blenfont/intern/blf.c | 4 ++-- source/blender/blenkernel/intern/boids.c | 2 +- source/blender/blenkernel/intern/brush.c | 8 ++++---- source/blender/blenkernel/intern/cloth.c | 2 +- source/blender/blenkernel/intern/curve.c | 2 +- source/blender/blenkernel/intern/curveprofile.c | 6 +++--- source/blender/blenkernel/intern/dynamicpaint.c | 2 +- source/blender/blenkernel/intern/fluid.c | 2 +- source/blender/blenkernel/intern/hair.c | 4 ++-- source/blender/blenkernel/intern/particle.c | 12 +++++------ source/blender/blenkernel/intern/particle_system.c | 4 ++-- source/blender/blenkernel/intern/pbvh.c | 2 +- source/blender/blenkernel/intern/pointcloud.c | 4 ++-- source/blender/blenkernel/intern/seqmodifier.c | 4 ++-- source/blender/blenkernel/intern/sequencer.c | 2 +- source/blender/blenkernel/intern/shrinkwrap.c | 2 +- source/blender/blenkernel/intern/studiolight.c | 4 ++-- source/blender/blenkernel/intern/subdiv_foreach.c | 2 +- .../blender/blenkernel/intern/tracking_stabilize.c | 2 +- source/blender/blenlib/intern/lasso_2d.c | 2 +- source/blender/blenlib/intern/math_geom.c | 4 ++-- source/blender/blenlib/intern/math_interp.c | 2 +- source/blender/bmesh/intern/bmesh_interp.c | 2 +- source/blender/bmesh/tools/bmesh_bevel.c | 8 +++++--- source/blender/bmesh/tools/bmesh_intersect.c | 2 +- .../draw/engines/eevee/eevee_depth_of_field.c | 2 +- source/blender/draw/engines/eevee/eevee_effects.c | 2 +- source/blender/draw/engines/eevee/eevee_engine.c | 4 ++-- .../blender/draw/engines/eevee/eevee_lightcache.c | 2 +- .../blender/draw/engines/eevee/eevee_lightprobes.c | 2 +- source/blender/draw/engines/eevee/eevee_lookdev.c | 2 +- .../blender/draw/engines/eevee/eevee_materials.c | 2 +- source/blender/draw/engines/eevee/eevee_mist.c | 2 +- .../blender/draw/engines/eevee/eevee_motion_blur.c | 12 +++++++---- .../blender/draw/engines/eevee/eevee_occlusion.c | 4 ++-- source/blender/draw/engines/eevee/eevee_render.c | 10 +++++---- source/blender/draw/engines/eevee/eevee_sampling.c | 8 ++++---- .../draw/engines/eevee/eevee_screen_raytrace.c | 4 ++-- source/blender/draw/engines/eevee/eevee_shadows.c | 2 +- .../draw/engines/eevee/eevee_shadows_cascade.c | 2 +- .../blender/draw/engines/eevee/eevee_subsurface.c | 6 +++--- .../draw/engines/eevee/eevee_temporal_sampling.c | 2 +- source/blender/draw/engines/eevee/eevee_volumes.c | 8 ++++---- .../draw/engines/external/external_engine.c | 2 +- .../draw/engines/gpencil/gpencil_antialiasing.c | 2 +- .../draw/engines/gpencil/gpencil_cache_utils.c | 2 +- .../blender/draw/engines/gpencil/gpencil_engine.c | 6 +++--- .../blender/draw/engines/gpencil/gpencil_render.c | 2 +- .../draw/engines/overlay/overlay_antialiasing.c | 4 ++-- .../draw/engines/overlay/overlay_armature.c | 2 +- .../blender/draw/engines/overlay/overlay_engine.c | 2 +- .../blender/draw/engines/overlay/overlay_extra.c | 8 ++++---- .../blender/draw/engines/overlay/overlay_image.c | 2 +- .../draw/engines/overlay/overlay_motion_path.c | 4 ++-- .../blender/draw/engines/overlay/overlay_outline.c | 2 +- .../workbench/workbench_effect_antialiasing.c | 2 +- .../draw/engines/workbench/workbench_effect_dof.c | 2 +- .../draw/engines/workbench/workbench_engine.c | 6 +++--- .../draw/engines/workbench/workbench_materials.c | 2 +- .../draw/engines/workbench/workbench_shadow.c | 4 ++-- .../draw/engines/workbench/workbench_volume.c | 4 ++-- source/blender/draw/intern/draw_cache.c | 18 ++++++++-------- source/blender/draw/intern/draw_common.c | 2 +- source/blender/draw/intern/draw_hair.c | 2 +- source/blender/draw/intern/draw_manager.c | 2 +- source/blender/editors/curve/editcurve_add.c | 8 ++++---- source/blender/editors/curve/editfont.c | 2 +- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 2 +- .../gizmo_library/gizmo_types/button2d_gizmo.c | 2 +- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 2 +- source/blender/editors/gpencil/annotate_paint.c | 6 +++--- source/blender/editors/gpencil/gpencil_edit.c | 2 +- source/blender/editors/gpencil/gpencil_fill.c | 2 +- source/blender/editors/gpencil/gpencil_mesh.c | 2 +- source/blender/editors/gpencil/gpencil_paint.c | 4 ++-- source/blender/editors/gpencil/gpencil_utils.c | 6 +++--- source/blender/editors/interface/interface_draw.c | 24 +++++++++++----------- .../editors/interface/interface_eyedropper_color.c | 4 ++-- .../interface/interface_eyedropper_colorband.c | 4 ++-- .../blender/editors/interface/interface_handlers.c | 4 ++-- .../editors/interface/interface_icons_event.c | 2 +- source/blender/editors/interface/interface_style.c | 2 +- .../blender/editors/interface/interface_widgets.c | 8 ++++---- source/blender/editors/mask/mask_draw.c | 2 +- .../blender/editors/mesh/editmesh_extrude_spin.c | 2 +- source/blender/editors/mesh/editmesh_knife.c | 2 +- source/blender/editors/object/object_add.c | 2 +- source/blender/editors/object/object_remesh.c | 6 +++--- source/blender/editors/object/object_transform.c | 2 +- source/blender/editors/screen/area.c | 2 +- source/blender/editors/screen/glutil.c | 14 ++++++------- source/blender/editors/sculpt_paint/paint_cursor.c | 8 +++++--- source/blender/editors/sculpt_paint/paint_curve.c | 6 +++--- source/blender/editors/sculpt_paint/paint_image.c | 2 +- .../blender/editors/sculpt_paint/paint_image_2d.c | 4 ++-- .../editors/sculpt_paint/paint_image_proj.c | 8 ++++---- source/blender/editors/sculpt_paint/paint_ops.c | 4 ++-- source/blender/editors/sculpt_paint/paint_utils.c | 4 ++-- .../editors/sculpt_paint/paint_vertex_weight_ops.c | 4 ++-- source/blender/editors/sculpt_paint/sculpt_cloth.c | 2 +- .../blender/editors/sculpt_paint/sculpt_detail.c | 6 +++--- .../editors/sculpt_paint/sculpt_filter_mesh.c | 2 +- .../editors/sculpt_paint/sculpt_mask_expand.c | 2 +- .../sculpt_paint/sculpt_multiplane_scrape.c | 8 ++++---- source/blender/editors/space_clip/clip_graph_ops.c | 6 +++--- source/blender/editors/space_clip/tracking_ops.c | 6 +++--- .../blender/editors/space_clip/tracking_select.c | 8 ++++---- source/blender/editors/space_image/image_draw.c | 12 +++++------ source/blender/editors/space_info/info_draw.c | 4 ++-- source/blender/editors/space_info/textview.c | 2 +- source/blender/editors/space_node/node_draw.c | 2 +- .../blender/editors/space_outliner/outliner_draw.c | 2 +- .../editors/space_sequencer/sequencer_draw.c | 8 ++++---- .../blender/editors/space_text/text_autocomplete.c | 2 +- source/blender/editors/space_text/text_ops.c | 2 +- .../blender/editors/space_view3d/view3d_buttons.c | 2 +- .../space_view3d/view3d_gizmo_preselect_type.c | 2 +- .../editors/space_view3d/view3d_gizmo_ruler.c | 2 +- .../editors/space_view3d/view3d_placement.c | 4 ++-- .../blender/editors/space_view3d/view3d_project.c | 6 +++--- source/blender/editors/space_view3d/view3d_utils.c | 2 +- source/blender/editors/space_view3d/view3d_walk.c | 2 +- .../editors/transform/transform_convert_mesh.c | 3 ++- .../blender/editors/transform/transform_gizmo_2d.c | 6 +++--- .../blender/editors/transform/transform_gizmo_3d.c | 2 +- .../editors/transform/transform_gizmo_extrude_3d.c | 2 +- .../editors/transform/transform_mode_edge_slide.c | 4 ++-- .../editors/transform/transform_mode_vert_slide.c | 6 +++--- .../editors/transform/transform_snap_object.c | 2 +- source/blender/editors/uvedit/uvedit_unwrap_ops.c | 2 +- .../gpencil_modifiers/intern/MOD_gpencilarray.c | 2 +- source/blender/gpu/intern/gpu_buffers.c | 8 ++++---- source/blender/gpu/intern/gpu_immediate_util.c | 24 +++++++++++----------- source/blender/imbuf/intern/anim_movie.c | 4 ++-- source/blender/imbuf/intern/tiff.c | 4 ++-- source/blender/imbuf/intern/util_gpu.c | 4 ++-- source/blender/makesrna/intern/makesrna.c | 2 +- .../modifiers/intern/MOD_particleinstance.c | 2 +- source/blender/modifiers/intern/MOD_screw.c | 4 ++-- .../blender/modifiers/intern/MOD_surfacedeform.c | 2 +- source/blender/modifiers/intern/MOD_uvwarp.c | 2 +- .../nodes/shader/nodes/node_shader_geometry.c | 2 +- .../nodes/shader/nodes/node_shader_mixRgb.c | 4 ++-- source/blender/render/intern/source/imagetexture.c | 2 +- .../blender/render/intern/source/multires_bake.c | 2 +- source/blender/render/intern/source/pointdensity.c | 2 +- .../blender/simulation/intern/implicit_blender.c | 4 ++-- source/blender/windowmanager/intern/wm_draw.c | 4 ++-- source/blender/windowmanager/intern/wm_gesture.c | 2 +- source/blender/windowmanager/intern/wm_operators.c | 8 ++++---- 150 files changed, 313 insertions(+), 302 deletions(-) (limited to 'source') diff --git a/source/blender/blenfont/intern/blf.c b/source/blender/blenfont/intern/blf.c index 2f7d5a60a6f..95b074fa2df 100644 --- a/source/blender/blenfont/intern/blf.c +++ b/source/blender/blenfont/intern/blf.c @@ -509,7 +509,7 @@ void BLF_color4fv(int fontid, const float rgba[4]) void BLF_color4f(int fontid, float r, float g, float b, float a) { - float rgba[4] = {r, g, b, a}; + const float rgba[4] = {r, g, b, a}; BLF_color4fv(fontid, rgba); } @@ -523,7 +523,7 @@ void BLF_color3fv_alpha(int fontid, const float rgb[3], float alpha) void BLF_color3f(int fontid, float r, float g, float b) { - float rgba[4] = {r, g, b, 1.0f}; + const float rgba[4] = {r, g, b, 1.0f}; BLF_color4fv(fontid, rgba); } diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index a0da1b1677d..a7324ffe738 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -873,7 +873,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, return bpa->ground; } - float zvec[3] = {0.0f, 0.0f, 2000.0f}; + const float zvec[3] = {0.0f, 0.0f, 2000.0f}; ParticleCollision col; ColliderCache *coll; BVHTreeRayHit hit; diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index 39fbea66637..ce0249c71ce 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1740,7 +1740,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene, } else if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) { float rotation = -mtex->rot; - float point_2d[2] = {point[0], point[1]}; + const float point_2d[2] = {point[0], point[1]}; float x, y; float co[3]; @@ -1770,7 +1770,7 @@ float BKE_brush_sample_tex_3d(const Scene *scene, } else { float rotation = -mtex->rot; - float point_2d[2] = {point[0], point[1]}; + const float point_2d[2] = {point[0], point[1]}; float x = 0.0f, y = 0.0f; /* Quite warnings */ float invradius = 1.0f; /* Quite warnings */ float co[3]; @@ -1853,7 +1853,7 @@ float BKE_brush_sample_masktex( } if (mtex->brush_map_mode == MTEX_MAP_MODE_STENCIL) { float rotation = -mtex->rot; - float point_2d[2] = {point[0], point[1]}; + const float point_2d[2] = {point[0], point[1]}; float x, y; float co[3]; @@ -1883,7 +1883,7 @@ float BKE_brush_sample_masktex( } else { float rotation = -mtex->rot; - float point_2d[2] = {point[0], point[1]}; + const float point_2d[2] = {point[0], point[1]}; float x = 0.0f, y = 0.0f; /* Quite warnings */ float invradius = 1.0f; /* Quite warnings */ float co[3]; diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c index 467bd68c631..aa534250554 100644 --- a/source/blender/blenkernel/intern/cloth.c +++ b/source/blender/blenkernel/intern/cloth.c @@ -825,7 +825,7 @@ static int cloth_from_object( MVert *mvert = NULL; ClothVertex *verts = NULL; float(*shapekey_rest)[3] = NULL; - float tnull[3] = {0, 0, 0}; + const float tnull[3] = {0, 0, 0}; // If we have a clothObject, free it. if (clmd->clothObject != NULL) { diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index e126fb7f632..735ffdea86e 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -2301,7 +2301,7 @@ static void make_bevel_list_3D_tangent(BevList *bl) while (nr--) { /* make perpendicular, modify tan in place, is ok */ float cross_tmp[3]; - float zero[3] = {0, 0, 0}; + const float zero[3] = {0, 0, 0}; cross_v3_v3v3(cross_tmp, bevp1->tan, bevp1->dir); normalize_v3(cross_tmp); diff --git a/source/blender/blenkernel/intern/curveprofile.c b/source/blender/blenkernel/intern/curveprofile.c index 0c9b71fad5d..068f8845e64 100644 --- a/source/blender/blenkernel/intern/curveprofile.c +++ b/source/blender/blenkernel/intern/curveprofile.c @@ -254,7 +254,7 @@ void BKE_curveprofile_remove_by_flag(CurveProfile *profile, const short flag) CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float y) { CurveProfilePoint *new_pt = NULL; - float new_loc[2] = {x, y}; + const float new_loc[2] = {x, y}; /* Don't add more control points than the maximum size of the higher resolution table. */ if (profile->path_len == PROF_TABLE_MAX - 1) { @@ -266,8 +266,8 @@ CurveProfilePoint *BKE_curveprofile_insert(CurveProfile *profile, float x, float float min_distance = FLT_MAX; int i_insert = 0; for (int i = 0; i < profile->path_len - 1; i++) { - float loc1[2] = {profile->path[i].x, profile->path[i].y}; - float loc2[2] = {profile->path[i + 1].x, profile->path[i + 1].y}; + const float loc1[2] = {profile->path[i].x, profile->path[i].y}; + const float loc2[2] = {profile->path[i + 1].x, profile->path[i + 1].y}; distance = dist_squared_to_line_segment_v2(new_loc, loc1, loc2); if (distance < min_distance) { diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index 62fb7a937b2..b017f3b179f 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2675,7 +2675,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa int w = bdata->w, h = bdata->h, px = bdata->px, py = bdata->py; - int final_pixel[2] = {(int)floorf(tgt_pixel[0] * w), (int)floorf(tgt_pixel[1] * h)}; + const int final_pixel[2] = {(int)floorf(tgt_pixel[0] * w), (int)floorf(tgt_pixel[1] * h)}; /* If current pixel uv is outside of texture */ if (final_pixel[0] < 0 || final_pixel[0] >= w || final_pixel[1] < 0 || final_pixel[1] >= h) { diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c index 6acff73957c..8aebbbefb31 100644 --- a/source/blender/blenkernel/intern/fluid.c +++ b/source/blender/blenkernel/intern/fluid.c @@ -955,7 +955,7 @@ static void obstacles_from_mesh_task_cb(void *__restrict userdata, for (int y = data->min[1]; y < data->max[1]; y++) { const int index = manta_get_index( x - bb->min[0], bb->res[0], y - bb->min[1], bb->res[1], z - bb->min[2]); - float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f}; + const float ray_start[3] = {(float)x + 0.5f, (float)y + 0.5f, (float)z + 0.5f}; /* Calculate object velocities. Result in bb->velocity. */ sample_effector(data->fes, diff --git a/source/blender/blenkernel/intern/hair.c b/source/blender/blenkernel/intern/hair.c index 90761d24b73..2905bfc978a 100644 --- a/source/blender/blenkernel/intern/hair.c +++ b/source/blender/blenkernel/intern/hair.c @@ -202,8 +202,8 @@ BoundBox *BKE_hair_boundbox_get(Object *ob) for (int a = 0; a < hair->totpoint; a++) { float *co = hair_co[a]; float radius = (hair_radius) ? hair_radius[a] : 0.0f; - float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; - float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; + const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; + const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; DO_MIN(co_min, min); DO_MAX(co_max, max); } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 44c24f5a4d1..363706ca969 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -1917,7 +1917,7 @@ static void psys_particle_on_shape(int UNUSED(distr), float orco[3]) { /* TODO */ - float zerovec[3] = {0.0f, 0.0f, 0.0f}; + const float zerovec[3] = {0.0f, 0.0f, 0.0f}; if (vec) { copy_v3_v3(vec, zerovec); } @@ -2168,10 +2168,10 @@ int do_guides(Depsgraph *depsgraph, { ParticleKey key; - float par_co[3] = {0.0f, 0.0f, 0.0f}; - float par_vel[3] = {0.0f, 0.0f, 0.0f}; - float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f}; - float orco_offset[3] = {0.0f, 0.0f, 0.0f}; + const float par_co[3] = {0.0f, 0.0f, 0.0f}; + const float par_vel[3] = {0.0f, 0.0f, 0.0f}; + const float par_rot[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float orco_offset[3] = {0.0f, 0.0f, 0.0f}; copy_v3_v3(key.co, vec_to_point); do_kink(&key, @@ -4692,7 +4692,7 @@ int psys_get_particle_state(ParticleSimulationData *sim, int p, ParticleKey *sta float mat[4][4]; ParticleKey *key1; float t = (cfra - pa->time) / pa->lifetime; - float par_orco[3] = {0.0f, 0.0f, 0.0f}; + const float par_orco[3] = {0.0f, 0.0f, 0.0f}; key1 = &pa->state; offset_child(cpa, key1, key1->rot, state, part->childflat, part->childrad); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index e74c13680e2..7bfc0ca764f 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4365,7 +4365,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, max_size = MAX3(size[0] / (float)upres, size[1] / (float)upres, size[2] / (float)upres); /* Set particle position. */ - float posParticle[3] = {posX, posY, posZ}; + const float posParticle[3] = {posX, posY, posZ}; copy_v3_v3(pa->state.co, posParticle); /* Normalize to unit cube around 0. */ @@ -4398,7 +4398,7 @@ static void particles_fluid_step(ParticleSimulationData *sim, pa->state.co[0], pa->state.co[1], pa->state.co[2]); # endif /* Set particle velocity. */ - float velParticle[3] = {velX, velY, velZ}; + const float velParticle[3] = {velX, velY, velZ}; copy_v3_v3(pa->state.vel, velParticle); mul_v3_fl(pa->state.vel, fds->dx); # if 0 diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c index fade3dad136..1dd22a0a28d 100644 --- a/source/blender/blenkernel/intern/pbvh.c +++ b/source/blender/blenkernel/intern/pbvh.c @@ -2345,7 +2345,7 @@ void BKE_pbvh_raycast_project_ray_root( struct IsectRayAABB_Precalc ray; float ray_normal_inv[3]; float offset = 1.0f + 1e-3f; - float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f}; + const float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f}; if (original) { BKE_pbvh_node_get_original_BB(pbvh->nodes, bb_min_root, bb_max_root); diff --git a/source/blender/blenkernel/intern/pointcloud.c b/source/blender/blenkernel/intern/pointcloud.c index df5d93beccb..21889acba3c 100644 --- a/source/blender/blenkernel/intern/pointcloud.c +++ b/source/blender/blenkernel/intern/pointcloud.c @@ -169,8 +169,8 @@ BoundBox *BKE_pointcloud_boundbox_get(Object *ob) for (int a = 0; a < pointcloud->totpoint; a++) { float *co = pointcloud_co[a]; float radius = (pointcloud_radius) ? pointcloud_radius[a] : 0.0f; - float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; - float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; + const float co_min[3] = {co[0] - radius, co[1] - radius, co[2] - radius}; + const float co_max[3] = {co[0] + radius, co[1] + radius, co[2] + radius}; DO_MIN(co_min, min); DO_MAX(co_max, max); } diff --git a/source/blender/blenkernel/intern/seqmodifier.c b/source/blender/blenkernel/intern/seqmodifier.c index 0bf7fffb833..a38fe252731 100644 --- a/source/blender/blenkernel/intern/seqmodifier.c +++ b/source/blender/blenkernel/intern/seqmodifier.c @@ -393,8 +393,8 @@ static void curves_apply(struct SequenceModifierData *smd, ImBuf *ibuf, ImBuf *m { CurvesModifierData *cmd = (CurvesModifierData *)smd; - float black[3] = {0.0f, 0.0f, 0.0f}; - float white[3] = {1.0f, 1.0f, 1.0f}; + const float black[3] = {0.0f, 0.0f, 0.0f}; + const float white[3] = {1.0f, 1.0f, 1.0f}; BKE_curvemapping_init(&cmd->curve_mapping); diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c index a02e4b2052c..6cdebcab904 100644 --- a/source/blender/blenkernel/intern/sequencer.c +++ b/source/blender/blenkernel/intern/sequencer.c @@ -2422,7 +2422,7 @@ static void color_balance_byte_float(StripColorBalance *cb_, while (p < e) { if (m) { - float t[3] = {m[0] / 255.0f, m[1] / 255.0f, m[2] / 255.0f}; + const float t[3] = {m[0] / 255.0f, m[1] / 255.0f, m[2] / 255.0f}; p[0] = p[0] * (1.0f - t[0]) + t[0] * cb_tab[0][p[0]]; p[1] = p[1] * (1.0f - t[1]) + t[1] * cb_tab[1][p[1]]; diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 25859e55d27..0ff5bdda9e9 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -760,7 +760,7 @@ static void target_project_tri_deviation(void *userdata, const float x[3], float { TargetProjectTriData *data = userdata; - float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]}; + const float w[3] = {x[0], x[1], 1.0f - x[0] - x[1]}; interp_v3_v3v3v3(data->co_interp, data->vtri_co[0], data->vtri_co[1], data->vtri_co[2], w); interp_v3_v3v3v3(data->no_interp, data->vtri_no[0], data->vtri_no[1], data->vtri_no[2], w); diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index ade5befeebf..68626bdc8dd 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -1243,7 +1243,7 @@ static int studiolight_cmp(const void *a, const void *b) static uint alpha_circle_mask(float u, float v, float inner_edge, float outer_edge) { /* Coords from center. */ - float co[2] = {u - 0.5f, v - 0.5f}; + const float co[2] = {u - 0.5f, v - 0.5f}; float dist = len_v2(co); float alpha = 1.0f + (inner_edge - dist) / (outer_edge - inner_edge); uint mask = (uint)floorf(255.0f * min_ff(max_ff(alpha, 0.0f), 1.0f)); @@ -1275,7 +1275,7 @@ static void studiolight_radiance_preview(uint *icon_buffer, StudioLight *sl) uint alphamask = alpha_circle_mask(dx, dy, 0.5f - texel_size[0], 0.5f); if (alphamask != 0) { float normal[3], direction[3], color[4]; - float incoming[3] = {0.0f, 0.0f, -1.0f}; + const float incoming[3] = {0.0f, 0.0f, -1.0f}; sphere_normal_from_uv(normal, dx, dy); reflect_v3_v3v3(direction, incoming, normal); /* We want to see horizon not poles. */ diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 9202635210c..37cca12721a 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -1040,7 +1040,7 @@ static void subdiv_foreach_boundary_edges(SubdivForeachTaskContext *ctx, static void rotate_indices(const int rot, int *a, int *b, int *c, int *d) { - int values[4] = {*a, *b, *c, *d}; + const int values[4] = {*a, *b, *c, *d}; *a = values[(0 - rot + 4) % 4]; *b = values[(1 - rot + 4) % 4]; *c = values[(2 - rot + 4) % 4]; diff --git a/source/blender/blenkernel/intern/tracking_stabilize.c b/source/blender/blenkernel/intern/tracking_stabilize.c index 65eb3d89420..46e3e10b01b 100644 --- a/source/blender/blenkernel/intern/tracking_stabilize.c +++ b/source/blender/blenkernel/intern/tracking_stabilize.c @@ -1092,7 +1092,7 @@ static void stabilization_data_to_mat4(float pixel_aspect, { float translation_mat[4][4], rotation_mat[4][4], scale_mat[4][4], pivot_mat[4][4], inv_pivot_mat[4][4], aspect_mat[4][4], inv_aspect_mat[4][4]; - float scale_vector[3] = {scale, scale, 1.0f}; + const float scale_vector[3] = {scale, scale, 1.0f}; unit_m4(translation_mat); unit_m4(rotation_mat); diff --git a/source/blender/blenlib/intern/lasso_2d.c b/source/blender/blenlib/intern/lasso_2d.c index f2cc8d42de7..a3b111cf0f2 100644 --- a/source/blender/blenlib/intern/lasso_2d.c +++ b/source/blender/blenlib/intern/lasso_2d.c @@ -61,7 +61,7 @@ bool BLI_lasso_is_point_inside(const int mcoords[][2], return false; } - int pt[2] = {sx, sy}; + const int pt[2] = {sx, sy}; return isect_point_poly_v2_int(pt, mcoords, mcoords_len, true); } diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c index ce83b522178..eff58f305d2 100644 --- a/source/blender/blenlib/intern/math_geom.c +++ b/source/blender/blenlib/intern/math_geom.c @@ -2094,7 +2094,7 @@ bool isect_ray_seg_v2(const float ray_origin[2], det = cross_v2v2(ray_direction, s10); if (det != 0.0f) { const float v = cross_v2v2(v0_local, v1_local); - float p[2] = {(ray_direction[0] * v) / det, (ray_direction[1] * v) / det}; + const float p[2] = {(ray_direction[0] * v) / det, (ray_direction[1] * v) / det}; const float t = (dot_v2v2(p, ray_direction) / dot_v2v2(ray_direction, ray_direction)); if ((t >= 0.0f) == 0) { @@ -5106,7 +5106,7 @@ void map_to_sphere(float *r_u, float *r_v, const float x, const float y, const f void map_to_plane_v2_v3v3(float r_co[2], const float co[3], const float no[3]) { - float target[3] = {0.0f, 0.0f, 1.0f}; + const float target[3] = {0.0f, 0.0f, 1.0f}; float axis[3]; cross_v3_v3v3(axis, no, target); diff --git a/source/blender/blenlib/intern/math_interp.c b/source/blender/blenlib/intern/math_interp.c index 6277b1cd9dc..13a1816f1bd 100644 --- a/source/blender/blenlib/intern/math_interp.c +++ b/source/blender/blenlib/intern/math_interp.c @@ -286,7 +286,7 @@ BLI_INLINE void bilinear_interpolation(const unsigned char *byte_buffer, if (float_output) { const float *row1, *row2, *row3, *row4; - float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float empty[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* pixel value must be already wrapped, however values at boundaries may flip */ if (wrap_x) { diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index e8298f4dffc..4bc7a74a3f7 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -295,7 +295,7 @@ static bool quad_co(const float v1[3], float r_uv[2]) { float projverts[5][3], n2[3]; - float origin[2] = {0.0f, 0.0f}; + const float origin[2] = {0.0f, 0.0f}; int i; /* project points into 2d along normal */ diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index f263392bdd2..8900d5b8209 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -1919,9 +1919,11 @@ static void calculate_profile_segments(const Profile *profile, } else { if (use_map) { - float p[3] = {reversed ? (float)yvals[ns - k] : (float)xvals[k], - reversed ? (float)xvals[ns - k] : (float)yvals[k], - 0.0f}; + const float p[3] = { + reversed ? (float)yvals[ns - k] : (float)xvals[k], + reversed ? (float)xvals[ns - k] : (float)yvals[k], + 0.0f, + }; /* Do the 2D->3D transformation of the profile coordinates. */ mul_v3_m4v3(co, map, p); } diff --git a/source/blender/bmesh/tools/bmesh_intersect.c b/source/blender/bmesh/tools/bmesh_intersect.c index 6426fe9c687..371d8d59d6c 100644 --- a/source/blender/bmesh/tools/bmesh_intersect.c +++ b/source/blender/bmesh/tools/bmesh_intersect.c @@ -898,7 +898,7 @@ static int isect_bvhtree_point_v3(BVHTree *tree, const float **looptris, const f &z_buffer, }; BVHTreeRayHit hit = {0}; - float dir[3] = {1.0f, 0.0f, 0.0f}; + const float dir[3] = {1.0f, 0.0f, 0.0f}; /* Need to initialize hit even tho it's not used. * This is to make it so kd-tree believes we didn't intersect anything and diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index 05cd6426911..1d8082538a8 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -261,7 +261,7 @@ void EEVEE_depth_of_field_draw(EEVEE_Data *vedata) /* Depth Of Field */ if ((effects->enabled_effects & EFFECT_DOF) != 0) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Downsample */ GPU_framebuffer_bind(fbl->dof_down_fb); diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c index f6e74c6822c..365ba0afaac 100644 --- a/source/blender/draw/engines/eevee/eevee_effects.c +++ b/source/blender/draw/engines/eevee/eevee_effects.c @@ -138,7 +138,7 @@ void EEVEE_effects_init(EEVEE_ViewLayerData *sldata, DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); const float *viewport_size = DRW_viewport_size_get(); - int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]}; + const int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]}; /* Shaders */ if (!e_data.downsample_sh) { diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index d77c6600026..72f008ea66a 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -217,10 +217,10 @@ static void eevee_draw_scene(void *vedata) } while (loop_len--) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float clear_depth = 1.0f; uint clear_stencil = 0x0; - uint primes[3] = {2, 3, 7}; + const uint primes[3] = {2, 3, 7}; double offset[3] = {0.0, 0.0, 0.0}; double r[3]; diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 38f5536170e..cb41d3dbd8d 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -863,7 +863,7 @@ static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lb /* HACK: set txl->color but unset it before Draw Manager frees it. */ txl->color = lbake->rt_color; - int viewport_size[2] = { + const int viewport_size[2] = { GPU_texture_width(txl->color), GPU_texture_height(txl->color), }; diff --git a/source/blender/draw/engines/eevee/eevee_lightprobes.c b/source/blender/draw/engines/eevee/eevee_lightprobes.c index 47a913640c7..0f4a9dc79b6 100644 --- a/source/blender/draw/engines/eevee/eevee_lightprobes.c +++ b/source/blender/draw/engines/eevee/eevee_lightprobes.c @@ -1112,7 +1112,7 @@ void EEVEE_lightbake_filter_diffuse(EEVEE_ViewLayerData *sldata, #if defined(IRRADIANCE_SH_L2) int size[2] = {3, 3}; #elif defined(IRRADIANCE_HL2) - int size[2] = {3, 2}; + const int size[2] = {3, 2}; pinfo->samples_len = 1024.0f; #endif diff --git a/source/blender/draw/engines/eevee/eevee_lookdev.c b/source/blender/draw/engines/eevee/eevee_lookdev.c index 403a8e2af55..f79d90500bd 100644 --- a/source/blender/draw/engines/eevee/eevee_lookdev.c +++ b/source/blender/draw/engines/eevee/eevee_lookdev.c @@ -245,7 +245,7 @@ static void eevee_lookdev_apply_taa(const EEVEE_EffectsInfo *effects, if (DRW_state_is_image_render() || ((effects->enabled_effects & EFFECT_TAA) != 0)) { double ht_point[2]; double ht_offset[2] = {0.0, 0.0}; - uint ht_primes[2] = {2, 3}; + const uint ht_primes[2] = {2, 3}; float ofs[2]; BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample, ht_point); diff --git a/source/blender/draw/engines/eevee/eevee_materials.c b/source/blender/draw/engines/eevee/eevee_materials.c index 4f97fe99b27..fb07208be47 100644 --- a/source/blender/draw/engines/eevee/eevee_materials.c +++ b/source/blender/draw/engines/eevee/eevee_materials.c @@ -907,7 +907,7 @@ static void material_renderpass_init(EEVEE_FramebufferList *fbl, DRW_texture_ensure_fullscreen_2d(output_tx, format, 0); /* Clear texture. */ if (do_clear) { - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* TODO(fclem) replace by GPU_texture_clear once it is fast. */ GPU_framebuffer_texture_attach(fbl->material_accum_fb, *output_tx, 0, 0); GPU_framebuffer_bind(fbl->material_accum_fb); diff --git a/source/blender/draw/engines/eevee/eevee_mist.c b/source/blender/draw/engines/eevee/eevee_mist.c index d2f3a13eb7c..cfac6cc4d62 100644 --- a/source/blender/draw/engines/eevee/eevee_mist.c +++ b/source/blender/draw/engines/eevee/eevee_mist.c @@ -53,7 +53,7 @@ void EEVEE_mist_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) EEVEE_PrivateData *g_data = stl->g_data; Scene *scene = draw_ctx->scene; - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; if (e_data.mist_sh == NULL) { DRWShaderLibrary *lib = EEVEE_shader_lib_get(); diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c index 4e49136a6bc..2a315927015 100644 --- a/source/blender/draw/engines/eevee/eevee_motion_blur.c +++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c @@ -117,8 +117,10 @@ int EEVEE_motion_blur_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Data *veda } const float *fs_size = DRW_viewport_size_get(); - int tx_size[2] = {1 + ((int)fs_size[0] / EEVEE_VELOCITY_TILE_SIZE), - 1 + ((int)fs_size[1] / EEVEE_VELOCITY_TILE_SIZE)}; + const int tx_size[2] = { + 1 + ((int)fs_size[0] / EEVEE_VELOCITY_TILE_SIZE), + 1 + ((int)fs_size[1] / EEVEE_VELOCITY_TILE_SIZE), + }; effects->velocity_tiles_x_tx = DRW_texture_pool_query_2d( tx_size[0], fs_size[1], GPU_RGBA16, &draw_engine_eevee_type); @@ -173,8 +175,10 @@ void EEVEE_motion_blur_cache_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat if ((effects->enabled_effects & EFFECT_MOTION_BLUR) != 0) { const float *fs_size = DRW_viewport_size_get(); - int tx_size[2] = {GPU_texture_width(effects->velocity_tiles_tx), - GPU_texture_height(effects->velocity_tiles_tx)}; + const int tx_size[2] = { + GPU_texture_width(effects->velocity_tiles_tx), + GPU_texture_height(effects->velocity_tiles_tx), + }; eevee_motion_blur_sync_camera(vedata); diff --git a/source/blender/draw/engines/eevee/eevee_occlusion.c b/source/blender/draw/engines/eevee/eevee_occlusion.c index 1929bbb9b98..9aae801197f 100644 --- a/source/blender/draw/engines/eevee/eevee_occlusion.c +++ b/source/blender/draw/engines/eevee/eevee_occlusion.c @@ -74,7 +74,7 @@ int EEVEE_occlusion_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); if (!e_data.dummy_horizon_tx) { - float pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float pixel[4] = {0.0f, 0.0f, 0.0f, 0.0f}; e_data.dummy_horizon_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, pixel); } @@ -143,7 +143,7 @@ void EEVEE_occlusion_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata const eGPUTextureFormat texture_format = (tot_samples > 128) ? GPU_R32F : GPU_R16F; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Should be enough precision for many samples. */ DRW_texture_ensure_fullscreen_2d(&txl->ao_accum, texture_format, 0); diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index b6b8833b1da..62698bc5da3 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -93,8 +93,10 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * copy_v4_fl4(camtexcofac, 1.0f, 1.0f, 0.0f, 0.0f); } - int final_res[2] = {size_orig[0] + g_data->overscan_pixels * 2.0f, - size_orig[1] + g_data->overscan_pixels * 2.0f}; + const int final_res[2] = { + size_orig[0] + g_data->overscan_pixels * 2.0f, + size_orig[1] + g_data->overscan_pixels * 2.0f, + }; int max_dim = max_ii(final_res[0], final_res[1]); if (max_dim > GPU_max_texture_size()) { @@ -523,10 +525,10 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl } while (render_samples < tot_sample && !RE_engine_test_break(engine)) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float clear_depth = 1.0f; uint clear_stencil = 0x00; - uint primes[3] = {2, 3, 7}; + const uint primes[3] = {2, 3, 7}; double offset[3] = {0.0, 0.0, 0.0}; double r[3]; diff --git a/source/blender/draw/engines/eevee/eevee_sampling.c b/source/blender/draw/engines/eevee/eevee_sampling.c index 5e951928c5a..253dae79902 100644 --- a/source/blender/draw/engines/eevee/eevee_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_sampling.c @@ -34,7 +34,7 @@ void EEVEE_sample_ball(int sample_ofs, float radius, float rsample[3]) { double ht_point[3]; double ht_offset[3] = {0.0, 0.0, 0.0}; - uint ht_primes[3] = {2, 3, 7}; + const uint ht_primes[3] = {2, 3, 7}; BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point); @@ -65,7 +65,7 @@ void EEVEE_sample_rectangle(int sample_ofs, { double ht_point[2]; double ht_offset[2] = {0.0, 0.0}; - uint ht_primes[2] = {2, 3}; + const uint ht_primes[2] = {2, 3}; BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point); @@ -91,7 +91,7 @@ void EEVEE_sample_ellipse(int sample_ofs, { double ht_point[2]; double ht_offset[2] = {0.0, 0.0}; - uint ht_primes[2] = {2, 3}; + const uint ht_primes[2] = {2, 3}; BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point); @@ -114,7 +114,7 @@ void EEVEE_random_rotation_m4(int sample_ofs, float scale, float r_mat[4][4]) { double ht_point[3]; double ht_offset[3] = {0.0, 0.0, 0.0}; - uint ht_primes[3] = {2, 3, 5}; + const uint ht_primes[3] = {2, 3, 5}; BLI_halton_3d(ht_primes, ht_offset, sample_ofs, ht_point); diff --git a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c index a1755e60c06..88029c2e940 100644 --- a/source/blender/draw/engines/eevee/eevee_screen_raytrace.c +++ b/source/blender/draw/engines/eevee/eevee_screen_raytrace.c @@ -138,7 +138,7 @@ int EEVEE_screen_raytrace_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) const int divisor = (effects->reflection_trace_full) ? 1 : 2; int tracing_res[2] = {(int)viewport_size[0] / divisor, (int)viewport_size[1] / divisor}; - int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]}; + const int size_fs[2] = {(int)viewport_size[0], (int)viewport_size[1]}; const bool high_qual_input = true; /* TODO dither low quality input */ const eGPUTextureFormat format = (high_qual_input) ? GPU_RGBA16F : GPU_RGBA8; @@ -330,7 +330,7 @@ void EEVEE_reflection_output_init(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_StorageList *stl = vedata->stl; EEVEE_EffectsInfo *effects = stl->effects; - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Create FrameBuffer. */ const eGPUTextureFormat texture_format = (tot_samples > 256) ? GPU_RGBA32F : GPU_RGBA16F; diff --git a/source/blender/draw/engines/eevee/eevee_shadows.c b/source/blender/draw/engines/eevee/eevee_shadows.c index 0da356b75ac..71a4da9fcab 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows.c +++ b/source/blender/draw/engines/eevee/eevee_shadows.c @@ -385,7 +385,7 @@ void EEVEE_shadow_output_init(EEVEE_ViewLayerData *sldata, EEVEE_EffectsInfo *effects = stl->effects; DefaultTextureList *dtxl = DRW_viewport_texture_list_get(); - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Create FrameBuffer. */ const eGPUTextureFormat texture_format = GPU_R32F; diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c index 1fd8d818b33..246bc18b71a 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows_cascade.c +++ b/source/blender/draw/engines/eevee/eevee_shadows_cascade.c @@ -139,7 +139,7 @@ static void eevee_shadow_cascade_setup(EEVEE_LightsInfo *linfo, float jitter_ofs[2]; double ht_point[2]; double ht_offset[2] = {0.0, 0.0}; - uint ht_primes[2] = {2, 3}; + const uint ht_primes[2] = {2, 3}; BLI_halton_2d(ht_primes, ht_offset, sample_ofs, ht_point); diff --git a/source/blender/draw/engines/eevee/eevee_subsurface.c b/source/blender/draw/engines/eevee/eevee_subsurface.c index 637c5201afc..74fb7ac99b7 100644 --- a/source/blender/draw/engines/eevee/eevee_subsurface.c +++ b/source/blender/draw/engines/eevee/eevee_subsurface.c @@ -166,7 +166,7 @@ void EEVEE_subsurface_output_init(EEVEE_ViewLayerData *UNUSED(sldata), * pass in look dev mode active. `texture_created` will make sure that newly created textures * are cleared. */ if (effects->taa_current_sample == 1 || texture_created) { - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPU_framebuffer_bind(fbl->sss_accum_fb); GPU_framebuffer_clear_color(fbl->sss_accum_fb, clear); } @@ -282,7 +282,7 @@ void EEVEE_subsurface_data_render(EEVEE_ViewLayerData *UNUSED(sldata), EEVEE_Dat EEVEE_EffectsInfo *effects = stl->effects; if ((effects->enabled_effects & EFFECT_SSS) != 0) { - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Clear sss_data texture only... can this be done in a more clever way? */ GPU_framebuffer_bind(fbl->sss_clear_fb); GPU_framebuffer_clear_color(fbl->sss_clear_fb, clear); @@ -320,7 +320,7 @@ void EEVEE_subsurface_compute(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) EEVEE_EffectsInfo *effects = stl->effects; if ((effects->enabled_effects & EFFECT_SSS) != 0) { - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; DRW_stats_group_start("SSS"); diff --git a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c index e184a80d2f6..12b50030435 100644 --- a/source/blender/draw/engines/eevee/eevee_temporal_sampling.c +++ b/source/blender/draw/engines/eevee/eevee_temporal_sampling.c @@ -171,7 +171,7 @@ void EEVEE_temporal_sampling_update_matrices(EEVEE_Data *vedata) double ht_point[2]; double ht_offset[2] = {0.0, 0.0}; - uint ht_primes[2] = {2, 3}; + const uint ht_primes[2] = {2, 3}; BLI_halton_2d(ht_primes, ht_offset, effects->taa_current_sample - 1, ht_point); diff --git a/source/blender/draw/engines/eevee/eevee_volumes.c b/source/blender/draw/engines/eevee/eevee_volumes.c index 57d5e54290e..e1e65c29b4f 100644 --- a/source/blender/draw/engines/eevee/eevee_volumes.c +++ b/source/blender/draw/engines/eevee/eevee_volumes.c @@ -149,7 +149,7 @@ void EEVEE_volumes_set_jitter(EEVEE_ViewLayerData *sldata, uint current_sample) double ht_point[3]; double ht_offset[3] = {0.0, 0.0}; - uint ht_primes[3] = {3, 7, 2}; + const uint ht_primes[3] = {3, 7, 2}; BLI_halton_3d(ht_primes, ht_offset, current_sample, ht_point); @@ -279,8 +279,8 @@ void EEVEE_volumes_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata) common_data->vol_use_lights = (scene_eval->eevee.flag & SCE_EEVEE_VOLUMETRIC_LIGHTS) != 0; if (!e_data.dummy_scatter) { - float scatter[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - float transmit[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const float scatter[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float transmit[4] = {1.0f, 1.0f, 1.0f, 1.0f}; e_data.dummy_scatter = DRW_texture_create_3d(1, 1, 1, GPU_RGBA8, DRW_TEX_WRAP, scatter); e_data.dummy_transmit = DRW_texture_create_3d(1, 1, 1, GPU_RGBA8, DRW_TEX_WRAP, transmit); } @@ -852,7 +852,7 @@ void EEVEE_volumes_output_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, EEVEE_PassList *psl = vedata->psl; EEVEE_EffectsInfo *effects = stl->effects; - float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear[4] = {0.0f, 0.0f, 0.0f, 0.0f}; /* Create FrameBuffer. */ diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 3ef20dbe9ec..36d295d1dde 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -268,7 +268,7 @@ static void external_draw_scene(void *vedata) * OpenGL render is used for quick preview (thumbnails or sequencer preview) * where using the rendering engine to preview doesn't make so much sense. */ if (draw_ctx->evil_C) { - float clear_col[4] = {0, 0, 0, 0}; + const float clear_col[4] = {0, 0, 0, 0}; /* This is to keep compatibility with external engine. */ /* TODO(fclem) remove it eventually. */ GPU_framebuffer_bind(dfbl->default_fb); diff --git a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c index 8955240c549..b9600ad8caf 100644 --- a/source/blender/draw/engines/gpencil/gpencil_antialiasing.c +++ b/source/blender/draw/engines/gpencil/gpencil_antialiasing.c @@ -36,7 +36,7 @@ void GPENCIL_antialiasing_init(struct GPENCIL_Data *vedata) const float *size = DRW_viewport_size_get(); const float *sizeinv = DRW_viewport_invert_size_get(); - float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]}; + const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]}; if (pd->simplify_antialias) { /* No AA fallback. */ diff --git a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c index 41a7196cb90..363794e1be3 100644 --- a/source/blender/draw/engines/gpencil/gpencil_cache_utils.c +++ b/source/blender/draw/engines/gpencil/gpencil_cache_utils.c @@ -245,7 +245,7 @@ static void gpencil_layer_random_color_get(const Object *ob, uint ob_hash = BLI_ghashutil_strhash_p_murmur(ob->id.name); uint gpl_hash = BLI_ghashutil_strhash_p_murmur(gpl->info); float hue = BLI_hash_int_01(ob_hash * gpl_hash); - float hsv[3] = {hue, hsv_saturation, hsv_value}; + const float hsv[3] = {hue, hsv_saturation, hsv_value}; hsv_to_rgb_v(hsv, r_color); } diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c index dbad226099e..746920e38c6 100644 --- a/source/blender/draw/engines/gpencil/gpencil_engine.c +++ b/source/blender/draw/engines/gpencil/gpencil_engine.c @@ -71,7 +71,7 @@ void GPENCIL_engine_init(void *ved) } if (txl->dummy_texture == NULL) { - float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}}; + const float pixels[1][4] = {{1.0f, 0.0f, 1.0f, 1.0f}}; txl->dummy_texture = DRW_texture_create_2d(1, 1, GPU_RGBA8, DRW_TEX_WRAP, (float *)pixels); } @@ -766,7 +766,7 @@ static void gpencil_draw_mask(GPENCIL_Data *vedata, GPENCIL_tObject *ob, GPENCIL { GPENCIL_PassList *psl = vedata->psl; GPENCIL_FramebufferList *fbl = vedata->fbl; - float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const float clear_col[4] = {1.0f, 1.0f, 1.0f, 1.0f}; float clear_depth = ob->is_drawmode3d ? 1.0f : 0.0f; bool inverted = false; /* OPTI(fclem) we could optimize by only clearing if the new mask_bits does not contain all @@ -813,7 +813,7 @@ static void GPENCIL_draw_object(GPENCIL_Data *vedata, GPENCIL_tObject *ob) GPENCIL_PassList *psl = vedata->psl; GPENCIL_PrivateData *pd = vedata->stl->pd; GPENCIL_FramebufferList *fbl = vedata->fbl; - float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}; + const float clear_cols[2][4] = {{0.0f, 0.0f, 0.0f, 0.0f}, {1.0f, 1.0f, 1.0f, 1.0f}}; DRW_stats_group_start("GPencil Object"); diff --git a/source/blender/draw/engines/gpencil/gpencil_render.c b/source/blender/draw/engines/gpencil/gpencil_render.c index c3294f88acf..df52b65aa78 100644 --- a/source/blender/draw/engines/gpencil/gpencil_render.c +++ b/source/blender/draw/engines/gpencil/gpencil_render.c @@ -129,7 +129,7 @@ void GPENCIL_render_init(GPENCIL_Data *vedata, /* To avoid unpredictable result, clear buffers that have not be initialized. */ GPU_framebuffer_bind(fbl->render_fb); if (do_clear_col) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPU_framebuffer_clear_color(fbl->render_fb, clear_col); } if (do_clear_z) { diff --git a/source/blender/draw/engines/overlay/overlay_antialiasing.c b/source/blender/draw/engines/overlay/overlay_antialiasing.c index a32242d6292..9e95e860d0a 100644 --- a/source/blender/draw/engines/overlay/overlay_antialiasing.c +++ b/source/blender/draw/engines/overlay/overlay_antialiasing.c @@ -69,7 +69,7 @@ void OVERLAY_antialiasing_init(OVERLAY_Data *vedata) /* Small texture which will have very small impact on rendertime. */ if (txl->dummy_depth_tx == NULL) { - float pixel[1] = {1.0f}; + const float pixel[1] = {1.0f}; txl->dummy_depth_tx = DRW_texture_create_2d(1, 1, GPU_DEPTH_COMPONENT24, 0, pixel); } @@ -202,7 +202,7 @@ void OVERLAY_antialiasing_start(OVERLAY_Data *vedata) OVERLAY_PrivateData *pd = vedata->stl->pd; if (pd->antialiasing.enabled) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPU_framebuffer_bind(fbl->overlay_line_fb); GPU_framebuffer_clear_color(fbl->overlay_line_fb, clear_col); } diff --git a/source/blender/draw/engines/overlay/overlay_armature.c b/source/blender/draw/engines/overlay/overlay_armature.c index 1a3bfb9934c..6638f8e9e2e 100644 --- a/source/blender/draw/engines/overlay/overlay_armature.c +++ b/source/blender/draw/engines/overlay/overlay_armature.c @@ -601,7 +601,7 @@ static void drw_shgroup_bone_custom_empty(ArmatureDrawContext *ctx, const float color[4], Object *custom) { - float final_color[4] = {color[0], color[1], color[2], 1.0f}; + const float final_color[4] = {color[0], color[1], color[2], 1.0f}; float mat[4][4]; mul_m4_m4m4(mat, ctx->ob->obmat, bone_mat); diff --git a/source/blender/draw/engines/overlay/overlay_engine.c b/source/blender/draw/engines/overlay/overlay_engine.c index bc96a03da31..1312408498a 100644 --- a/source/blender/draw/engines/overlay/overlay_engine.c +++ b/source/blender/draw/engines/overlay/overlay_engine.c @@ -440,7 +440,7 @@ static void OVERLAY_draw_scene(void *vedata) DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); if (DRW_state_is_fbo()) { - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPU_framebuffer_bind(dfbl->overlay_only_fb); GPU_framebuffer_clear_color(dfbl->overlay_only_fb, clear_col); } diff --git a/source/blender/draw/engines/overlay/overlay_extra.c b/source/blender/draw/engines/overlay/overlay_extra.c index c7c4e2b1a3a..ce678c7d03f 100644 --- a/source/blender/draw/engines/overlay/overlay_extra.c +++ b/source/blender/draw/engines/overlay/overlay_extra.c @@ -277,7 +277,7 @@ void OVERLAY_extra_wire(OVERLAY_ExtraCallBuffers *cb, const float color[4]) { float draw_mat[4][4]; - float col[4] = {UNPACK3(color), 0.0f /* No stipples. */}; + const float col[4] = {UNPACK3(color), 0.0f /* No stipples. */}; pack_v4_in_mat4(draw_mat, mat, col); DRW_shgroup_call_obmat(cb->extra_wire, geom, draw_mat); } @@ -679,8 +679,8 @@ void OVERLAY_light_cache_populate(OVERLAY_Data *vedata, Object *ob) DRW_buffer_add_entry(cb->light_spot, color, &instdata); if ((la->mode & LA_SHOW_CONE) && !DRW_state_is_select()) { - float color_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f}; - float color_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f}; + const float color_inside[4] = {0.0f, 0.0f, 0.0f, 0.5f}; + const float color_outside[4] = {1.0f, 1.0f, 1.0f, 0.3f}; DRW_buffer_add_entry(cb->light_spot_cone_front, color_inside, &instdata); DRW_buffer_add_entry(cb->light_spot_cone_back, color_outside, &instdata); } @@ -1539,7 +1539,7 @@ void OVERLAY_extra_cache_populate(OVERLAY_Data *vedata, Object *ob) } /* Helpers for when we're transforming origins. */ if (draw_xform) { - float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f}; + const float color_xform[4] = {0.15f, 0.15f, 0.15f, 0.7f}; DRW_buffer_add_entry(cb->origin_xform, color_xform, ob->obmat); } /* don't show object extras in set's */ diff --git a/source/blender/draw/engines/overlay/overlay_image.c b/source/blender/draw/engines/overlay/overlay_image.c index 06d92f486d0..08cddf4e185 100644 --- a/source/blender/draw/engines/overlay/overlay_image.c +++ b/source/blender/draw/engines/overlay/overlay_image.c @@ -340,7 +340,7 @@ void OVERLAY_image_camera_cache_populate(OVERLAY_Data *vedata, Object *ob) mul_m4_m4m4(mat, modelmat, mat); const bool is_foreground = (bgpic->flag & CAM_BGIMG_FLAG_FOREGROUND) != 0; - float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha}; + const float color_premult_alpha[4] = {1.0f, 1.0f, 1.0f, bgpic->alpha}; DRWPass *pass = is_foreground ? psl->image_foreground_ps : psl->image_background_ps; diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c index 168f6f8a17f..0e5a52702fe 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.c +++ b/source/blender/draw/engines/overlay/overlay_motion_path.c @@ -149,7 +149,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, /* Draw curve-line of path. */ if (show_lines) { - int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame}; + const int motion_path_settings[4] = {cfra, sfra, efra, mpath->start_frame}; DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_lines_grp); DRW_shgroup_uniform_ivec4_copy(grp, "mpathLineSettings", motion_path_settings); DRW_shgroup_uniform_int_copy(grp, "lineThickness", mpath->line_thickness); @@ -162,7 +162,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, /* Draw points. */ { int pt_size = max_ii(mpath->line_thickness - 1, 1); - int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize}; + const int motion_path_settings[4] = {pt_size, cfra, mpath->start_frame, stepsize}; DRWShadingGroup *grp = DRW_shgroup_create_sub(pd->motion_path_points_grp); DRW_shgroup_uniform_ivec4_copy(grp, "mpathPointSettings", motion_path_settings); DRW_shgroup_uniform_bool_copy(grp, "showKeyFrames", show_keyframes); diff --git a/source/blender/draw/engines/overlay/overlay_outline.c b/source/blender/draw/engines/overlay/overlay_outline.c index 214322c4adc..e904066248f 100644 --- a/source/blender/draw/engines/overlay/overlay_outline.c +++ b/source/blender/draw/engines/overlay/overlay_outline.c @@ -342,7 +342,7 @@ void OVERLAY_outline_draw(OVERLAY_Data *vedata) { OVERLAY_FramebufferList *fbl = vedata->fbl; OVERLAY_PassList *psl = vedata->psl; - float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clearcol[4] = {0.0f, 0.0f, 0.0f, 0.0f}; bool do_outlines = psl->outlines_prepass_ps != NULL && !DRW_pass_is_empty(psl->outlines_prepass_ps); diff --git a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c index faf64b55c2d..47a03073839 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c +++ b/source/blender/draw/engines/workbench/workbench_effect_antialiasing.c @@ -301,7 +301,7 @@ void workbench_antialiasing_cache_init(WORKBENCH_Data *vedata) const float *size = DRW_viewport_size_get(); const float *sizeinv = DRW_viewport_invert_size_get(); - float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]}; + const float metrics[4] = {sizeinv[0], sizeinv[1], size[0], size[1]}; { /* Stage 1: Edge detection. */ diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index e13f7bfdd92..f2f75d616ff 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -155,7 +155,7 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata) } const float *full_size = DRW_viewport_size_get(); - int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)}; + const int size[2] = {max_ii(1, (int)full_size[0] / 2), max_ii(1, (int)full_size[1] / 2)}; #if 0 /* TODO(fclem) finish COC min_max optimisation */ /* NOTE: We Ceil here in order to not miss any edge texel if using a NPO2 texture. */ int shrink_h_size[2] = {ceilf(size[0] / 8.0f), size[1]}; diff --git a/source/blender/draw/engines/workbench/workbench_engine.c b/source/blender/draw/engines/workbench/workbench_engine.c index 53119723fab..ca80b6a9002 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.c +++ b/source/blender/draw/engines/workbench/workbench_engine.c @@ -64,7 +64,7 @@ void workbench_engine_init(void *ved) workbench_update_world_ubo(wpd); if (txl->dummy_image_tx == NULL) { - float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f}; + const float fpixel[4] = {1.0f, 0.0f, 1.0f, 1.0f}; txl->dummy_image_tx = DRW_texture_create_2d(1, 1, GPU_RGBA8, 0, fpixel); } wpd->dummy_image_tx = txl->dummy_image_tx; @@ -480,8 +480,8 @@ void workbench_draw_sample(void *ved) WORKBENCH_PrivateData *wpd = vedata->stl->wpd; WORKBENCH_PassList *psl = vedata->psl; DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get(); - float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + const float clear_col[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float clear_col_with_alpha[4] = {0.0f, 0.0f, 0.0f, 1.0f}; const bool do_render = workbench_antialiasing_setup(vedata); const bool xray_is_visible = wpd->shading.xray_alpha > 0.0f; diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 2ed63bac853..538083b4beb 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -60,7 +60,7 @@ void workbench_material_ubo_data(WORKBENCH_PrivateData *wpd, hash = (hash * 13) ^ BLI_ghashutil_strhash_p_murmur(ob->id.lib->filepath); } float hue = BLI_hash_int_01(hash); - float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE}; + const float hsv[3] = {hue, HSV_SATURATION, HSV_VALUE}; hsv_to_rgb_v(hsv, data->base_color); break; } diff --git a/source/blender/draw/engines/workbench/workbench_shadow.c b/source/blender/draw/engines/workbench/workbench_shadow.c index 2cf5f3c4c13..56a028d5a7e 100644 --- a/source/blender/draw/engines/workbench/workbench_shadow.c +++ b/source/blender/draw/engines/workbench/workbench_shadow.c @@ -62,7 +62,7 @@ static void workbench_shadow_update(WORKBENCH_PrivateData *wpd) wpd->shadow_cached_direction, wpd->shadow_direction_ws, 1e-5f); if (wpd->shadow_changed) { - float up[3] = {0.0f, 0.0f, 1.0f}; + const float up[3] = {0.0f, 0.0f, 1.0f}; unit_m4(wpd->shadow_mat); /* TODO fix singularity. */ @@ -229,7 +229,7 @@ static float workbench_shadow_object_shadow_distance(WORKBENCH_PrivateData *wpd, { BoundBox *shadow_bbox = workbench_shadow_object_shadow_bbox_get(wpd, ob, oed); - int corners[4] = {0, 3, 4, 7}; + const int corners[4] = {0, 3, 4, 7}; float dist = 1e4f, dist_isect; for (int i = 0; i < 4; i++) { if (isect_ray_plane_v3(shadow_bbox->vec[corners[i]], diff --git a/source/blender/draw/engines/workbench/workbench_volume.c b/source/blender/draw/engines/workbench/workbench_volume.c index d3c4d51dbd4..f71e77d5da5 100644 --- a/source/blender/draw/engines/workbench/workbench_volume.c +++ b/source/blender/draw/engines/workbench/workbench_volume.c @@ -43,8 +43,8 @@ void workbench_volume_engine_init(WORKBENCH_Data *vedata) WORKBENCH_TextureList *txl = vedata->txl; if (txl->dummy_volume_tx == NULL) { - float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - float one[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const float zero[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float one[4] = {1.0f, 1.0f, 1.0f, 1.0f}; txl->dummy_volume_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, zero, NULL); txl->dummy_shadow_tx = GPU_texture_create_3d(1, 1, 1, GPU_RGBA8, one, NULL); txl->dummy_coba_tx = GPU_texture_create_1d(1, GPU_RGBA8, zero, NULL); diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index b36a177c19f..d59c891fbeb 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -361,8 +361,8 @@ GPUBatch *DRW_cache_fullscreen_quad_get(void) if (!SHC.drw_fullscreen_quad) { /* Use a triangle instead of a real quad */ /* https://www.slideshare.net/DevCentralAMD/vertex-shader-tricks-bill-bilodeau - slide 14 */ - float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}}; - float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}}; + const float pos[3][2] = {{-1.0f, -1.0f}, {3.0f, -1.0f}, {-1.0f, 3.0f}}; + const float uvs[3][2] = {{0.0f, 0.0f}, {2.0f, 0.0f}, {0.0f, 2.0f}}; /* Position Only 2D format */ static GPUVertFormat format = {0}; @@ -400,7 +400,7 @@ GPUBatch *DRW_cache_quad_get(void) int v = 0; int flag = VCLASS_EMPTY_SCALED; - float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; + const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; for (int a = 0; a < 4; a++) { GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a][0], p[a][1], 0.0f}, flag}); } @@ -421,7 +421,7 @@ GPUBatch *DRW_cache_quad_wires_get(void) int v = 0; int flag = VCLASS_EMPTY_SCALED; - float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; + const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; for (int a = 0; a < 5; a++) { GPU_vertbuf_vert_set(vbo, v++, &(Vert){{p[a % 4][0], p[a % 4][1], 0.0f}, flag}); } @@ -1650,7 +1650,7 @@ GPUBatch *DRW_cache_light_area_square_lines_get(void) int flag = VCLASS_LIGHT_AREA_SHAPE; for (int a = 0; a < 4; a++) { for (int b = 0; b < 2; b++) { - float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; + const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; float x = p[(a + b) % 4][0]; float y = p[(a + b) % 4][1]; GPU_vertbuf_vert_set(vbo, v++, &(Vert){{x * 0.5f, y * 0.5f, 0.0f}, flag}); @@ -2659,7 +2659,7 @@ GPUBatch *DRW_cache_camera_frame_get(void) GPU_vertbuf_data_alloc(vbo, v_len); int v = 0; - float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; + const float p[4][2] = {{-1.0f, -1.0f}, {-1.0f, 1.0f}, {1.0f, 1.0f}, {1.0f, -1.0f}}; /* Frame */ for (int a = 0; a < 4; a++) { for (int b = 0; b < 2; b++) { @@ -2740,7 +2740,7 @@ GPUBatch *DRW_cache_camera_tria_wire_get(void) GPU_vertbuf_data_alloc(vbo, v_len); int v = 0; - float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}}; + const float p[3][2] = {{-1.0f, 1.0f}, {1.0f, 1.0f}, {0.0f, 0.0f}}; for (int a = 0; a < 3; a++) { for (int b = 0; b < 2; b++) { float x = p[(a + b) % 3][0]; @@ -3416,8 +3416,8 @@ GPUBatch *DRW_cache_cursor_get(bool crosshair_lines) const int vert_len = segments + 8; const int index_len = vert_len + 5; - uchar red[3] = {255, 0, 0}; - uchar white[3] = {255, 255, 255}; + const uchar red[3] = {255, 0, 0}; + const uchar white[3] = {255, 255, 255}; static GPUVertFormat format = {0}; static struct { diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c index 0f26a8ddc09..f0d73d5bb84 100644 --- a/source/blender/draw/intern/draw_common.c +++ b/source/blender/draw/intern/draw_common.c @@ -489,7 +489,7 @@ static void DRW_evaluate_weight_to_color(const float weight, float result[4]) * increasing widens yellow/cyan vs red/green/blue. * Gamma 1.0 produces the original 2.79 color ramp. */ const float gamma = 1.5f; - float hsv[3] = {(2.0f / 3.0f) * (1.0f - weight), 1.0f, pow(0.5f + 0.5f * weight, gamma)}; + const float hsv[3] = {(2.0f / 3.0f) * (1.0f - weight), 1.0f, pow(0.5f + 0.5f * weight, gamma)}; hsv_to_rgb_v(hsv, result); diff --git a/source/blender/draw/intern/draw_hair.c b/source/blender/draw/intern/draw_hair.c index cbdcbbf9090..1cbf3ee9d54 100644 --- a/source/blender/draw/intern/draw_hair.c +++ b/source/blender/draw/intern/draw_hair.c @@ -114,7 +114,7 @@ void DRW_hair_init(void) g_dummy_vbo = GPU_vertbuf_create_with_format(&format); - float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float vert[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPU_vertbuf_data_alloc(g_dummy_vbo, 1); GPU_vertbuf_attr_fill(g_dummy_vbo, dummy_id, vert); /* Create vbo immediately to bind to texture buffer. */ diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index d03b5107bb6..4a5e07476a9 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2030,7 +2030,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph, } } - int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}; + const int viewport_size[2] = {BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)}; struct GPUViewport *viewport = GPU_viewport_create(); GPU_viewport_size_set(viewport, viewport_size); diff --git a/source/blender/editors/curve/editcurve_add.c b/source/blender/editors/curve/editcurve_add.c index bacdd5b69b5..75d90df3291 100644 --- a/source/blender/editors/curve/editcurve_add.c +++ b/source/blender/editors/curve/editcurve_add.c @@ -397,8 +397,8 @@ Nurb *ED_curve_add_nurbs_primitive( break; case CU_PRIM_SPHERE: /* sphere */ if (cutype == CU_NURBS) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; + const float tmp_cent[3] = {0.f, 0.f, 0.f}; + const float tmp_vec[3] = {0.f, 0.f, 1.f}; nu->pntsu = 5; nu->pntsv = 1; @@ -451,8 +451,8 @@ Nurb *ED_curve_add_nurbs_primitive( break; case CU_PRIM_DONUT: /* torus */ if (cutype == CU_NURBS) { - float tmp_cent[3] = {0.f, 0.f, 0.f}; - float tmp_vec[3] = {0.f, 0.f, 1.f}; + const float tmp_cent[3] = {0.f, 0.f, 0.f}; + const float tmp_vec[3] = {0.f, 0.f, 1.f}; xzproj = 1; nu = ED_curve_add_nurbs_primitive(C, obedit, mat, CU_NURBS | CU_PRIM_CIRCLE, 0); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index d78c543f94b..4529209b297 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -648,7 +648,7 @@ static void txt_add_object(bContext *C, TextLine *firstline, int totline, const int nchars = 0, nbytes = 0; char *s; int a; - float rot[3] = {0.f, 0.f, 0.f}; + const float rot[3] = {0.f, 0.f, 0.f}; obedit = BKE_object_add(bmain, scene, view_layer, OB_FONT, NULL); base = view_layer->basact; diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index f31e004264c..341f43d0662 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -239,7 +239,7 @@ static int gizmo_arrow_test_select(bContext *UNUSED(C), wmGizmo *gz, const int m WM_gizmo_calc_matrix_final(gz, matrix_final); /* Arrow in pixel space. */ - float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]}; + const float arrow_start[2] = {matrix_final[3][0], matrix_final[3][1]}; float arrow_end[2]; { float co[3] = {0, 0, arrow_length}; diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index 04b93f35681..c5231b3cd96 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -99,7 +99,7 @@ static void button2d_geom_draw_backdrop(const wmGizmo *gz, else { /* Draw fill. */ if ((fill_alpha != 0.0f) || (select == true)) { - float fill_color[4] = {UNPACK3(color), fill_alpha * color[3]}; + const float fill_color[4] = {UNPACK3(color), fill_alpha * color[3]}; immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(fill_color); imm_draw_circle_fill_2d(pos, 0, 0, 1.0f, CIRCLE_RESOLUTION); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index 8955a666e22..0bc65fe10a5 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -257,7 +257,7 @@ static void cage3d_draw_circle_handles(const RegionView3D *rv3d, immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor3fv(color); - float sign[3] = {-1.0f, 0.0f, 1.0f}; + const float sign[3] = {-1.0f, 0.0f, 1.0f}; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index ab83abb6b37..b45a324bc67 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -573,14 +573,14 @@ static short annotation_stroke_addpoint(tGPsdata *p, /* Arrow end corner. */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_END) { pt++; - float e_heading[2] = {start[0] - end[0], start[1] - end[1]}; + const float e_heading[2] = {start[0] - end[0], start[1] - end[1]}; /* Calculate points for ending arrow. */ annotation_stroke_arrow_calc_points( pt, e_heading, end, gpd->runtime.arrow_end, gpd->runtime.arrow_end_style); } /* Arrow start corner. */ if (gpd->runtime.sbuffer_sflag & GP_STROKE_USE_ARROW_START) { - float s_heading[2] = {end[0] - start[0], end[1] - start[1]}; + const float s_heading[2] = {end[0] - start[0], end[1] - start[1]}; /* Calculate points for starting arrow. */ annotation_stroke_arrow_calc_points( NULL, s_heading, start, gpd->runtime.arrow_start, gpd->runtime.arrow_start_style); @@ -704,7 +704,7 @@ static void annotation_stroke_arrow_init_point( tGPsdata *p, tGPspoint *ptc, bGPDspoint *pt, const float co[8], const int co_idx) { /* Note: provided co_idx should be always pair number as it's [x1, y1, x2, y2, x3, y3]. */ - float real_co[2] = {co[co_idx], co[co_idx + 1]}; + const float real_co[2] = {co[co_idx], co[co_idx + 1]}; copy_v2_v2(&ptc->x, real_co); annotation_stroke_convertcoords(p, &ptc->x, &pt->x, NULL); annotation_stroke_arrow_init_point_default(pt); diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 9658dc04b52..99e98df3397 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -3376,7 +3376,7 @@ static void gpencil_stroke_join_strokes(bGPDstroke *gps_a, bGPDspoint point; bGPDspoint *pt; int i; - float delta[3] = {1.0f, 1.0f, 1.0f}; + const float delta[3] = {1.0f, 1.0f, 1.0f}; float deltatime = 0.0f; /* sanity checks */ diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 7db25ef817b..a70bbfc9d48 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -456,7 +456,7 @@ static bool gpencil_render_offscreen(tGPDfill *tgpf) GPU_matrix_set(tgpf->rv3d->viewmat); /* draw strokes */ - float ink[4] = {1.0f, 0.0f, 0.0f, 1.0f}; + const float ink[4] = {1.0f, 0.0f, 0.0f, 1.0f}; gpencil_draw_datablock(tgpf, ink); GPU_matrix_pop_projection(); diff --git a/source/blender/editors/gpencil/gpencil_mesh.c b/source/blender/editors/gpencil/gpencil_mesh.c index 11f42f7d3ac..a6088e31ff8 100644 --- a/source/blender/editors/gpencil/gpencil_mesh.c +++ b/source/blender/editors/gpencil/gpencil_mesh.c @@ -196,7 +196,7 @@ static int gpencil_bake_mesh_animation_exec(bContext *C, wmOperator *op) bool newob = false; if (STREQ(target, "*NEW")) { ushort local_view_bits = (v3d && v3d->localvd) ? v3d->local_view_uuid : 0; - float loc[3] = {0.0f, 0.0f, 0.0f}; + const float loc[3] = {0.0f, 0.0f, 0.0f}; ob_gpencil = ED_gpencil_add_object(C, loc, local_view_bits); newob = true; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 9ec04bbb553..de58a0916b2 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -519,7 +519,7 @@ static void gpencil_brush_angle(bGPdata *gpd, Brush *brush, tGPspoint *pt, const /* default angle of brush in radians */ float angle = brush->gpencil_settings->draw_angle; /* angle vector of the brush with full thickness */ - float v0[2] = {cos(angle), sin(angle)}; + const float v0[2] = {cos(angle), sin(angle)}; /* Apply to first point (only if there are 2 points because before no data to do it ) */ if (gpd->runtime.sbuffer_used == 1) { @@ -3247,7 +3247,7 @@ static void gpencil_brush_angle_segment(tGPsdata *p, tGPspoint *pt_prev, tGPspoi float fac; /* angle vector of the brush with full thickness */ - float v0[2] = {cos(angle), sin(angle)}; + const float v0[2] = {cos(angle), sin(angle)}; mvec[0] = pt->x - pt_prev->x; mvec[1] = pt->y - pt_prev->y; diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index f2ccbd6d2cf..339e97bd71c 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -1080,7 +1080,7 @@ void ED_gpencil_project_stroke_to_plane(const Scene *scene, } } else { - float scale[3] = {1.0f, 1.0f, 1.0f}; + const float scale[3] = {1.0f, 1.0f, 1.0f}; plane_normal[2] = 1.0f; float mat[4][4]; loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, scale); @@ -1285,7 +1285,7 @@ void ED_gpencil_project_point_to_plane(const Scene *scene, } } else { - float scale[3] = {1.0f, 1.0f, 1.0f}; + const float scale[3] = {1.0f, 1.0f, 1.0f}; plane_normal[2] = 1.0f; float mat[4][4]; loc_eul_size_to_mat4(mat, cursor->location, cursor->rotation_euler, scale); @@ -1469,7 +1469,7 @@ void ED_gpencil_reset_layers_parent(Depsgraph *depsgraph, Object *obact, bGPdata /* Helper function to create new OB_GPENCIL Object */ Object *ED_gpencil_add_object(bContext *C, const float loc[3], ushort local_view_bits) { - float rot[3] = {0.0f}; + const float rot[3] = {0.0f}; Object *ob = ED_object_add_type(C, OB_GPENCIL, NULL, loc, rot, false, local_view_bits); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index df11a78e657..05f6e61ff40 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -840,7 +840,7 @@ static void draw_scope_end(const rctf *rect, GLint *scissor) /* outline */ UI_draw_roundbox_corner_set(UI_CNR_ALL); - float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 0.5f}; UI_draw_roundbox_4fv( false, rect->xmin - 1, rect->ymin, rect->xmax + 1, rect->ymax + 1, 3.0f, color); } @@ -858,7 +858,7 @@ static void histogram_draw_one(float r, const bool is_line, uint pos_attr) { - float color[4] = {r, g, b, alpha}; + const float color[4] = {r, g, b, alpha}; /* that can happen */ if (res == 0) { @@ -1032,7 +1032,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), Scopes *scopes = (Scopes *)but->poin; int scissor[4]; float colors[3][3]; - float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}}; + const float colorsycc[3][3] = {{1, 0, 1}, {1, 1, 0}, {0, 1, 1}}; /* colors pre multiplied by alpha for speed up */ float colors_alpha[3][3], colorsycc_alpha[3][3]; float min, max; @@ -1172,7 +1172,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region), /* LUMA (1 channel) */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { - float col[3] = {alpha, alpha, alpha}; + const float col[3] = {alpha, alpha, alpha}; GPU_matrix_push(); GPU_matrix_translate_2f(rect.xmin, yofs); @@ -1465,7 +1465,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region), if (scopes->ok && scopes->vecscope != NULL) { /* pixel point cloud */ - float col[3] = {alpha, alpha, alpha}; + const float col[3] = {alpha, alpha, alpha}; GPU_blend_set_func(GPU_ONE, GPU_ONE); GPU_point_size(1.0); @@ -1773,7 +1773,7 @@ void ui_draw_but_COLORBAND(uiBut *but, const uiWidgetColors *UNUSED(wcol), const void ui_draw_but_UNITVEC(uiBut *but, const uiWidgetColors *wcol, const rcti *rect) { /* sphere color */ - float diffuse[3] = {1.0f, 1.0f, 1.0f}; + const float diffuse[3] = {1.0f, 1.0f, 1.0f}; float light[3]; const float size = 0.5f * min_ff(BLI_rcti_size_x(rect), BLI_rcti_size_y(rect)); @@ -1937,7 +1937,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, /* Do this first to not mess imm context */ if (but->a1 == UI_GRAD_H) { /* magic trigger for curve backgrounds */ - float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ + const float col[3] = {0.0f, 0.0f, 0.0f}; /* dummy arg */ rcti grid = { .xmin = rect->xmin + zoomx * (-offsx), @@ -2483,7 +2483,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), (rect.ymax + 1) - (rect.ymin - 1)); if (scopes->track_disabled) { - float color[4] = {0.7f, 0.3f, 0.3f, 0.3f}; + const float color[4] = {0.7f, 0.3f, 0.3f, 0.3f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv( true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color); @@ -2532,7 +2532,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), float col_sel[4], col_outline[4]; if (scopes->use_track_mask) { - float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv( true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color); @@ -2565,7 +2565,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), /* Do stipple cross with geometry */ immBegin(GPU_PRIM_LINES, 7 * 2 * 2); - float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f}; + const float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f}; for (int axe = 0; axe < 2; axe++) { for (int i = 0; i < 7; i++) { float x1 = pos_sel[i] * (1 - axe); @@ -2595,7 +2595,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), } if (!ok) { - float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 0.3f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv( true, rect.xmin - 1, rect.ymin, rect.xmax + 1, rect.ymax + 1, 3.0f, color); @@ -2773,7 +2773,7 @@ void ui_draw_dropshadow( GPU_batch_draw(batch); /* outline emphasis */ - float color[4] = {0.0f, 0.0f, 0.0f, 0.4f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 0.4f}; UI_draw_roundbox_4fv(false, rct->xmin - 0.5f, rct->ymin - 0.5f, diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 5da82b5be9c..c86e35f91db 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -172,7 +172,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) ARegion *region = BKE_area_find_region_xy(area, RGN_TYPE_WINDOW, mx, my); if (region) { SpaceNode *snode = area->spacedata.first; - int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; + const int mval[2] = {mx - region->winrct.xmin, my - region->winrct.ymin}; if (ED_space_node_color_sample(bmain, snode, region, mval, r_col)) { return; @@ -194,7 +194,7 @@ void eyedropper_color_sample_fl(bContext *C, int mx, int my, float r_col[3]) if (win) { /* Fallback to simple opengl picker. */ - int mval[2] = {mx, my}; + const int mval[2] = {mx, my}; WM_window_pixel_sample_read(wm, win, mval, r_col); IMB_colormanagement_display_to_scene_linear_v3(r_col, display); } diff --git a/source/blender/editors/interface/interface_eyedropper_colorband.c b/source/blender/editors/interface/interface_eyedropper_colorband.c index 7b8357f5ef1..b757341ae13 100644 --- a/source/blender/editors/interface/interface_eyedropper_colorband.c +++ b/source/blender/editors/interface/interface_eyedropper_colorband.c @@ -179,8 +179,8 @@ static void eyedropper_colorband_sample_segment(bContext *C, /* Since the mouse tends to move rather rapidly we use #BLI_bitmap_draw_2d_line_v2v2i * to interpolate between the reported coordinates */ struct EyedropperColorband_Context userdata = {C, eye}; - int p1[2] = {eye->last_x, eye->last_y}; - int p2[2] = {mx, my}; + const int p1[2] = {eye->last_x, eye->last_y}; + const int p2[2] = {mx, my}; BLI_bitmap_draw_2d_line_v2v2i(p1, p2, eyedropper_colorband_sample_callback, &userdata); } diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index efbfcf8d19d..7ea64d36d48 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -3023,7 +3023,7 @@ static bool ui_textedit_insert_buf(uiBut *but, static bool ui_textedit_insert_ascii(uiBut *but, uiHandleButtonData *data, char ascii) { - char buf[2] = {ascii, '\0'}; + const char buf[2] = {ascii, '\0'}; if (UI_but_is_utf8(but) && (BLI_str_utf8_size(buf) == -1)) { printf( @@ -6955,7 +6955,7 @@ static bool ui_numedit_but_CURVEPROFILE(uiBlock *block, fy *= mval_factor; /* Move all selected points. */ - float delta[2] = {fx, fy}; + const float delta[2] = {fx, fy}; for (a = 0; a < profile->path_len; a++) { /* Don't move the last and first control points. */ if ((pts[a].flag & PROF_SELECT) && (a != 0) && (a != profile->path_len)) { diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index fed29571185..4be2dbc0b4e 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -143,7 +143,7 @@ void icon_draw_rect_input(float x, }; if ((event_type >= EVT_AKEY) && (event_type <= EVT_ZKEY)) { - char str[2] = {'A' + (event_type - EVT_AKEY), '\0'}; + const char str[2] = {'A' + (event_type - EVT_AKEY), '\0'}; icon_draw_rect_input_text(&rect, color, str, 13); } else if ((event_type >= EVT_F1KEY) && (event_type <= EVT_F12KEY)) { diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 64070725f2b..5310ff0e3ec 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -334,7 +334,7 @@ void UI_fontstyle_draw_simple_backdrop(const uiFontStyle *fs, const float margin = height / 4.0f; /* backdrop */ - float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f}; + const float color[4] = {col_bg[0], col_bg[1], col_bg[2], 0.5f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_aa(true, diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 52835b5474e..bbf29365710 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -518,7 +518,7 @@ GPUBatch *ui_batch_roundbox_shadow_get(void) void UI_draw_anti_tria( float x1, float y1, float x2, float y2, float x3, float y3, const float color[4]) { - float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}}; + const float tri_arr[3][2] = {{x1, y1}, {x2, y2}, {x3, y3}}; float draw_color[4]; copy_v4_v4(draw_color, color); @@ -2568,7 +2568,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - uchar red[4] = {255, 0, 0}; + const uchar red[4] = {255, 0, 0}; if (wt->draw) { color_blend_v3_v3(wt->wcol.inner, red, 0.4f); } @@ -2585,7 +2585,7 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_NODE_ACTIVE) { - uchar blue[4] = {86, 128, 194}; + const uchar blue[4] = {86, 128, 194}; color_blend_v3_v3(wt->wcol.inner, blue, 0.3f); } } @@ -4071,7 +4071,7 @@ static void widget_state_label(uiWidgetType *wt, int state, int drawflag) } if (state & UI_BUT_REDALERT) { - uchar red[4] = {255, 0, 0}; + const uchar red[4] = {255, 0, 0}; color_blend_v3_v3(wt->wcol.text, red, 0.4f); } } diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c index 12ce358a501..c617c921d70 100644 --- a/source/blender/editors/mask/mask_draw.c +++ b/source/blender/editors/mask/mask_draw.c @@ -735,7 +735,7 @@ void ED_mask_draw_region( } if (draw_flag & MASK_DRAWFLAG_OVERLAY) { - float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; float *buffer = mask_rasterize(mask_eval, width, height); if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) { diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c index 9f1d499bb6a..6dde45a4f5f 100644 --- a/source/blender/editors/mesh/editmesh_extrude_spin.c +++ b/source/blender/editors/mesh/editmesh_extrude_spin.c @@ -57,7 +57,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op) { ViewLayer *view_layer = CTX_data_view_layer(C); float cent[3], axis[3]; - float d[3] = {0.0f, 0.0f, 0.0f}; + const float d[3] = {0.0f, 0.0f, 0.0f}; RNA_float_get_array(op->ptr, "center", cent); RNA_float_get_array(op->ptr, "axis", axis); diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 1f411617c68..6f4f75e802a 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -2632,7 +2632,7 @@ static void knifetool_update_mval(KnifeTool_OpData *kcd, const float mval[2]) static void knifetool_update_mval_i(KnifeTool_OpData *kcd, const int mval_i[2]) { - float mval[2] = {UNPACK2(mval_i)}; + const float mval[2] = {UNPACK2(mval_i)}; knifetool_update_mval(kcd, mval); } diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index bc9bef4dc63..81b8cd70353 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -205,7 +205,7 @@ void ED_object_rotation_from_quat(float rot[3], const float viewquat[4], const c switch (align_axis) { case 'X': { /* Same as 'rv3d->viewinv[1]' */ - float axis_y[4] = {0.0f, 1.0f, 0.0f}; + const float axis_y[4] = {0.0f, 1.0f, 0.0f}; float quat_y[4], quat[4]; axis_angle_to_quat(quat_y, axis_y, M_PI_2); mul_qt_qtqt(quat, viewquat, quat_y); diff --git a/source/blender/editors/object/object_remesh.c b/source/blender/editors/object/object_remesh.c index 28f58a34814..8d8f01dd61a 100644 --- a/source/blender/editors/object/object_remesh.c +++ b/source/blender/editors/object/object_remesh.c @@ -406,7 +406,7 @@ static int voxel_size_edit_modal(bContext *C, wmOperator *op, const wmEvent *eve return OPERATOR_FINISHED; } - float mval[2] = {event->mval[0], event->mval[1]}; + const float mval[2] = {event->mval[0], event->mval[1]}; float d = cd->init_mval[0] - mval[0]; @@ -470,7 +470,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev BoundBox *bb = BKE_mesh_boundbox_get(cd->active_object); /* Indices of the Bounding Box faces. */ - int BB_faces[6][4] = { + const int BB_faces[6][4] = { {3, 0, 4, 7}, {1, 2, 6, 5}, {3, 2, 1, 0}, @@ -525,7 +525,7 @@ static int voxel_size_edit_invoke(bContext *C, wmOperator *op, const wmEvent *ev float d_a[3], d_b[3]; float d_a_proj[2], d_b_proj[2]; float preview_plane_proj[4][3]; - float y_axis_proj[2] = {0.0f, 1.0f}; + const float y_axis_proj[2] = {0.0f, 1.0f}; mid_v3_v3v3(text_pos, cd->preview_plane[0], cd->preview_plane[2]); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index f2d7ad3ac11..52b572fb0dd 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -1907,7 +1907,7 @@ static int object_transform_axis_target_modal(bContext *C, wmOperator *op, const for (int x = -ofs; x <= ofs; x += ofs / 2) { for (int y = -ofs; y <= ofs; y += ofs / 2) { if (x != 0 && y != 0) { - int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y}; + const int mval_ofs[2] = {event->mval[0] + x, event->mval[1] + y}; float n[3]; if (ED_view3d_depth_read_cached_normal(&xfd->vc, mval_ofs, n)) { add_v3_v3(normal, n); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 9616b8114ba..58fb934ebf0 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -291,7 +291,7 @@ static void region_draw_azone_tab_arrow(ScrArea *area, ARegion *region, AZone *a /* Workaround for different color spaces between normal areas and the ones using GPUViewports. */ float alpha = WM_region_use_viewport(area, region) ? 0.6f : 0.4f; - float color[4] = {0.05f, 0.05f, 0.05f, alpha}; + const float color[4] = {0.05f, 0.05f, 0.05f, alpha}; UI_draw_roundbox_aa( true, (float)az->x1, (float)az->y1, (float)az->x2, (float)az->y2, 4.0f, color); diff --git a/source/blender/editors/screen/glutil.c b/source/blender/editors/screen/glutil.c index 07a122c7094..903013460d4 100644 --- a/source/blender/editors/screen/glutil.c +++ b/source/blender/editors/screen/glutil.c @@ -112,7 +112,7 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, int seamless, offset_x, offset_y, nsubparts_x, nsubparts_y; int components; const bool use_clipping = ((clip_min_x < clip_max_x) && (clip_min_y < clip_max_y)); - float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + const float white[4] = {1.0f, 1.0f, 1.0f, 1.0f}; if (ELEM(gpu_format, GPU_RGBA8, GPU_RGBA16F)) { components = 4; @@ -203,21 +203,21 @@ void immDrawPixelsTexScaled_clipping(IMMDrawPixelsTexState *state, * at edges of full image. */ if (subpart_w < tex_w) { void *data = DATA(src_y, src_x + subpart_w - 1); - int offset[2] = {subpart_w, 0}; - int extent[2] = {1, subpart_h}; + const int offset[2] = {subpart_w, 0}; + const int extent[2] = {1, subpart_h}; GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0); } if (subpart_h < tex_h) { void *data = DATA(src_y + subpart_h - 1, src_x); - int offset[2] = {0, subpart_h}; - int extent[2] = {subpart_w, 1}; + const int offset[2] = {0, subpart_h}; + const int extent[2] = {subpart_w, 1}; GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0); } if (subpart_w < tex_w && subpart_h < tex_h) { void *data = DATA(src_y + subpart_h - 1, src_x + subpart_w - 1); - int offset[2] = {subpart_w, subpart_h}; - int extent[2] = {1, 1}; + const int offset[2] = {subpart_w, subpart_h}; + const int extent[2] = {1, 1}; GPU_texture_update_sub(tex, gpu_data, data, UNPACK2(offset), 0, UNPACK2(extent), 0); } #undef DATA 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)); diff --git a/source/blender/editors/space_clip/clip_graph_ops.c b/source/blender/editors/space_clip/clip_graph_ops.c index 589831b1c45..63d9889e662 100644 --- a/source/blender/editors/space_clip/clip_graph_ops.c +++ b/source/blender/editors/space_clip/clip_graph_ops.c @@ -114,7 +114,7 @@ static void find_nearest_tracking_segment_cb(void *userdata, float val) { MouseSelectUserData *data = userdata; - float co[2] = {scene_framenr, val}; + const float co[2] = {scene_framenr, val}; if (!clip_graph_value_visible(data->sc, value_source)) { return; @@ -151,7 +151,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, float val) { MouseSelectUserData *data = userdata; - float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]}; + const float mdiff[2] = {scene_framenr - data->mouse_co[0], val - data->mouse_co[1]}; float dist_sq = len_squared_v2(mdiff); if (!clip_graph_value_visible(data->sc, value_source)) { @@ -159,7 +159,7 @@ static void find_nearest_tracking_knot_cb(void *userdata, } if (data->marker == NULL || dist_sq < data->min_dist_sq) { - float co[2] = {scene_framenr, val}; + const float co[2] = {scene_framenr, val}; data->track = track; data->marker = marker; diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 739701b5595..177a0bc2bcf 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -513,7 +513,7 @@ static bool slide_check_corners(float (*corners)[2]) { int i, next, prev; float cross = 0.0f; - float p[2] = {0.0f, 0.0f}; + const float p[2] = {0.0f, 0.0f}; if (!isect_point_quad_v2(p, corners[0], corners[1], corners[2], corners[3])) { return false; @@ -861,7 +861,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event) BKE_tracking_marker_clamp(data->marker, CLAMP_PAT_DIM); } else if (data->action == SLIDE_ACTION_OFFSET) { - float d[2] = {dx, dy}; + const float d[2] = {dx, dy}; for (int a = 0; a < data->track->markersnr; a++) { add_v2_v2v2(data->track->markers[a].pos, data->old_markers[a], d); } @@ -940,7 +940,7 @@ static int slide_marker_modal(bContext *C, wmOperator *op, const wmEvent *event) BKE_tracking_marker_clamp(data->marker, CLAMP_SEARCH_DIM); } else if (data->area == TRACK_AREA_SEARCH) { - float d[2] = {dx, dy}; + const float d[2] = {dx, dy}; add_v2_v2v2(data->min, data->old_search_min, d); add_v2_v2v2(data->max, data->old_search_max, d); } diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index b6f9ca9589f..615d09a04b2 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -153,9 +153,9 @@ static float dist_to_rect(const float co[2], const float max[2]) { float d1, d2, d3, d4; - float p[2] = {co[0] - pos[0], co[1] - pos[1]}; - float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}; - float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; + const float p[2] = {co[0] - pos[0], co[1] - pos[1]}; + const float v1[2] = {min[0], min[1]}, v2[2] = {max[0], min[1]}; + const float v3[2] = {max[0], max[1]}, v4[2] = {min[0], max[1]}; d1 = dist_squared_to_line_segment_v2(p, v1, v2); d2 = dist_squared_to_line_segment_v2(p, v2, v3); @@ -169,7 +169,7 @@ static float dist_to_rect(const float co[2], static float dist_to_crns(const float co[2], const float pos[2], const float crns[4][2]) { float d1, d2, d3, d4; - float p[2] = {co[0] - pos[0], co[1] - pos[1]}; + const float p[2] = {co[0] - pos[0], co[1] - pos[1]}; const float *v1 = crns[0], *v2 = crns[1]; const float *v3 = crns[2], *v4 = crns[3]; diff --git a/source/blender/editors/space_image/image_draw.c b/source/blender/editors/space_image/image_draw.c index 1038011e480..f70589ac5f1 100644 --- a/source/blender/editors/space_image/image_draw.c +++ b/source/blender/editors/space_image/image_draw.c @@ -168,9 +168,9 @@ void ED_image_draw_info(Scene *scene, uchar green[3] = {0, 255, 0}; uchar blue[3] = {100, 100, 255}; #else - uchar red[3] = {255, 255, 255}; - uchar green[3] = {255, 255, 255}; - uchar blue[3] = {255, 255, 255}; + const uchar red[3] = {255, 255, 255}; + const uchar green[3] = {255, 255, 255}; + const uchar blue[3] = {255, 255, 255}; #endif float hue = 0, sat = 0, val = 0, lum = 0, u = 0, v = 0; float col[4], finalcol[4]; @@ -465,7 +465,7 @@ void ED_image_draw_info(Scene *scene, static void sima_draw_zbuf_pixels( float x1, float y1, int rectx, int recty, const int *rect, float zoomx, float zoomy) { - float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; /* Slowwww */ float *rectf = MEM_mallocN(rectx * recty * sizeof(float), "temp"); @@ -494,7 +494,7 @@ static void sima_draw_zbuffloat_pixels(Scene *scene, { float bias, scale, *rectf, clip_end; int a; - float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; if (scene->camera && scene->camera->type == OB_CAMERA) { bias = ((Camera *)scene->camera->data)->clip_start; @@ -798,7 +798,7 @@ static void draw_udim_tile_grid(uint pos_attr, { float x1, y1; UI_view2d_view_to_region_fl(®ion->v2d, x, y, &x1, &y1); - int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; + const int gridpos[5][2] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; for (int i = 0; i < 4; i++) { immAttr3fv(color_attr, color); immVertex2f(pos_attr, x1 + gridpos[i][0] * stepx, y1 + gridpos[i][1] * stepy); diff --git a/source/blender/editors/space_info/info_draw.c b/source/blender/editors/space_info/info_draw.c index 6c818257ec7..72533b88406 100644 --- a/source/blender/editors/space_info/info_draw.c +++ b/source/blender/editors/space_info/info_draw.c @@ -270,12 +270,12 @@ void *info_text_pick(const SpaceInfo *sinfo, int info_textview_height(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports) { - int mval[2] = {INT_MAX, INT_MAX}; + const int mval[2] = {INT_MAX, INT_MAX}; return info_textview_main__internal(sinfo, region, reports, false, mval, NULL, NULL); } void info_textview_main(const SpaceInfo *sinfo, const ARegion *region, const ReportList *reports) { - int mval[2] = {INT_MAX, INT_MAX}; + const int mval[2] = {INT_MAX, INT_MAX}; info_textview_main__internal(sinfo, region, reports, true, mval, NULL, NULL); } diff --git a/source/blender/editors/space_info/textview.c b/source/blender/editors/space_info/textview.c index eee8b989cc2..93a79d9a2bc 100644 --- a/source/blender/editors/space_info/textview.c +++ b/source/blender/editors/space_info/textview.c @@ -264,7 +264,7 @@ static bool textview_draw_string(TextViewDrawState *tds, if (tds->sel[0] != tds->sel[1]) { textview_step_sel(tds, -final_offset); - int pos[2] = {tds->xy[0], line_bottom}; + const int pos[2] = {tds->xy[0], line_bottom}; textview_draw_sel(s, pos, len, tds, bg_sel); } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 52bd4d68649..3fd0b0a5a58 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -986,7 +986,7 @@ void node_draw_shadow(SpaceNode *snode, bNode *node, float radius, float alpha) else { const float margin = 3.0f; - float color[4] = {0.0f, 0.0f, 0.0f, 0.33f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 0.33f}; UI_draw_roundbox_aa(true, rct->xmin - margin, rct->ymin - margin, diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c index a45b415b629..4271eaded99 100644 --- a/source/blender/editors/space_outliner/outliner_draw.c +++ b/source/blender/editors/space_outliner/outliner_draw.c @@ -2694,7 +2694,7 @@ static void outliner_draw_iconrow_number(const uiFontStyle *fstyle, int ys, const int num_elements) { - float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + const float color[4] = {0.0f, 0.0f, 0.0f, 1.0f}; float ufac = 0.25f * UI_UNIT_X; float offset_x = (float)offsx + UI_UNIT_X * 0.35f; diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 7863d2b724d..0f4690c11d5 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -2169,7 +2169,7 @@ static void draw_cache_view(const bContext *C) if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) { stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT); stripe_top = stripe_bot + stripe_ht; - float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f}; + const float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f}; immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); immRectf(pos, scene->r.sfra, stripe_bot, scene->r.efra, stripe_top); @@ -2188,7 +2188,7 @@ static void draw_cache_view(const bContext *C) stripe_top = stripe_bot + stripe_ht; if (scene->ed->cache_flag & SEQ_CACHE_VIEW_RAW) { - float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f}; + const float bg_color[4] = {1.0f, 0.1f, 0.02f, 0.1f}; immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); } @@ -2197,7 +2197,7 @@ static void draw_cache_view(const bContext *C) stripe_top = stripe_bot + stripe_ht; if (scene->ed->cache_flag & SEQ_CACHE_VIEW_PREPROCESSED) { - float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f}; + const float bg_color[4] = {0.1f, 0.1f, 0.75f, 0.1f}; immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); } @@ -2206,7 +2206,7 @@ static void draw_cache_view(const bContext *C) stripe_bot = stripe_top - stripe_ht; if (scene->ed->cache_flag & SEQ_CACHE_VIEW_COMPOSITE) { - float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f}; + const float bg_color[4] = {1.0f, 0.6f, 0.0f, 0.1f}; immUniformColor4f(bg_color[0], bg_color[1], bg_color[2], bg_color[3]); immRectf(pos, seq->startdisp, stripe_bot, seq->enddisp, stripe_top); } diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index 24c55e60513..74cf3c866d3 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -55,7 +55,7 @@ int text_do_suggest_select(SpaceText *st, ARegion *region) TextLine *tmp; int l, x, y, w, h, i; int tgti, *top; - int mval[2] = {0, 0}; + const int mval[2] = {0, 0}; if (!st || !st->text) { return 0; diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 6be436cffb5..201f9dae5d5 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2587,7 +2587,7 @@ static void text_scroll_apply(bContext *C, wmOperator *op, const wmEvent *event) { SpaceText *st = CTX_wm_space_text(C); TextScroll *tsc = op->customdata; - int mval[2] = {event->x, event->y}; + const int mval[2] = {event->x, event->y}; text_update_character_width(st); diff --git a/source/blender/editors/space_view3d/view3d_buttons.c b/source/blender/editors/space_view3d/view3d_buttons.c index d78c58c0c64..38784a5c79e 100644 --- a/source/blender/editors/space_view3d/view3d_buttons.c +++ b/source/blender/editors/space_view3d/view3d_buttons.c @@ -1071,7 +1071,7 @@ static void v3d_object_dimension_buts(bContext *C, uiLayout *layout, View3D *v3d const float lim = FLT_MAX; for (int i = 0; i < 3; i++) { uiBut *but; - char text[3] = {'X' + i, ':', '\0'}; + const char text[3] = {'X' + i, ':', '\0'}; but = uiDefButF(block, UI_BTYPE_NUM, B_TRANSFORM_PANEL_DIMS, diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c index 30212fcd9e5..e17993445df 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c @@ -156,7 +156,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int if (eve_test) { BMVert *vert = (BMVert *)eve_test; float vert_p_co[3], vert_co[3]; - float mval_f[2] = {UNPACK2(vc.mval)}; + const float mval_f[2] = {UNPACK2(vc.mval)}; mul_v3_m4v3(vert_co, gz_ele->bases[base_index_vert]->object->obmat, vert->co); ED_view3d_project(vc.region, vert_co, vert_p_co); float len = len_v2v2(vert_p_co, mval_f); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index 59b2e378955..7799aba5c19 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -909,7 +909,7 @@ static void gizmo_ruler_draw(const bContext *C, wmGizmo *gz) static int gizmo_ruler_test_select(bContext *UNUSED(C), wmGizmo *gz, const int mval[2]) { RulerItem *ruler_item_pick = (RulerItem *)gz; - float mval_fl[2] = {UNPACK2(mval)}; + const float mval_fl[2] = {UNPACK2(mval)}; int co_index; /* select and drag */ diff --git a/source/blender/editors/space_view3d/view3d_placement.c b/source/blender/editors/space_view3d/view3d_placement.c index b7219290654..b79632f0a82 100644 --- a/source/blender/editors/space_view3d/view3d_placement.c +++ b/source/blender/editors/space_view3d/view3d_placement.c @@ -321,7 +321,7 @@ static void draw_line_bounds(const BoundBox *bounds, const float color[4]) GPUVertFormat *format = immVertexFormat(); uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - int edges[12][2] = { + const int edges[12][2] = { /* First side. */ {0, 1}, {1, 2}, @@ -507,7 +507,7 @@ static void draw_circle_in_quad(const float v1[2], float theta = ((2.0f * M_PI) * ((float)i / (float)resolution)) + 0.01f; float x = cosf(theta); float y = sinf(theta); - float pt[2] = {x, y}; + const float pt[2] = {x, y}; float w[4]; barycentric_weights_v2_quad(UNPACK4(quad), pt, w); diff --git a/source/blender/editors/space_view3d/view3d_project.c b/source/blender/editors/space_view3d/view3d_project.c index c10a88af146..c790a8659ee 100644 --- a/source/blender/editors/space_view3d/view3d_project.c +++ b/source/blender/editors/space_view3d/view3d_project.c @@ -778,7 +778,7 @@ void ED_view3d_project(const struct ARegion *region, const float world[3], float { // viewport is set up to make coordinates relative to the region, not window RegionView3D *rv3d = region->regiondata; - int viewport[4] = {0, 0, region->winx, region->winy}; + const int viewport[4] = {0, 0, region->winx, region->winy}; GPU_matrix_project(world, rv3d->viewmat, rv3d->winmat, viewport, r_region_co); } @@ -787,8 +787,8 @@ bool ED_view3d_unproject( const struct ARegion *region, float regionx, float regiony, float regionz, float world[3]) { RegionView3D *rv3d = region->regiondata; - int viewport[4] = {0, 0, region->winx, region->winy}; - float region_co[3] = {regionx, regiony, regionz}; + const int viewport[4] = {0, 0, region->winx, region->winy}; + const float region_co[3] = {regionx, regiony, regionz}; return GPU_matrix_unproject(region_co, rv3d->viewmat, rv3d->winmat, viewport, world); } diff --git a/source/blender/editors/space_view3d/view3d_utils.c b/source/blender/editors/space_view3d/view3d_utils.c index 4e73a2be17e..a264e1560c6 100644 --- a/source/blender/editors/space_view3d/view3d_utils.c +++ b/source/blender/editors/space_view3d/view3d_utils.c @@ -1499,7 +1499,7 @@ void ED_view3d_from_m4(const float mat[4][4], float ofs[3], float quat[4], const */ void ED_view3d_to_m4(float mat[4][4], const float ofs[3], const float quat[4], const float dist) { - float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]}; + const float iviewquat[4] = {-quat[0], quat[1], quat[2], quat[3]}; float dvec[3] = {0.0f, 0.0f, dist}; quat_to_mat4(mat, iviewquat); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 64167b83655..2cc41097070 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -387,7 +387,7 @@ static bool walk_floor_distance_get(RegionView3D *rv3d, const float dvec[3], float *r_distance) { - float ray_normal[3] = {0, 0, -1}; /* down */ + const float ray_normal[3] = {0, 0, -1}; /* down */ float ray_start[3]; float r_location[3]; float r_normal_dummy[3]; diff --git a/source/blender/editors/transform/transform_convert_mesh.c b/source/blender/editors/transform/transform_convert_mesh.c index 6f447997fb0..573f4550fec 100644 --- a/source/blender/editors/transform/transform_convert_mesh.c +++ b/source/blender/editors/transform/transform_convert_mesh.c @@ -754,7 +754,8 @@ void createTransEditVerts(TransInfo *t) if (tc->use_mirror_axis_any) { bool use_topology = (me->editflag & ME_EDIT_MIRROR_TOPO) != 0; bool use_select = (t->flag & T_PROP_EDIT) == 0; - bool mirror_axis[3] = {tc->use_mirror_axis_x, tc->use_mirror_axis_y, tc->use_mirror_axis_z}; + const bool mirror_axis[3] = { + tc->use_mirror_axis_x, tc->use_mirror_axis_y, tc->use_mirror_axis_z}; editmesh_mirror_data_calc(em, use_select, use_topology, mirror_axis, &mirror_data); if (mirror_data.vert_map) { diff --git a/source/blender/editors/transform/transform_gizmo_2d.c b/source/blender/editors/transform/transform_gizmo_2d.c index dacdb72806c..11cde6a9038 100644 --- a/source/blender/editors/transform/transform_gizmo_2d.c +++ b/source/blender/editors/transform/transform_gizmo_2d.c @@ -350,8 +350,8 @@ static void gizmo2d_xform_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup ptr = WM_gizmo_operator_set(ggd->cage, 0, ot_translate, NULL); RNA_boolean_set(ptr, "release_confirm", 1); - bool constraint_x[3] = {1, 0, 0}; - bool constraint_y[3] = {0, 1, 0}; + const bool constraint_x[3] = {1, 0, 0}; + const bool constraint_y[3] = {0, 1, 0}; ptr = WM_gizmo_operator_set(ggd->cage, ED_GIZMO_CAGE2D_PART_SCALE_MIN_X, ot_resize, NULL); PropertyRNA *prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); @@ -484,7 +484,7 @@ static void gizmo2d_xform_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup) ARegion *region = CTX_wm_region(C); GizmoGroup2D *ggd = gzgroup->customdata; float origin[3] = {UNPACK2(ggd->origin), 0.0f}; - float origin_aa[3] = {UNPACK2(ggd->origin), 0.0f}; + const float origin_aa[3] = {UNPACK2(ggd->origin), 0.0f}; gizmo2d_origin_to_region(region, origin); diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index 3878103fa4e..6155042f555 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -2053,7 +2053,7 @@ static void WIDGETGROUP_xform_cage_setup(const bContext *UNUSED(C), wmGizmoGroup for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { for (int z = 0; z < 3; z++) { - bool constraint[3] = {x != 1, y != 1, z != 1}; + const bool constraint[3] = {x != 1, y != 1, z != 1}; ptr = WM_gizmo_operator_set(gz, i, ot_resize, NULL); if (prop_release_confirm == NULL) { prop_release_confirm = RNA_struct_find_property(ptr, "release_confirm"); diff --git a/source/blender/editors/transform/transform_gizmo_extrude_3d.c b/source/blender/editors/transform/transform_gizmo_extrude_3d.c index 7f6f3e53bc3..ae7cda0bd03 100644 --- a/source/blender/editors/transform/transform_gizmo_extrude_3d.c +++ b/source/blender/editors/transform/transform_gizmo_extrude_3d.c @@ -213,7 +213,7 @@ static void gizmo_mesh_extrude_setup(const bContext *C, wmGizmoGroup *gzgroup) PointerRNA macroptr = RNA_pointer_get(ptr, "TRANSFORM_OT_translate"); RNA_boolean_set(¯optr, "release_confirm", true); - bool constraint[3] = {0, 0, 0}; + const bool constraint[3] = {0, 0, 0}; RNA_boolean_set_array(¯optr, "constraint_axis", constraint); } diff --git a/source/blender/editors/transform/transform_mode_edge_slide.c b/source/blender/editors/transform/transform_mode_edge_slide.c index 4a648a77fe1..1886f95beae 100644 --- a/source/blender/editors/transform/transform_mode_edge_slide.c +++ b/source/blender/editors/transform/transform_mode_edge_slide.c @@ -534,7 +534,7 @@ static EdgeSlideData *createEdgeSlideVerts_double_side(TransInfo *t, TransDataCo int sv_tot; int *sv_table; /* BMVert -> sv_array index */ EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); - float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; + const float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; int numsel, i, loop_nr; bool use_occlude_geometry = false; View3D *v3d = NULL; @@ -894,7 +894,7 @@ static EdgeSlideData *createEdgeSlideVerts_single_side(TransInfo *t, TransDataCo int sv_tot; int *sv_table; /* BMVert -> sv_array index */ EdgeSlideData *sld = MEM_callocN(sizeof(*sld), "sld"); - float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; + const float mval[2] = {(float)t->mval[0], (float)t->mval[1]}; int loop_nr; bool use_occlude_geometry = false; View3D *v3d = NULL; diff --git a/source/blender/editors/transform/transform_mode_vert_slide.c b/source/blender/editors/transform/transform_mode_vert_slide.c index b396317ba7c..38537194af3 100644 --- a/source/blender/editors/transform/transform_mode_vert_slide.c +++ b/source/blender/editors/transform/transform_mode_vert_slide.c @@ -126,7 +126,7 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2]) { /* Active object may have no selected vertices. */ VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data; - float mval_fl[2] = {UNPACK2(mval)}; + const float mval_fl[2] = {UNPACK2(mval)}; TransDataVertSlideVert *sv; /* set the vertex to use as a reference for the mouse direction 'curr_sv_index' */ @@ -153,8 +153,8 @@ static void calcVertSlideMouseActiveVert(struct TransInfo *t, const int mval[2]) static void calcVertSlideMouseActiveEdges(struct TransInfo *t, const int mval[2]) { VertSlideData *sld = TRANS_DATA_CONTAINER_FIRST_OK(t)->custom.mode.data; - float imval_fl[2] = {UNPACK2(t->mouse.imval)}; - float mval_fl[2] = {UNPACK2(mval)}; + const float imval_fl[2] = {UNPACK2(t->mouse.imval)}; + const float mval_fl[2] = {UNPACK2(mval)}; float dir[3]; TransDataVertSlideVert *sv; diff --git a/source/blender/editors/transform/transform_snap_object.c b/source/blender/editors/transform/transform_snap_object.c index eb14c5bec28..8079795d306 100644 --- a/source/blender/editors/transform/transform_snap_object.c +++ b/source/blender/editors/transform/transform_snap_object.c @@ -1214,7 +1214,7 @@ static void cb_mlooptri_edges_get(const int index, int v_index[3], const BVHTree const MLoopTri *lt = &data->looptri[index]; for (int j = 2, j_next = 0; j_next < 3; j = j_next++) { const MEdge *ed = &medge[mloop[lt->tri[j]].e]; - uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; + const uint tri_edge[2] = {mloop[lt->tri[j]].v, mloop[lt->tri[j_next]].v}; if (ELEM(ed->v1, tri_edge[0], tri_edge[1]) && ELEM(ed->v2, tri_edge[0], tri_edge[1])) { // printf("real edge found\n"); v_index[j] = mloop[lt->tri[j]].e; diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.c b/source/blender/editors/uvedit/uvedit_unwrap_ops.c index 9f77bf31481..49f11cd6a74 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.c +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.c @@ -1348,7 +1348,7 @@ static void uv_map_rotation_matrix(float result[4][4], float sideangledeg, float radius) { - float offset[4] = {0}; + const float offset[4] = {0}; uv_map_rotation_matrix_ex(result, rv3d, ob, upangledeg, sideangledeg, radius, offset); } diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c index d92721f887f..d645064475b 100644 --- a/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c +++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c @@ -236,7 +236,7 @@ static void generate_geometry(GpencilModifierData *md, float rand[3][3]; for (int j = 0; j < 3; j++) { - uint primes[3] = {2, 3, 7}; + const uint primes[3] = {2, 3, 7}; double offset[3] = {0.0, 0.0, 0.0}; double r[3]; /* To ensure a nice distribution, we use halton sequence and offset using the seed. */ diff --git a/source/blender/gpu/intern/gpu_buffers.c b/source/blender/gpu/intern/gpu_buffers.c index 5a36e5ffdec..d32b45e0b5f 100644 --- a/source/blender/gpu/intern/gpu_buffers.c +++ b/source/blender/gpu/intern/gpu_buffers.c @@ -695,7 +695,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, } if (show_vcol) { - ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; + const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index, &vcol); } @@ -749,7 +749,7 @@ void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, empty_mask = empty_mask && (cmask == 0); } - ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; + const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 0, &vcol); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 1, &vcol); GPU_vertbuf_attr_set(buffers->vert_buf, g_vbo_id.col, vbo_index + 2, &vcol); @@ -832,12 +832,12 @@ static void gpu_bmesh_vert_to_buffer_copy(BMVert *v, } if (show_vcol) { - ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; + const ushort vcol[4] = {USHRT_MAX, USHRT_MAX, USHRT_MAX, USHRT_MAX}; GPU_vertbuf_attr_set(vert_buf, g_vbo_id.col, v_index, &vcol); } /* Add default face sets color to avoid artifacts. */ - uchar face_set[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; + const uchar face_set[3] = {UCHAR_MAX, UCHAR_MAX, UCHAR_MAX}; GPU_vertbuf_attr_set(vert_buf, g_vbo_id.fset, v_index, &face_set); } diff --git a/source/blender/gpu/intern/gpu_immediate_util.c b/source/blender/gpu/intern/gpu_immediate_util.c index e834d6afccb..b8cd9fe356d 100644 --- a/source/blender/gpu/intern/gpu_immediate_util.c +++ b/source/blender/gpu/intern/gpu_immediate_util.c @@ -460,10 +460,10 @@ void imm_draw_cylinder_fill_normal_3d( float h1 = height * ((float)j / (float)stacks); float h2 = height * ((float)(j + 1) / (float)stacks); - float v1[3] = {r1 * cos2, r1 * sin2, h1}; - float v2[3] = {r2 * cos2, r2 * sin2, h2}; - float v3[3] = {r2 * cos1, r2 * sin1, h2}; - float v4[3] = {r1 * cos1, r1 * sin1, h1}; + const float v1[3] = {r1 * cos2, r1 * sin2, h1}; + const float v2[3] = {r2 * cos2, r2 * sin2, h2}; + const float v3[3] = {r2 * cos1, r2 * sin1, h2}; + const float v4[3] = {r1 * cos1, r1 * sin1, h1}; float n1[3], n2[3]; /* calc normals */ @@ -516,10 +516,10 @@ void imm_draw_cylinder_wire_3d( float h1 = height * ((float)j / (float)stacks); float h2 = height * ((float)(j + 1) / (float)stacks); - float v1[3] = {r1 * cos2, r1 * sin2, h1}; - float v2[3] = {r2 * cos2, r2 * sin2, h2}; - float v3[3] = {r2 * cos1, r2 * sin1, h2}; - float v4[3] = {r1 * cos1, r1 * sin1, h1}; + const float v1[3] = {r1 * cos2, r1 * sin2, h1}; + const float v2[3] = {r2 * cos2, r2 * sin2, h2}; + const float v3[3] = {r2 * cos1, r2 * sin1, h2}; + const float v4[3] = {r1 * cos1, r1 * sin1, h1}; immVertex3fv(pos, v1); immVertex3fv(pos, v2); @@ -554,10 +554,10 @@ void imm_draw_cylinder_fill_3d( float h1 = height * ((float)j / (float)stacks); float h2 = height * ((float)(j + 1) / (float)stacks); - float v1[3] = {r1 * cos2, r1 * sin2, h1}; - float v2[3] = {r2 * cos2, r2 * sin2, h2}; - float v3[3] = {r2 * cos1, r2 * sin1, h2}; - float v4[3] = {r1 * cos1, r1 * sin1, h1}; + const float v1[3] = {r1 * cos2, r1 * sin2, h1}; + const float v2[3] = {r2 * cos2, r2 * sin2, h2}; + const float v3[3] = {r2 * cos1, r2 * sin1, h2}; + const float v4[3] = {r1 * cos1, r1 * sin1, h1}; /* first tri */ immVertex3fv(pos, v1); diff --git a/source/blender/imbuf/intern/anim_movie.c b/source/blender/imbuf/intern/anim_movie.c index 9fab450cc76..01372d5ed68 100644 --- a/source/blender/imbuf/intern/anim_movie.c +++ b/source/blender/imbuf/intern/anim_movie.c @@ -803,7 +803,7 @@ static void ffmpeg_postprocess(struct anim *anim) if (ENDIAN_ORDER == B_ENDIAN) { int *dstStride = anim->pFrameRGB->linesize; uint8_t **dst = anim->pFrameRGB->data; - int dstStride2[4] = {dstStride[0], 0, 0, 0}; + const int dstStride2[4] = {dstStride[0], 0, 0, 0}; uint8_t *dst2[4] = {dst[0], 0, 0, 0}; int x, y, h, w; unsigned char *bottom; @@ -849,7 +849,7 @@ static void ffmpeg_postprocess(struct anim *anim) else { int *dstStride = anim->pFrameRGB->linesize; uint8_t **dst = anim->pFrameRGB->data; - int dstStride2[4] = {-dstStride[0], 0, 0, 0}; + const int dstStride2[4] = {-dstStride[0], 0, 0, 0}; uint8_t *dst2[4] = {dst[0] + (anim->y - 1) * dstStride[0], 0, 0, 0}; sws_scale(anim->img_convert_ctx, diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index dc7a9594f4f..5d72066675b 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -306,8 +306,8 @@ static TIFF *imb_tiff_client_open(ImbTIFFMemFile *memFile, const unsigned char * #define IMB_TIFF_NCB 4 /* number of comparison bytes used */ int imb_is_a_tiff(const unsigned char *mem) { - char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a}; - char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00}; + const char big_endian[IMB_TIFF_NCB] = {0x4d, 0x4d, 0x00, 0x2a}; + const char lil_endian[IMB_TIFF_NCB] = {0x49, 0x49, 0x2a, 0x00}; return ((memcmp(big_endian, mem, IMB_TIFF_NCB) == 0) || (memcmp(lil_endian, mem, IMB_TIFF_NCB) == 0)); diff --git a/source/blender/imbuf/intern/util_gpu.c b/source/blender/imbuf/intern/util_gpu.c index c52f671f59f..1a46572fb20 100644 --- a/source/blender/imbuf/intern/util_gpu.c +++ b/source/blender/imbuf/intern/util_gpu.c @@ -186,7 +186,7 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex, bool use_premult) { const bool do_rescale = (ibuf->x != w || ibuf->y != h); - int size[2] = {w, h}; + const int size[2] = {w, h}; eGPUDataFormat data_format; eGPUTextureFormat tex_format; @@ -208,7 +208,7 @@ void IMB_update_gpu_texture_sub(GPUTexture *tex, GPUTexture *IMB_create_gpu_texture(ImBuf *ibuf, bool use_high_bitdepth, bool use_premult) { GPUTexture *tex = NULL; - int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; + const int size[2] = {GPU_texture_size_with_limit(ibuf->x), GPU_texture_size_with_limit(ibuf->y)}; bool do_rescale = (ibuf->x != size[0]) || (ibuf->y != size[1]); #ifdef WITH_DDS diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index bebb3a49c04..8781a3f448f 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -175,7 +175,7 @@ static int replace_if_different(const char *tmpfile, const char *dep_files[]) if (dep_files) { int pass; for (pass = 0; dep_files[pass]; pass++) { - char from_path[4096] = __FILE__; + const char from_path[4096] = __FILE__; char *p1, *p2; /* dir only */ diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index bdb1851906b..d3d2f891929 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -442,7 +442,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * float angle = 2.0f * M_PI * (pimd->rotation + pimd->random_rotation * (psys_frand(psys, 19957323 + p) - 0.5f)); - float eul[3] = {0.0f, 0.0f, angle}; + const float eul[3] = {0.0f, 0.0f, angle}; float rot[4]; eul_to_quat(rot, eul); diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index b9bb7add811..3bb7ecd43f4 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -301,7 +301,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * float totlen = len_v3(mtx_tx[3]); if (totlen != 0.0f) { - float zero[3] = {0.0f, 0.0f, 0.0f}; + const float zero[3] = {0.0f, 0.0f, 0.0f}; float cp[3]; screw_ofs = closest_to_line_v3(cp, mtx_tx[3], zero, axis_vec); } @@ -412,7 +412,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * CustomData_copy_data(&mesh->vdata, &result->vdata, 0, 0, (int)totvert); if (mloopuv_layers_tot) { - float zero_co[3] = {0}; + const float zero_co[3] = {0}; plane_from_point_normal_v3(uv_axis_plane, zero_co, axis_vec); } diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index c69d78f112f..962e93be215 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -449,7 +449,7 @@ BLI_INLINE SDefBindWeightData *computeBindWeights(SDefBindCalcData *const data, SDefBindWeightData *bwdata; SDefBindPoly *bpoly; - float world[3] = {0.0f, 0.0f, 1.0f}; + const float world[3] = {0.0f, 0.0f, 1.0f}; float avg_point_dist = 0.0f; float tot_weight = 0.0f; int inf_weight_flags = 0; diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index 4aca3c28ed8..f7d05501b84 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -185,7 +185,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * mul_m4_m4m4(warp_mat, mat_cent, warp_mat); } - int shuf_indices[4] = {axis_u, axis_v, -1, 3}; + const int shuf_indices[4] = {axis_u, axis_v, -1, 3}; shuffle_m4(shuf_mat, shuf_indices); mul_m4_m4m4(warp_mat, shuf_mat, warp_mat); transpose_m4(shuf_mat); diff --git a/source/blender/nodes/shader/nodes/node_shader_geometry.c b/source/blender/nodes/shader/nodes/node_shader_geometry.c index 30e376f8e09..f66633e64c8 100644 --- a/source/blender/nodes/shader/nodes/node_shader_geometry.c +++ b/source/blender/nodes/shader/nodes/node_shader_geometry.c @@ -42,7 +42,7 @@ static int node_shader_gpu_geometry(GPUMaterial *mat, { /* HACK: Don't request GPU_BARYCENTRIC_TEXCO if not used because it will * trigger the use of geometry shader (and the performance penalty it implies). */ - float val[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + const float val[4] = {0.0f, 0.0f, 0.0f, 0.0f}; GPUNodeLink *bary_link = (!out[5].hasoutput) ? GPU_constant(val) : GPU_builtin(GPU_BARYCENTRIC_TEXCO); if (out[5].hasoutput) { diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 38c7f9cb3fc..8725122b12c 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -91,8 +91,8 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat, if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { int ret = GPU_stack_link(mat, node, names[node->custom1], in, out); if (ret && node->custom2 & SHD_MIXRGB_CLAMP) { - float min[3] = {0.0f, 0.0f, 0.0f}; - float max[3] = {1.0f, 1.0f, 1.0f}; + const float min[3] = {0.0f, 0.0f, 0.0f}; + const float max[3] = {1.0f, 1.0f, 1.0f}; GPU_link( mat, "clamp_color", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); } diff --git a/source/blender/render/intern/source/imagetexture.c b/source/blender/render/intern/source/imagetexture.c index f7ae51dd141..188bdab316c 100644 --- a/source/blender/render/intern/source/imagetexture.c +++ b/source/blender/render/intern/source/imagetexture.c @@ -888,7 +888,7 @@ static void ewa_read_pixel_cb(void *userdata, int x, int y, float result[4]) static void ewa_eval(TexResult *texr, ImBuf *ibuf, float fx, float fy, afdata_t *AFD) { ReadEWAData data; - float uv[2] = {fx, fy}; + const float uv[2] = {fx, fy}; data.ibuf = ibuf; data.AFD = AFD; BLI_ewa_filter(ibuf->x, diff --git a/source/blender/render/intern/source/multires_bake.c b/source/blender/render/intern/source/multires_bake.c index b30821a1b73..f12b425ee8b 100644 --- a/source/blender/render/intern/source/multires_bake.c +++ b/source/blender/render/intern/source/multires_bake.c @@ -157,7 +157,7 @@ static void init_bake_rast(MBakeRast *bake_rast, static void flush_pixel(const MResolvePixelData *data, const int x, const int y) { - float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h}; + const float st[2] = {(x + 0.5f) / data->w, (y + 0.5f) / data->h}; const float *st0, *st1, *st2; const float *tang0, *tang1, *tang2; float no0[3], no1[3], no2[3]; diff --git a/source/blender/render/intern/source/pointdensity.c b/source/blender/render/intern/source/pointdensity.c index c49cf6203e0..db3ae8d8b5e 100644 --- a/source/blender/render/intern/source/pointdensity.c +++ b/source/blender/render/intern/source/pointdensity.c @@ -868,7 +868,7 @@ void RE_point_density_minmax(struct Depsgraph *depsgraph, particle_system_minmax(depsgraph, scene, object, psys, pd->radius, r_min, r_max); } else { - float radius[3] = {pd->radius, pd->radius, pd->radius}; + const float radius[3] = {pd->radius, pd->radius, pd->radius}; BoundBox *bb = BKE_object_boundbox_get(object); if (bb != NULL) { diff --git a/source/blender/simulation/intern/implicit_blender.c b/source/blender/simulation/intern/implicit_blender.c index 1f6e67cb9ac..aef4f404795 100644 --- a/source/blender/simulation/intern/implicit_blender.c +++ b/source/blender/simulation/intern/implicit_blender.c @@ -1469,7 +1469,7 @@ void SIM_mass_spring_force_face_wind( Implicit_Data *data, int v1, int v2, int v3, const float (*winvec)[3]) { const float effector_scale = 0.02f; - int vs[3] = {v1, v2, v3}; + const int vs[3] = {v1, v2, v3}; float win[3], nor[3], area; float factor, base_force; float force[3]; @@ -1509,7 +1509,7 @@ void SIM_mass_spring_force_face_extern( Implicit_Data *data, int v1, int v2, int v3, const float (*forcevec)[3]) { const float effector_scale = 0.02f; - int vs[3] = {v1, v2, v3}; + const int vs[3] = {v1, v2, v3}; float nor[3], area; float factor, base_force[3]; float force[3][3]; diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c index fe4c98394a3..b8cb5432a49 100644 --- a/source/blender/windowmanager/intern/wm_draw.c +++ b/source/blender/windowmanager/intern/wm_draw.c @@ -570,8 +570,8 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend) } /* Not the same layout as rectf/recti. */ - float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax}; - float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax}; + const float rectt[4] = {rect_tex.xmin, rect_tex.ymin, rect_tex.xmax, rect_tex.ymax}; + const float rectg[4] = {rect_geo.xmin, rect_geo.ymin, rect_geo.xmax, rect_geo.ymax}; if (blend) { /* GL_ONE because regions drawn offscreen have premultiplied alpha. */ diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c index 5a66cbd10eb..55233168ab2 100644 --- a/source/blender/windowmanager/intern/wm_gesture.c +++ b/source/blender/windowmanager/intern/wm_gesture.c @@ -324,7 +324,7 @@ static void draw_filled_lasso(wmGesture *gt) int(*mcoords)[2] = MEM_mallocN(sizeof(*mcoords) * (mcoords_len + 1), __func__); int i; rcti rect; - float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + const float red[4] = {1.0f, 0.0f, 0.0f, 0.0f}; for (i = 0; i < mcoords_len; i++, lasso += 2) { mcoords[i][0] = lasso[0]; diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 6a3f4f6a364..8dea1a1031a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2445,7 +2445,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, r2, 80); if (rmin > 0.0f) { /* Inner fill circle to increase the contrast of the value */ - float black[3] = {0.0f}; + const float black[3] = {0.0f}; immUniformColor3fvAlpha(black, 0.2f); imm_draw_circle_fill_2d(pos, 0.0, 0.0f, rmin, 80); @@ -2852,7 +2852,7 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even if (!has_numInput) { if (rc->slow_mode) { if (rc->subtype == PROP_ANGLE) { - float position[2] = {event->x, event->y}; + const float position[2] = {event->x, event->y}; /* calculate the initial angle here first */ delta[0] = rc->initial_mouse[0] - rc->slow_mouse[0]; @@ -2954,8 +2954,8 @@ static int radial_control_modal(bContext *C, wmOperator *op, const wmEvent *even rc->slow_mouse[1] = event->y; rc->slow_mode = true; if (rc->subtype == PROP_ANGLE) { - float initial_position[2] = {UNPACK2(rc->initial_mouse)}; - float current_position[2] = {UNPACK2(rc->slow_mouse)}; + const float initial_position[2] = {UNPACK2(rc->initial_mouse)}; + const float current_position[2] = {UNPACK2(rc->slow_mouse)}; rc->dial = BLI_dial_init(initial_position, 0.0f); /* immediately set the position to get a an initial direction */ BLI_dial_angle(rc->dial, current_position); -- cgit v1.2.3