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/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 +- source/blender/blenkernel/intern/tracking_stabilize.c | 2 +- 18 files changed, 33 insertions(+), 33 deletions(-) (limited to 'source/blender/blenkernel/intern') 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); -- cgit v1.2.3