diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-26 05:51:46 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-26 05:51:46 +0300 |
commit | 6fc7b37583a2fa0815ae50b8c604f823d863cab1 (patch) | |
tree | bbb02a7a513e43a634739c93904f5b23ad913ae0 /source/blender | |
parent | a3e1a9e2aace26a71c2698cd96ce4086db25e94d (diff) |
Cleanup: reduce variable scope
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/particle_child.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking_detect.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_delete.c | 7 | ||||
-rw-r--r-- | source/blender/bmesh/intern/bmesh_structure.c | 3 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_connect_nonplanar.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/operators/bmo_poke.c | 4 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_constraints.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/bmp.c | 3 | ||||
-rw-r--r-- | source/blender/imbuf/intern/readimage.c | 4 | ||||
-rw-r--r-- | source/blender/imbuf/intern/tiff.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main.c | 3 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_shapekey.c | 7 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_edit.c | 3 | ||||
-rw-r--r-- | source/blender/sequencer/intern/strip_transform.c | 4 |
15 files changed, 28 insertions, 36 deletions
diff --git a/source/blender/blenkernel/intern/particle_child.c b/source/blender/blenkernel/intern/particle_child.c index 2720bdacb3b..a890812cfc4 100644 --- a/source/blender/blenkernel/intern/particle_child.c +++ b/source/blender/blenkernel/intern/particle_child.c @@ -403,7 +403,7 @@ void do_kink(ParticleKey *state, float obmat[4][4], int smooth_start) { - float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3], q1[4] = {1.0f, 0.0f, 0.0f, 0.0f}; + float kink[3] = {1.0f, 0.0f, 0.0f}, par_vec[3]; float t, dt = 1.0f, result[3]; if (ELEM(type, PART_KINK_NO, PART_KINK_SPIRAL)) { @@ -453,6 +453,7 @@ void do_kink(ParticleKey *state, switch (type) { case PART_KINK_CURL: { float curl_offset[3]; + float q1[4] = {1.0f, 0.0f, 0.0f, 0.0f}; /* rotate kink vector around strand tangent */ mul_v3_v3fl(curl_offset, kink, amplitude); diff --git a/source/blender/blenkernel/intern/tracking_detect.c b/source/blender/blenkernel/intern/tracking_detect.c index 51ffce4a3e3..540f880905d 100644 --- a/source/blender/blenkernel/intern/tracking_detect.c +++ b/source/blender/blenkernel/intern/tracking_detect.c @@ -81,7 +81,6 @@ static void detect_retrieve_libmv_features(MovieTracking *tracking, a = libmv_countFeatures(features); while (a--) { - MovieTrackingTrack *track; double x, y, size, score; bool ok = true; float xu, yu; @@ -99,7 +98,8 @@ static void detect_retrieve_libmv_features(MovieTracking *tracking, } if (ok) { - track = BKE_tracking_track_add(tracking, tracksbase, xu, yu, framenr, width, height); + MovieTrackingTrack *track = BKE_tracking_track_add( + tracking, tracksbase, xu, yu, framenr, width, height); track->flag |= SELECT; track->pat_flag |= SELECT; track->search_flag |= SELECT; diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 992a07b2062..17fb451e422 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -786,9 +786,9 @@ int BLI_str_utf8_offset_to_column(const char *str, int offset) int BLI_str_utf8_offset_from_column(const char *str, int column) { - int offset = 0, pos = 0, col; + int offset = 0, pos = 0; while (*(str + offset) && pos < column) { - col = BLI_str_utf8_char_width_safe(str + offset); + const int col = BLI_str_utf8_char_width_safe(str + offset); if (pos + col > column) { break; } diff --git a/source/blender/bmesh/intern/bmesh_delete.c b/source/blender/bmesh/intern/bmesh_delete.c index e2436e53099..8ec7dc410d0 100644 --- a/source/blender/bmesh/intern/bmesh_delete.c +++ b/source/blender/bmesh/intern/bmesh_delete.c @@ -86,7 +86,6 @@ void BMO_mesh_delete_oflag_tagged(BMesh *bm, const short oflag, const char htype void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type) { BMEdge *e; - BMFace *f; BMIter eiter; BMIter fiter; @@ -128,6 +127,7 @@ void BMO_mesh_delete_oflag_context(BMesh *bm, const short oflag, const int type) case DEL_FACES: case DEL_FACES_KEEP_BOUNDARY: { /* go through and mark all edges and all verts of all faces for delete */ + BMFace *f; BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { if (BMO_face_flag_test(bm, f, oflag)) { BMLoop *l_first = BM_FACE_FIRST_LOOP(f); @@ -257,8 +257,6 @@ void BM_mesh_delete_hflag_tagged(BMesh *bm, const char hflag, const char htype) void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type) { - BMEdge *e; - BMFace *f; BMIter eiter; BMIter fiter; @@ -271,6 +269,7 @@ void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type) } case DEL_EDGES: { /* flush down to vert */ + BMEdge *e; BM_ITER_MESH (e, &eiter, bm, BM_EDGES_OF_MESH) { if (BM_elem_flag_test(e, hflag)) { BM_elem_flag_enable(e->v1, hflag); @@ -299,6 +298,8 @@ void BM_mesh_delete_hflag_context(BMesh *bm, const char hflag, const int type) } case DEL_FACES: { /* go through and mark all edges and all verts of all faces for delete */ + BMFace *f; + BMEdge *e; BM_ITER_MESH (f, &fiter, bm, BM_FACES_OF_MESH) { if (BM_elem_flag_test(f, hflag)) { BMLoop *l_first = BM_FACE_FIRST_LOOP(f); diff --git a/source/blender/bmesh/intern/bmesh_structure.c b/source/blender/bmesh/intern/bmesh_structure.c index 6baaeb43f1a..7d340f02f2e 100644 --- a/source/blender/bmesh/intern/bmesh_structure.c +++ b/source/blender/bmesh/intern/bmesh_structure.c @@ -182,9 +182,8 @@ void bmesh_disk_edge_remove(BMEdge *e, BMVert *v) BMEdge *bmesh_disk_edge_exists(const BMVert *v1, const BMVert *v2) { - BMEdge *e_iter, *e_first; - if (v1->e) { + BMEdge *e_iter, *e_first; e_first = e_iter = v1->e; do { diff --git a/source/blender/bmesh/operators/bmo_connect_nonplanar.c b/source/blender/bmesh/operators/bmo_connect_nonplanar.c index ac88ffb9065..8112844fc8a 100644 --- a/source/blender/bmesh/operators/bmo_connect_nonplanar.c +++ b/source/blender/bmesh/operators/bmo_connect_nonplanar.c @@ -24,7 +24,7 @@ static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const float no[3]) { float axis_mat[3][3]; - float z_prev, z_curr; + float z_prev; float delta_z = 0.0f; /* Newell's Method */ @@ -35,7 +35,7 @@ static float bm_face_subset_calc_planar(BMLoop *l_first, BMLoop *l_last, const f z_prev = dot_m3_v3_row_z(axis_mat, l_last->v->co); do { - z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co); + const float z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co); delta_z += fabsf(z_curr - z_prev); z_prev = z_curr; } while ((l_iter = l_iter->next) != l_term); diff --git a/source/blender/bmesh/operators/bmo_poke.c b/source/blender/bmesh/operators/bmo_poke.c index 05f13a161b1..6622dbf7575 100644 --- a/source/blender/bmesh/operators/bmo_poke.c +++ b/source/blender/bmesh/operators/bmo_poke.c @@ -52,7 +52,6 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op) } BMO_ITER (f, &oiter, op->slots_in, "faces", BM_FACE) { - BMFace *f_new; float f_center[3]; BMVert *v_center = NULL; BMLoop *l_iter, *l_first; @@ -83,8 +82,7 @@ void bmo_poke_exec(BMesh *bm, BMOperator *op) l_iter = l_first = BM_FACE_FIRST_LOOP(f); do { BMLoop *l_new; - - f_new = BM_face_create_quad_tri( + BMFace *f_new = BM_face_create_quad_tri( bm, l_iter->v, l_iter->next->v, v_center, NULL, f, BM_CREATE_NOP); l_new = BM_FACE_FIRST_LOOP(f_new); diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 02921a5ffec..2e12611a7c9 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -177,7 +177,7 @@ static void axisProjection(const TransInfo *t, const float in[3], float out[3]) { - float norm[3], vec[3], factor, angle; + float vec[3], factor, angle; float t_con_center[3]; if (is_zero_v3(in)) { @@ -214,7 +214,7 @@ static void axisProjection(const TransInfo *t, } else { float v[3]; - float norm_center[3]; + float norm[3], norm_center[3]; float plane[3]; view_vector_calc(t, t_con_center, norm_center); diff --git a/source/blender/imbuf/intern/bmp.c b/source/blender/imbuf/intern/bmp.c index 967cbd04813..af9b62f1a74 100644 --- a/source/blender/imbuf/intern/bmp.c +++ b/source/blender/imbuf/intern/bmp.c @@ -178,7 +178,6 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[ const char(*palette)[4] = (const char(*)[4])(mem + palette_offset); const int startmask = ((1 << depth) - 1) << 8; for (size_t i = y; i > 0; i--) { - int index; int bitoffs = 8; int bitmask = startmask; int nbytes = 0; @@ -189,7 +188,7 @@ ImBuf *imb_bmp_decode(const uchar *mem, size_t size, int flags, char colorspace[ for (size_t j = x; j > 0; j--) { bitoffs -= depth; bitmask >>= depth; - index = (bmp[0] & bitmask) >> bitoffs; + const int index = (bmp[0] & bitmask) >> bitoffs; pcol = palette[index]; /* intentionally BGR -> RGB */ rect[0] = pcol[2]; diff --git a/source/blender/imbuf/intern/readimage.c b/source/blender/imbuf/intern/readimage.c index 4b433836767..b33e9dc4e0e 100644 --- a/source/blender/imbuf/intern/readimage.c +++ b/source/blender/imbuf/intern/readimage.c @@ -209,7 +209,7 @@ static void imb_cache_filename(char *filepath, const char *name, int flags) ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]) { ImBuf *ibuf; - int file, a; + int file; char filepath_tx[IMB_FILENAME_SIZE]; BLI_assert(!BLI_path_is_rel(filepath)); @@ -226,7 +226,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S if (ibuf) { BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); BLI_strncpy(ibuf->cachename, filepath_tx, sizeof(ibuf->cachename)); - for (a = 1; a < ibuf->miptot; a++) { + for (int a = 1; a < ibuf->miptot; a++) { BLI_strncpy(ibuf->mipmap[a - 1]->cachename, filepath_tx, sizeof(ibuf->cachename)); } } diff --git a/source/blender/imbuf/intern/tiff.c b/source/blender/imbuf/intern/tiff.c index dae6ef49c6d..1989566fc32 100644 --- a/source/blender/imbuf/intern/tiff.c +++ b/source/blender/imbuf/intern/tiff.c @@ -549,10 +549,8 @@ ImBuf *imb_loadtiff(const unsigned char *mem, ImbTIFFMemFile memFile; uint32_t width, height; char *format = NULL; - int level; short spp; int ib_depth; - int found; /* Check whether or not we have a TIFF file. */ if (imb_is_a_tiff(mem, size) == 0) { @@ -592,8 +590,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem, if (flags & IB_alphamode_detect) { if (spp == 4) { unsigned short extra, *extraSampleTypes; - - found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes); + const int found = TIFFGetField(image, TIFFTAG_EXTRASAMPLES, &extra, &extraSampleTypes); if (found && (extraSampleTypes[0] == EXTRASAMPLE_ASSOCALPHA)) { ibuf->flags |= IB_alphamode_premul; @@ -617,7 +614,7 @@ ImBuf *imb_loadtiff(const unsigned char *mem, int numlevel = TIFFNumberOfDirectories(image); /* create empty mipmap levels in advance */ - for (level = 0; level < numlevel; level++) { + for (int level = 0; level < numlevel; level++) { if (!TIFFSetDirectory(image, level)) { break; } diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 4aedb1fc611..e0128595b7f 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -169,7 +169,6 @@ void RNA_def_main(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; - CollectionDefFunc *func; /* plural must match idtypes in readblenentry.c */ MainCollectionDef lists[] = { @@ -467,7 +466,7 @@ void RNA_def_main(BlenderRNA *brna) RNA_def_property_ui_text(prop, lists[i].name, lists[i].description); /* collection functions */ - func = lists[i].func; + CollectionDefFunc *func = lists[i].func; if (func) { func(brna, prop); } diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 56dd1fc50f8..3649a108ed4 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -49,11 +49,11 @@ static void deformMatrices(ModifierData *md, { Key *key = BKE_key_from_object(ctx->object); KeyBlock *kb = BKE_keyblock_from_object(ctx->object); - float scale[3][3]; (void)vertexCos; /* unused */ if (kb && kb->totelem == verts_num && kb != key->refkey) { + float scale[3][3]; int a; if (ctx->object->shapeflag & OB_SHAPE_LOCK) { @@ -95,15 +95,14 @@ static void deformMatricesEM(ModifierData *UNUSED(md), { Key *key = BKE_key_from_object(ctx->object); KeyBlock *kb = BKE_keyblock_from_object(ctx->object); - float scale[3][3]; (void)vertexCos; /* unused */ if (kb && kb->totelem == verts_num && kb != key->refkey) { - int a; + float scale[3][3]; scale_m3_fl(scale, kb->curval); - for (a = 0; a < verts_num; a++) { + for (int a = 0; a < verts_num; a++) { copy_m3_m3(defMats[a], scale); } } diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index 15c472dd5a7..726205d18d3 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -96,12 +96,11 @@ static void seq_update_muting_recursive(ListBase *channels, int mute) { Sequence *seq; - int seqmute; /* For sound we go over full meta tree to update muted state, * since sound is played outside of evaluating the imbufs. */ for (seq = seqbasep->first; seq; seq = seq->next) { - seqmute = (mute || SEQ_render_is_muted(channels, seq)); + int seqmute = (mute || SEQ_render_is_muted(channels, seq)); if (seq->type == SEQ_TYPE_META) { /* if this is the current meta sequence, unmute because diff --git a/source/blender/sequencer/intern/strip_transform.c b/source/blender/sequencer/intern/strip_transform.c index 68b30c9ce19..a7361cbb1f9 100644 --- a/source/blender/sequencer/intern/strip_transform.c +++ b/source/blender/sequencer/intern/strip_transform.c @@ -84,7 +84,7 @@ bool SEQ_transform_seqbase_isolated_sel_check(ListBase *seqbase) void SEQ_transform_fix_single_image_seq_offsets(const Scene *scene, Sequence *seq) { - int left, start, offset; + int left, start; if (!SEQ_transform_single_image_check(seq)) { return; } @@ -94,7 +94,7 @@ void SEQ_transform_fix_single_image_seq_offsets(const Scene *scene, Sequence *se left = SEQ_time_left_handle_frame_get(scene, seq); start = seq->start; if (start != left) { - offset = left - start; + const int offset = left - start; SEQ_time_left_handle_frame_set( scene, seq, SEQ_time_left_handle_frame_get(scene, seq) - offset); SEQ_time_right_handle_frame_set( |