From 63916f5941b443dfc8566682bb75374e5abd553f Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 9 Sep 2020 18:41:07 +0200 Subject: Cleanup: reduce variable scope --- source/blender/editors/animation/drivers.c | 6 +- source/blender/editors/animation/fmodifier_ui.c | 6 +- source/blender/editors/animation/keyframes_edit.c | 14 ++--- .../blender/editors/animation/keyframes_general.c | 23 +++----- source/blender/editors/animation/keyframing.c | 15 ++--- source/blender/editors/armature/armature_select.c | 3 +- .../blender/editors/armature/armature_skinning.c | 32 +++++----- source/blender/editors/armature/armature_utils.c | 15 +++-- source/blender/editors/armature/meshlaplacian.c | 22 +++---- source/blender/editors/armature/pose_edit.c | 3 +- source/blender/editors/armature/pose_group.c | 5 +- source/blender/editors/curve/editcurve.c | 34 +++++------ source/blender/editors/curve/editcurve_select.c | 20 +++---- source/blender/editors/gpencil/annotate_paint.c | 5 +- source/blender/editors/gpencil/gpencil_convert.c | 26 ++++----- source/blender/editors/gpencil/gpencil_edit.c | 6 +- source/blender/editors/gpencil/gpencil_merge.c | 11 ++-- source/blender/editors/gpencil/gpencil_paint.c | 9 +-- source/blender/editors/gpencil/gpencil_primitive.c | 8 +-- .../blender/editors/gpencil/gpencil_sculpt_paint.c | 3 +- .../blender/editors/gpencil/gpencil_vertex_ops.c | 3 +- source/blender/editors/interface/interface_align.c | 3 +- source/blender/editors/interface/interface_draw.c | 17 +++--- source/blender/editors/interface/interface_icons.c | 6 +- .../blender/editors/interface/interface_layout.c | 8 +-- source/blender/editors/interface/interface_panel.c | 8 +-- .../editors/interface/interface_region_tooltip.c | 3 +- .../editors/interface/interface_templates.c | 4 +- .../blender/editors/interface/interface_widgets.c | 25 ++++---- source/blender/editors/interface/view2d_ops.c | 7 +-- .../blender/editors/lattice/editlattice_select.c | 9 +-- source/blender/editors/mask/mask_add.c | 25 ++++---- source/blender/editors/mask/mask_ops.c | 46 ++++++--------- source/blender/editors/mask/mask_select.c | 21 +++---- source/blender/editors/mesh/editface.c | 5 +- source/blender/editors/mesh/editmesh_knife.c | 26 ++++----- source/blender/editors/mesh/mesh_data.c | 24 +++----- source/blender/editors/object/object_bake_api.c | 27 ++++----- .../blender/editors/object/object_data_transfer.c | 18 ++---- source/blender/editors/object/object_facemap_ops.c | 4 +- source/blender/editors/object/object_transform.c | 3 +- source/blender/editors/object/object_vgroup.c | 68 ++++++++-------------- source/blender/editors/object/object_warp.c | 10 +--- .../blender/editors/physics/particle_edit_undo.c | 7 +-- source/blender/editors/physics/particle_object.c | 5 +- source/blender/editors/screen/area.c | 5 +- source/blender/editors/sculpt_paint/paint_cursor.c | 3 +- source/blender/editors/sculpt_paint/paint_curve.c | 13 ++--- .../editors/sculpt_paint/paint_image_proj.c | 30 +++++----- source/blender/editors/sculpt_paint/paint_stroke.c | 24 +++----- .../editors/sculpt_paint/paint_vertex_color_ops.c | 15 ++--- .../sculpt_paint/paint_vertex_color_utils.c | 4 +- source/blender/editors/sculpt_paint/sculpt_undo.c | 22 +++---- .../blender/editors/space_buttons/space_buttons.c | 2 +- source/blender/editors/space_clip/clip_buttons.c | 3 +- source/blender/editors/space_clip/clip_draw.c | 17 ++---- source/blender/editors/space_clip/clip_editor.c | 9 ++- source/blender/editors/space_clip/clip_ops.c | 11 ++-- source/blender/editors/space_clip/clip_utils.c | 7 +-- source/blender/editors/space_clip/tracking_ops.c | 11 ++-- .../blender/editors/space_clip/tracking_select.c | 9 +-- source/blender/editors/space_file/filelist.c | 4 +- source/blender/editors/space_file/filesel.c | 9 +-- source/blender/editors/space_file/fsmenu.c | 3 +- source/blender/editors/space_graph/graph_draw.c | 19 +++--- source/blender/editors/space_node/node_add.c | 6 +- .../editors/space_node/node_relationships.c | 13 ++--- source/blender/editors/space_node/node_templates.c | 6 +- .../editors/space_sequencer/sequencer_add.c | 3 +- .../editors/space_sequencer/sequencer_draw.c | 7 +-- .../editors/space_sequencer/sequencer_edit.c | 17 +++--- .../editors/space_sequencer/sequencer_scopes.c | 10 +--- .../editors/space_sequencer/sequencer_select.c | 3 +- source/blender/editors/space_text/text_ops.c | 4 +- source/blender/editors/space_view3d/view3d_draw.c | 5 +- source/blender/editors/space_view3d/view3d_edit.c | 6 +- .../blender/editors/space_view3d/view3d_select.c | 8 +-- .../editors/transform/transform_constraints.c | 3 +- .../editors/transform/transform_convert_mask.c | 3 +- 79 files changed, 378 insertions(+), 584 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 3b15cd794d8..4d5ff33d5cf 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -355,9 +355,8 @@ int ANIM_add_driver_with_target(ReportList *reports, int src_len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr2, prop2) : 1; int len = MIN2(dst_len, src_len); - int i; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, @@ -378,9 +377,8 @@ int ANIM_add_driver_with_target(ReportList *reports, case CREATEDRIVER_MAPPING_1_N: /* 1-N - Specified target index for all */ default: { int len = (RNA_property_array_check(prop)) ? RNA_property_array_length(&ptr, prop) : 1; - int i; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { done_tot += add_driver_with_target(reports, dst_id, dst_path, diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 9d54be61171..a8fb0be4fbf 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -177,7 +177,6 @@ static void draw_modifier__generator(uiLayout *layout, const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; float *cp = NULL; char xval[32]; - uint i; int maxXWidth; /* draw polynomial order selector */ @@ -221,7 +220,7 @@ static void draw_modifier__generator(uiLayout *layout, UI_block_func_set(block, deg_update, fcurve_owner_id, NULL); cp = data->coefficients; - for (i = 0; (i < data->arraysize) && (cp); i++, cp++) { + for (uint i = 0; (i < data->arraysize) && (cp); i++, cp++) { /* To align with first line... */ if (i) { uiDefBut(block, @@ -319,7 +318,6 @@ static void draw_modifier__generator(uiLayout *layout, case FCM_GENERATOR_POLYNOMIAL_FACTORISED: /* Factorized polynomial expression */ { float *cp = NULL; - uint i; /* draw polynomial order selector */ row = uiLayoutRow(layout, false); @@ -351,7 +349,7 @@ static void draw_modifier__generator(uiLayout *layout, UI_block_func_set(block, deg_update, fcurve_owner_id, NULL); cp = data->coefficients; - for (i = 0; (i < data->poly_order) && (cp); i++, cp += 2) { + for (uint i = 0; (i < data->poly_order) && (cp); i++, cp += 2) { /* To align with first line */ if (i) { uiDefBut(block, diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index ef86b132a60..de2525ee150 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -943,11 +943,8 @@ KeyframeEditFunc ANIM_editkeyframes_snap(short mode) static void mirror_bezier_xaxis_ex(BezTriple *bezt, const float center) { - float diff; - int i; - - for (i = 0; i < 3; i++) { - diff = (center - bezt->vec[i][0]); + for (int i = 0; i < 3; i++) { + float diff = (center - bezt->vec[i][0]); bezt->vec[i][0] = (center + diff); } swap_v3_v3(bezt->vec[0], bezt->vec[2]); @@ -958,11 +955,8 @@ static void mirror_bezier_xaxis_ex(BezTriple *bezt, const float center) static void mirror_bezier_yaxis_ex(BezTriple *bezt, const float center) { - float diff; - int i; - - for (i = 0; i < 3; i++) { - diff = (center - bezt->vec[i][1]); + for (int i = 0; i < 3; i++) { + float diff = (center - bezt->vec[i][1]); bezt->vec[i][1] = (center + diff); } } diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 64065d6d633..ea032446fc6 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -108,7 +108,6 @@ void delete_fcurve_key(FCurve *fcu, int index, bool do_recalc) /* Delete selected keyframes in given F-Curve */ bool delete_fcurve_keys(FCurve *fcu) { - int i; bool changed = false; if (fcu->bezt == NULL) { /* ignore baked curves */ @@ -116,7 +115,7 @@ bool delete_fcurve_keys(FCurve *fcu) } /* Delete selected BezTriples */ - for (i = 0; i < fcu->totvert; i++) { + for (int i = 0; i < fcu->totvert; i++) { if (fcu->bezt[i].f2 & SELECT) { memmove(&fcu->bezt[i], &fcu->bezt[i + 1], sizeof(BezTriple) * (fcu->totvert - i - 1)); fcu->totvert--; @@ -148,19 +147,16 @@ void clear_fcurve_keys(FCurve *fcu) /* duplicate selected keyframes for the given F-Curve */ void duplicate_fcurve_keys(FCurve *fcu) { - BezTriple *newbezt; - int i; - /* this can only work when there is an F-Curve, and also when there are some BezTriples */ if (ELEM(NULL, fcu, fcu->bezt)) { return; } - for (i = 0; i < fcu->totvert; i++) { + for (int i = 0; i < fcu->totvert; i++) { /* If a key is selected */ if (fcu->bezt[i].f2 & SELECT) { /* Expand the list */ - newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); + BezTriple *newbezt = MEM_callocN(sizeof(BezTriple) * (fcu->totvert + 1), "beztriple"); memcpy(newbezt, fcu->bezt, sizeof(BezTriple) * (i + 1)); memcpy(newbezt + i + 1, fcu->bezt + i, sizeof(BezTriple)); @@ -489,16 +485,15 @@ typedef struct tSmooth_Bezt { // TODO: introduce scaling factor for weighting falloff void smooth_fcurve(FCurve *fcu) { - BezTriple *bezt; - int i, x, totSel = 0; + int totSel = 0; if (fcu->bezt == NULL) { return; } /* first loop through - count how many verts are selected */ - bezt = fcu->bezt; - for (i = 0; i < fcu->totvert; i++, bezt++) { + BezTriple *bezt = fcu->bezt; + for (int i = 0; i < fcu->totvert; i++, bezt++) { if (BEZT_ISSEL_ANY(bezt)) { totSel++; } @@ -513,7 +508,7 @@ void smooth_fcurve(FCurve *fcu) /* populate tarray with data of selected points */ bezt = fcu->bezt; - for (i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { + for (int i = 0, x = 0; (i < fcu->totvert) && (x < totSel); i++, bezt++) { if (BEZT_ISSEL_ANY(bezt)) { /* tsb simply needs pointer to vec, and index */ tsb->h1 = &bezt->vec[0][1]; @@ -539,7 +534,7 @@ void smooth_fcurve(FCurve *fcu) /* round 1: calculate smoothing deltas and new values */ tsb = tarray; - for (i = 0; i < totSel; i++, tsb++) { + for (int i = 0; i < totSel; i++, tsb++) { /* Don't touch end points (otherwise, curves slowly explode, * as we don't have enough data there). */ if (ELEM(i, 0, (totSel - 1)) == 0) { @@ -564,7 +559,7 @@ void smooth_fcurve(FCurve *fcu) /* round 2: apply new values */ tsb = tarray; - for (i = 0; i < totSel; i++, tsb++) { + for (int i = 0; i < totSel; i++, tsb++) { /* don't touch end points, as their values weren't touched above */ if (ELEM(i, 0, (totSel - 1)) == 0) { /* y2 takes the average of the 2 points */ diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 66d4882cf9d..fb4c0ae0758 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -618,22 +618,19 @@ enum { */ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) { - BezTriple *bezt = NULL, *prev = NULL; - int totCount, i; - float valA = 0.0f, valB = 0.0f; - /* safety checking */ if (fcu == NULL) { return KEYNEEDED_JUSTADD; } - totCount = fcu->totvert; + int totCount = fcu->totvert; if (totCount == 0) { return KEYNEEDED_JUSTADD; } /* loop through checking if any are the same */ - bezt = fcu->bezt; - for (i = 0; i < totCount; i++) { + BezTriple *bezt = fcu->bezt; + BezTriple *prev = NULL; + for (int i = 0; i < totCount; i++) { float prevPosi = 0.0f, prevVal = 0.0f; float beztPosi = 0.0f, beztVal = 0.0f; @@ -712,8 +709,8 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) * keyframe is not equal to last keyframe. */ bezt = (fcu->bezt + (fcu->totvert - 1)); - valA = bezt->vec[1][1]; - + float valA = bezt->vec[1][1]; + float valB; if (prev) { valB = prev->vec[1][1]; } diff --git a/source/blender/editors/armature/armature_select.c b/source/blender/editors/armature/armature_select.c index 7fba855ffdb..4c5efb304c9 100644 --- a/source/blender/editors/armature/armature_select.c +++ b/source/blender/editors/armature/armature_select.c @@ -177,11 +177,10 @@ static void *ed_armature_pick_bone_from_selectbuffer_impl(const bool is_editmode void *firstunSel = NULL, *firstSel = NULL, *data; Base *firstunSel_base = NULL, *firstSel_base = NULL; uint hitresult; - short i; bool takeNext = false; int minsel = 0xffffffff, minunsel = 0xffffffff; - for (i = 0; i < hits; i++) { + for (short i = 0; i < hits; i++) { hitresult = buffer[3 + (i * 4)]; if (hitresult & BONESEL_ANY) { /* to avoid including objects in selection */ diff --git a/source/blender/editors/armature/armature_skinning.c b/source/blender/editors/armature/armature_skinning.c index ea9b0eb92b9..aa742d4b7ba 100644 --- a/source/blender/editors/armature/armature_skinning.c +++ b/source/blender/editors/armature/armature_skinning.c @@ -212,10 +212,6 @@ static void envelope_bone_weighting(Object *ob, { /* Create vertex group weights from envelopes */ - Bone *bone; - bDeformGroup *dgroup; - float distance; - int i, iflip, j; bool use_topology = (mesh->editflag & ME_EDIT_MIRROR_TOPO) != 0; bool use_mask = false; @@ -225,30 +221,30 @@ static void envelope_bone_weighting(Object *ob, } /* for each vertex in the mesh */ - for (i = 0; i < mesh->totvert; i++) { + for (int i = 0; i < mesh->totvert; i++) { if (use_mask && !(mesh->mvert[i].flag & SELECT)) { continue; } - iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1; + int iflip = (dgroupflip) ? mesh_get_x_mirror_vert(ob, NULL, i, use_topology) : -1; /* for each skinnable bone */ - for (j = 0; j < numbones; j++) { + for (int j = 0; j < numbones; j++) { if (!selected[j]) { continue; } - bone = bonelist[j]; - dgroup = dgrouplist[j]; + Bone *bone = bonelist[j]; + bDeformGroup *dgroup = dgrouplist[j]; /* store the distance-factor from the vertex to the bone */ - distance = distfactor_to_bone(verts[i], - root[j], - tip[j], - bone->rad_head * scale, - bone->rad_tail * scale, - bone->dist * scale); + float distance = distfactor_to_bone(verts[i], + root[j], + tip[j], + bone->rad_head * scale, + bone->rad_tail * scale, + bone->dist * scale); /* add the vert to the deform group if (weight != 0.0) */ if (distance != 0.0f) { @@ -300,7 +296,7 @@ static void add_verts_to_dgroups(ReportList *reports, Mat4 bbone_array[MAX_BBONE_SUBDIV], *bbone = NULL; float(*root)[3], (*tip)[3], (*verts)[3]; int *selected; - int numbones, vertsfilled = 0, i, j, segments = 0; + int numbones, vertsfilled = 0, segments = 0; const bool wpmode = (ob->mode & OB_MODE_WEIGHT_PAINT); struct { Object *armob; @@ -346,7 +342,7 @@ static void add_verts_to_dgroups(ReportList *reports, tip = MEM_callocN(sizeof(float[3]) * numbones, "tip"); selected = MEM_callocN(sizeof(int) * numbones, "selected"); - for (j = 0; j < numbones; j++) { + for (int j = 0; j < numbones; j++) { bone = bonelist[j]; dgroup = dgrouplist[j]; @@ -427,7 +423,7 @@ static void add_verts_to_dgroups(ReportList *reports, } /* transform verts to global space */ - for (i = 0; i < mesh->totvert; i++) { + for (int i = 0; i < mesh->totvert; i++) { if (!vertsfilled) { copy_v3_v3(verts[i], mesh->mvert[i].co); } diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 04c1ec97841..1c8c5ba9d94 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -198,27 +198,26 @@ bool ED_armature_ebone_is_child_recursive(EditBone *ebone_parent, EditBone *ebon */ EditBone *ED_armature_ebone_find_shared_parent(EditBone *ebone_child[], const uint ebone_child_tot) { - uint i; - EditBone *ebone_iter; - #define EBONE_TEMP_UINT(ebone) (*((uint *)(&((ebone)->temp)))) /* clear all */ - for (i = 0; i < ebone_child_tot; i++) { - for (ebone_iter = ebone_child[i]; ebone_iter; ebone_iter = ebone_iter->parent) { + for (uint i = 0; i < ebone_child_tot; i++) { + for (EditBone *ebone_iter = ebone_child[i]; ebone_iter; ebone_iter = ebone_iter->parent) { EBONE_TEMP_UINT(ebone_iter) = 0; } } /* accumulate */ - for (i = 0; i < ebone_child_tot; i++) { - for (ebone_iter = ebone_child[i]->parent; ebone_iter; ebone_iter = ebone_iter->parent) { + for (uint i = 0; i < ebone_child_tot; i++) { + for (EditBone *ebone_iter = ebone_child[i]->parent; ebone_iter; + ebone_iter = ebone_iter->parent) { EBONE_TEMP_UINT(ebone_iter) += 1; } } /* only need search the first chain */ - for (ebone_iter = ebone_child[0]->parent; ebone_iter; ebone_iter = ebone_iter->parent) { + for (EditBone *ebone_iter = ebone_child[0]->parent; ebone_iter; + ebone_iter = ebone_iter->parent) { if (EBONE_TEMP_UINT(ebone_iter) == ebone_child_tot) { return ebone_iter; } diff --git a/source/blender/editors/armature/meshlaplacian.c b/source/blender/editors/armature/meshlaplacian.c index 1534ea3287f..cf64cfc849d 100644 --- a/source/blender/editors/armature/meshlaplacian.c +++ b/source/blender/editors/armature/meshlaplacian.c @@ -1041,7 +1041,6 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, MDefBoundIsect *isect; float(*mp_cagecos)[3] = BLI_array_alloca(mp_cagecos, mp->totloop); - int i; /* create MDefBoundIsect, and extra for 'poly_weights[]' */ isect = BLI_memarena_alloc(mdb->memarena, sizeof(*isect) + (sizeof(float) * mp->totloop)); @@ -1056,7 +1055,7 @@ static MDefBoundIsect *meshdeform_ray_tree_intersect(MeshDeformBind *mdb, isect->len = max_ff(len_v3v3(co1, isect->co), MESHDEFORM_LEN_THRESHOLD); /* compute mean value coordinates for interpolation */ - for (i = 0; i < mp->totloop; i++) { + for (int i = 0; i < mp->totloop; i++) { copy_v3_v3(mp_cagecos[i], cagecos[mloop[mp->loopstart + i].v]); } @@ -1225,9 +1224,8 @@ static float meshdeform_boundary_phi(const MeshDeformBind *mdb, { const MLoop *mloop = mdb->cagemesh_cache.mloop; const MPoly *mp = &mdb->cagemesh_cache.mpoly[isect->poly_index]; - int i; - for (i = 0; i < mp->totloop; i++) { + for (int i = 0; i < mp->totloop; i++) { if (mloop[mp->loopstart + i].v == cagevert) { return isect->poly_weights[i]; } @@ -1241,16 +1239,18 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, float *UNUSED(vec), int UNUSED(cagevert)) { - float dvec[3], ivec[3], wx, wy, wz, result = 0.0f; - float weight, totweight = 0.0f; - int i, a, x, y, z; + float dvec[3], ivec[3], result = 0.0f; + float totweight = 0.0f; - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { ivec[i] = (int)gridvec[i]; dvec[i] = gridvec[i] - ivec[i]; } - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { + int x, y, z; + float wx, wy, wz; + if (i & 1) { x = ivec[0] + 1; wx = dvec[0]; @@ -1282,8 +1282,8 @@ static float meshdeform_interp_w(MeshDeformBind *mdb, CLAMP(y, 0, mdb->size - 1); CLAMP(z, 0, mdb->size - 1); - a = meshdeform_index(mdb, x, y, z, 0); - weight = wx * wy * wz; + int a = meshdeform_index(mdb, x, y, z, 0); + float weight = wx * wy * wz; result += weight * mdb->phi[a]; totweight += weight; } diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 0cd3afc9cf9..85948f3abc3 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -742,7 +742,6 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) int maxLayers = (RNA_boolean_get(op->ptr, "all")) ? 32 : 16; /* hardcoded for now - we can only have 32 armature layers, so this should be fine... */ bool layers[32] = {false}; - int i; /* sanity checking */ if (arm == NULL) { @@ -755,7 +754,7 @@ static int pose_armature_layers_showall_exec(bContext *C, wmOperator *op) */ RNA_id_pointer_create(&arm->id, &ptr); - for (i = 0; i < maxLayers; i++) { + for (int i = 0; i < maxLayers; i++) { layers[i] = 1; } diff --git a/source/blender/editors/armature/pose_group.c b/source/blender/editors/armature/pose_group.c index cb7c68178d9..ffa28bf9e36 100644 --- a/source/blender/editors/armature/pose_group.c +++ b/source/blender/editors/armature/pose_group.c @@ -381,8 +381,6 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) bPoseChannel *pchan; tSortActionGroup *agrp_array; bActionGroup *agrp; - int agrp_count; - int i; if (ELEM(NULL, ob, pose)) { return OPERATOR_CANCELLED; @@ -392,8 +390,9 @@ static int group_sort_exec(bContext *C, wmOperator *UNUSED(op)) } /* create temporary array with bone groups and indices */ - agrp_count = BLI_listbase_count(&pose->agroups); + int agrp_count = BLI_listbase_count(&pose->agroups); agrp_array = MEM_mallocN(sizeof(tSortActionGroup) * agrp_count, "sort bone groups"); + int i; for (agrp = pose->agroups.first, i = 0; agrp; agrp = agrp->next, i++) { BLI_assert(i < agrp_count); agrp_array[i].agrp = agrp; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index fb102574a85..2b3df79476a 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1144,7 +1144,7 @@ static int *init_index_map(Object *obedit, int *r_old_totvert) Nurb *nu; CVKeyIndex *keyIndex; int *old_to_new_map; - int old_totvert, i; + int old_totvert; int vertex_index; for (nu = curve->nurb.first, old_totvert = 0; nu != NULL; nu = nu->next) { @@ -1157,7 +1157,7 @@ static int *init_index_map(Object *obedit, int *r_old_totvert) } old_to_new_map = MEM_mallocN(old_totvert * sizeof(int), "curve old to new index map"); - for (i = 0; i < old_totvert; i++) { + for (int i = 0; i < old_totvert; i++) { old_to_new_map[i] = -1; } @@ -2804,19 +2804,15 @@ static void smooth_single_bezt(BezTriple *bezt, const BezTriple *bezt_orig_next, float factor) { - int i; - BLI_assert(IN_RANGE_INCL(factor, 0.0f, 1.0f)); - for (i = 0; i < 3; i++) { - float val_old, val_new, offset; - + for (int i = 0; i < 3; i++) { /* get single dimension pos of the mid handle */ - val_old = bezt->vec[1][i]; + float val_old = bezt->vec[1][i]; /* get the weights of the previous/next mid handles and calc offset */ - val_new = (bezt_orig_prev->vec[1][i] * 0.5f) + (bezt_orig_next->vec[1][i] * 0.5f); - offset = (val_old * (1.0f - factor)) + (val_new * factor) - val_old; + float val_new = (bezt_orig_prev->vec[1][i] * 0.5f) + (bezt_orig_next->vec[1][i] * 0.5f); + float offset = (val_old * (1.0f - factor)) + (val_new * factor) - val_old; /* offset midpoint and 2 handles */ bezt->vec[1][i] += offset; @@ -2833,11 +2829,9 @@ static void smooth_single_bp(BPoint *bp, const BPoint *bp_orig_next, float factor) { - int i; - BLI_assert(IN_RANGE_INCL(factor, 0.0f, 1.0f)); - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { float val_old, val_new, offset; val_old = bp->vec[i]; @@ -3472,7 +3466,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) BezTriple *bezt, *beztnew, *beztn; BPoint *bp, *prevbp, *bpnew, *bpn; float vec[15]; - int a, b, sel, amount, *usel, *vsel, i; + int a, b, sel, amount, *usel, *vsel; float factor; // printf("*** subdivideNurb: entering subdivide\n"); @@ -3525,7 +3519,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) memcpy(prevvec, bezt->vec, sizeof(float[9])); - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = 1.0f / (number_cuts + 1 - i); memcpy(beztn, nextbezt, sizeof(BezTriple)); @@ -3615,7 +3609,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) if ((bp->f1 & SELECT) && (nextbp->f1 & SELECT)) { // printf("*** subdivideNurb: insert 'linear' point\n"); - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); memcpy(bpn, nextbp, sizeof(BPoint)); @@ -3718,7 +3712,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) bp++; if (b < nu->pntsu - 1) { prevbp = bp - 1; - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); *bpn = *bp; interp_v4_v4v4(bpn->vec, prevbp->vec, bp->vec, factor); @@ -3736,7 +3730,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) for (b = 0; b < (number_cuts + 1) * nu->pntsu - number_cuts; b++) { BPoint *tmp = bpn; - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); *tmp = *bp; interp_v4_v4v4(tmp->vec, prevbp->vec, bp->vec, factor); @@ -3778,7 +3772,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) bp++; } if ((a < nu->pntsv - 1) && vsel[a] == nu->pntsu && vsel[a + 1] == nu->pntsu) { - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); prevbp = bp - nu->pntsu; for (b = 0; b < nu->pntsu; b++) { @@ -3834,7 +3828,7 @@ static void subdividenurb(Object *obedit, View3D *v3d, int number_cuts) * handle at most 3rd order curves? I miss * some symmetry here... */ - for (i = 0; i < number_cuts; i++) { + for (int i = 0; i < number_cuts; i++) { factor = (float)(i + 1) / (number_cuts + 1); prevbp = bp - 1; *bpn = *prevbp; diff --git a/source/blender/editors/curve/editcurve_select.c b/source/blender/editors/curve/editcurve_select.c index b60eb258916..4b502e9e336 100644 --- a/source/blender/editors/curve/editcurve_select.c +++ b/source/blender/editors/curve/editcurve_select.c @@ -1874,10 +1874,6 @@ static void curve_select_shortest_path_curve(Nurb *nu, int vert_src, int vert_ds static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst) { - HeapSimple *heap; - - int i, vert_curr; - int totu = nu->pntsu; int totv = nu->pntsv; int vert_num = totu * totv; @@ -1890,34 +1886,32 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst /* init connectivity data */ data = MEM_mallocN(sizeof(*data) * vert_num, __func__); - for (i = 0; i < vert_num; i++) { + for (int i = 0; i < vert_num; i++) { data[i].vert = i; data[i].vert_prev = -1; data[i].cost = FLT_MAX; } /* init heap */ - heap = BLI_heapsimple_new(); + HeapSimple *heap = BLI_heapsimple_new(); - vert_curr = data[vert_src].vert; + int vert_curr = data[vert_src].vert; BLI_heapsimple_insert(heap, 0.0f, &data[vert_src].vert); data[vert_src].cost = 0.0f; data[vert_src].vert_prev = vert_src; /* nop */ while (!BLI_heapsimple_is_empty(heap)) { - int axis, sign; - int u, v; - vert_curr = *((int *)BLI_heapsimple_pop_min(heap)); if (vert_curr == vert_dst) { break; } + int u, v; BKE_nurb_index_to_uv(nu, vert_curr, &u, &v); /* loop over 4 adjacent verts */ - for (sign = -1; sign != 3; sign += 2) { - for (axis = 0; axis != 2; axis += 1) { + for (int sign = -1; sign != 3; sign += 2) { + for (int axis = 0; axis != 2; axis += 1) { int uv_other[2] = {u, v}; int vert_other; @@ -1943,7 +1937,7 @@ static void curve_select_shortest_path_surf(Nurb *nu, int vert_src, int vert_dst BLI_heapsimple_free(heap, NULL); if (vert_curr == vert_dst) { - i = 0; + int i = 0; while (vert_curr != vert_src && i++ < vert_num) { if (nu->type == CU_BEZIER) { select_beztriple(&nu->bezt[vert_curr], SELECT, SELECT, HIDDEN); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 8237e6cfd62..ab3b1525e9e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1119,7 +1119,6 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p, bGPDspoint *pt1, *pt2; int pc1[2] = {0}; int pc2[2] = {0}; - int i; int mval_i[2]; round_v2i_v2fl(mval_i, mval); @@ -1152,7 +1151,7 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p, * we don't miss anything, though things will be * slightly slower as a result */ - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { bGPDspoint *pt = &gps->points[i]; pt->flag &= ~GP_SPOINT_TAG; } @@ -1161,7 +1160,7 @@ static void annotation_stroke_eraser_dostroke(tGPsdata *p, * 1) Thin out parts of the stroke under the brush * 2) Tag "too thin" parts for removal (in second pass) */ - for (i = 0; (i + 1) < gps->totpoints; i++) { + for (int i = 0; (i + 1) < gps->totpoints; i++) { /* get points to work with */ pt1 = gps->points + i; pt2 = gps->points + i + 1; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 21d755bea52..3b62b44c7cd 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -371,10 +371,9 @@ static void gpencil_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, int *nbr_gaps, float *tot_gaps_time) { - int i; float delta_time = 0.0f; - for (i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->num_points; i++) { if (gtd->times[i] < 0 && i) { (*nbr_gaps)++; gtd->times[i] = -gtd->times[i] - delta_time; @@ -420,14 +419,11 @@ static void gpencil_stroke_path_animation_add_keyframes(ReportList *reports, float delta_time = 0.0f, next_delta_time = 0.0f; int nbr_done_gaps = 0; - int i; - float cfra; - /* This is a bit tricky, as: * - We can't add arbitrarily close points on FCurve (in time). * - We *must* have all "caps" points of all strokes in FCurve, as much as possible! */ - for (i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->num_points; i++) { /* If new stroke... */ if (i > end_stroke_idx) { start_stroke_idx = i; @@ -442,7 +438,7 @@ static void gpencil_stroke_path_animation_add_keyframes(ReportList *reports, /* Simple proportional stuff... */ cu->ctime = gtd->dists[i] / gtd->tot_dist * cu->pathlen; - cfra = time_start + ((gtd->times[i] + delta_time) / gtd->tot_time * time_range); + float cfra = time_start + ((gtd->times[i] + delta_time) / gtd->tot_time * time_range); /* And now, the checks about timing... */ if (i == start_stroke_idx) { @@ -527,7 +523,7 @@ static void gpencil_stroke_path_animation(bContext *C, FCurve *fcu; PointerRNA ptr; PropertyRNA *prop = NULL; - int nbr_gaps = 0, i; + int nbr_gaps = 0; if (gtd->mode == GP_STROKECONVERT_TIMING_NONE) { return; @@ -551,7 +547,7 @@ static void gpencil_stroke_path_animation(bContext *C, if (G.debug & G_DEBUG) { printf("%s: tot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time); - for (i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->num_points; i++) { printf("\tpoint %d:\t\tlen: %f\t\ttime: %f\n", i, gtd->dists[i], gtd->times[i]); } } @@ -628,7 +624,7 @@ static void gpencil_stroke_path_animation(bContext *C, if (G.debug & G_DEBUG) { printf("%s: \ntot len: %f\t\ttot time: %f\n", __func__, gtd->tot_dist, gtd->tot_time); - for (i = 0; i < gtd->num_points; i++) { + for (int i = 0; i < gtd->num_points; i++) { printf("\tpoint %d:\t\tlen: %f\t\ttime: %f\n", i, gtd->dists[i], gtd->times[i]); } printf("\n\n"); @@ -1251,12 +1247,10 @@ static void gpencil_stroke_finalize_curve_endpoints(Curve *cu) static void gpencil_stroke_norm_curve_weights(Curve *cu, const float minmax_weights[2]) { - Nurb *nu; const float delta = minmax_weights[0]; - float fac; - int i; /* when delta == minmax_weights[0] == minmax_weights[1], we get div by zero [#35686] */ + float fac; if (IS_EQF(delta, minmax_weights[1])) { fac = 1.0f; } @@ -1264,16 +1258,16 @@ static void gpencil_stroke_norm_curve_weights(Curve *cu, const float minmax_weig fac = 1.0f / (minmax_weights[1] - delta); } - for (nu = cu->nurb.first; nu; nu = nu->next) { + LISTBASE_FOREACH (Nurb *, nu, &cu->nurb) { if (nu->bezt) { BezTriple *bezt = nu->bezt; - for (i = 0; i < nu->pntsu; i++, bezt++) { + for (int i = 0; i < nu->pntsu; i++, bezt++) { bezt->weight = (bezt->weight - delta) * fac; } } else if (nu->bp) { BPoint *bp = nu->bp; - for (i = 0; i < nu->pntsu; i++, bp++) { + for (int i = 0; i < nu->pntsu; i++, bp++) { bp->weight = (bp->weight - delta) * fac; } } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 37338ec4592..ac8085f0e53 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -4725,7 +4725,6 @@ static int gpencil_cutter_lasso_select(bContext *C, const float scale = ts->gp_sculpt.isect_threshold; bGPDspoint *pt; - int i; GP_SpaceConversion gsc = {NULL}; bool changed = false; @@ -4741,6 +4740,7 @@ static int gpencil_cutter_lasso_select(bContext *C, /* deselect all strokes first */ CTX_DATA_BEGIN (C, bGPDstroke *, gps, editable_gpencil_strokes) { + int i; for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { pt->flag &= ~GP_SPOINT_SELECT; } @@ -4753,7 +4753,7 @@ static int gpencil_cutter_lasso_select(bContext *C, GP_EDITABLE_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) { int tot_inside = 0; const int oldtot = gps->totpoints; - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { pt = &gps->points[i]; if ((pt->flag & GP_SPOINT_SELECT) || (pt->flag & GP_SPOINT_TAG)) { continue; @@ -4777,7 +4777,7 @@ static int gpencil_cutter_lasso_select(bContext *C, } /* if mark all points inside lasso set to remove all stroke */ if ((tot_inside == oldtot) || ((tot_inside == 1) && (oldtot == 2))) { - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { pt = &gps->points[i]; pt->flag |= GP_SPOINT_SELECT; } diff --git a/source/blender/editors/gpencil/gpencil_merge.c b/source/blender/editors/gpencil/gpencil_merge.c index 4aae0b97e05..ca93e8de844 100644 --- a/source/blender/editors/gpencil/gpencil_merge.c +++ b/source/blender/editors/gpencil/gpencil_merge.c @@ -200,7 +200,6 @@ static void gpencil_calc_points_factor(bContext *C, tGPencilPointCache *src_array) { bGPDspoint *pt; - int i; int idx = 0; /* create selected point array an fill it */ @@ -214,6 +213,7 @@ static void gpencil_calc_points_factor(bContext *C, } LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { if (gps->flag & GP_STROKE_SELECT) { + int i; for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { if (clear_stroke) { pt->flag |= GP_SPOINT_TAG; @@ -252,7 +252,7 @@ static void gpencil_calc_points_factor(bContext *C, /* calc center */ float center[2] = {0.0f, 0.0f}; - for (i = 0; i < totpoints; i++) { + for (int i = 0; i < totpoints; i++) { center[0] += points2d[i][0]; center[1] += points2d[i][1]; } @@ -261,7 +261,7 @@ static void gpencil_calc_points_factor(bContext *C, /* calc angle and distance to center for each point */ const float axis[2] = {1.0f, 0.0f}; float v1[3]; - for (i = 0; i < totpoints; i++) { + for (int i = 0; i < totpoints; i++) { float ln = len_v2v2(center, points2d[i]); sub_v2_v2v2(v1, points2d[i], center); float angle = angle_signed_v2v2(axis, v1); @@ -337,10 +337,9 @@ static void gpencil_get_extremes( tGPencilPointCache *src_array, int totpoints, bGPDstroke *gps_filter, float *start, float *end) { tGPencilPointCache *array_pt = NULL; - int i; /* find first point */ - for (i = 0; i < totpoints; i++) { + for (int i = 0; i < totpoints; i++) { array_pt = &src_array[i]; if (gps_filter == array_pt->gps) { copy_v3_v3(start, &array_pt->x); @@ -348,7 +347,7 @@ static void gpencil_get_extremes( } } /* find last point */ - for (i = totpoints - 1; i >= 0; i--) { + for (int i = totpoints - 1; i >= 0; i--) { array_pt = &src_array[i]; if (gps_filter == array_pt->gps) { copy_v3_v3(end, &array_pt->x); diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 09fb65b654e..6748211a1bc 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -941,7 +941,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) const bool is_depth = (bool)(*align_flag & (GP_PROJECT_DEPTH_VIEW | GP_PROJECT_DEPTH_STROKE)); const bool is_camera = (bool)(ts->gp_sculpt.lock_axis == 0) && (rv3d->persp == RV3D_CAMOB) && (!is_depth); - int i, totelem; + int totelem; /* For very low pressure at the end, truncate stroke. */ if (p->paintmode == GP_PAINTMODE_DRAW) { @@ -1079,7 +1079,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* reproject to plane (only in 3d space) */ gpencil_reproject_toplane(p, gps); pt = gps->points; - for (i = 0; i < gps->totpoints; i++, pt++) { + for (int i = 0; i < gps->totpoints; i++, pt++) { /* if parented change position relative to parent object */ gpencil_apply_parent_point(depsgraph, obact, gpl, pt); } @@ -1099,7 +1099,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) int found_depth = 0; depth_arr = MEM_mallocN(sizeof(float) * gpd->runtime.sbuffer_used, "depth_points"); - + int i; for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used; i++, ptc++, pt++) { round_v2i_v2fl(mval_i, &ptc->x); @@ -1169,6 +1169,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) dvert = gps->dvert; /* convert all points (normal behavior) */ + int i; for (i = 0, ptc = gpd->runtime.sbuffer; i < gpd->runtime.sbuffer_used && ptc; i++, ptc++, pt++) { /* convert screen-coordinates to appropriate coordinates (and store them) */ @@ -1266,7 +1267,7 @@ static void gpencil_stroke_newfrombuffer(tGPsdata *p) /* add weights */ if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) { BKE_gpencil_dvert_ensure(gps); - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { MDeformVert *ve = &gps->dvert[i]; MDeformWeight *dw = BKE_defvert_ensure_index(ve, def_nr); if (dw) { diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index 04e440a1960..c03ff05ac73 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -773,7 +773,6 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) /* get an array of depths, far depths are blended */ float *depth_arr = NULL; if (is_depth) { - int i; int mval_i[2], mval_prev[2] = {0}; bool interp_depth = false; bool found_depth = false; @@ -787,7 +786,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) depth_arr = MEM_mallocN(sizeof(float) * gps->totpoints, "depth_points"); tGPspoint *ptc = &points2D[0]; - for (i = 0; i < gps->totpoints; i++, ptc++) { + for (int i = 0; i < gps->totpoints; i++, ptc++) { round_v2i_v2fl(mval_i, &ptc->x); if ((ED_view3d_autodist_depth(tgpi->region, mval_i, depth_margin, depth_arr + i) == 0) && (i && (ED_view3d_autodist_depth_seg( @@ -801,14 +800,14 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) } if (!found_depth) { - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { depth_arr[i] = 0.9999f; } } else { /* if all depth are too high disable */ bool valid_depth = false; - for (i = 0; i < gps->totpoints; i++) { + for (int i = 0; i < gps->totpoints; i++) { if (depth_arr[i] < 0.9999f) { valid_depth = true; break; @@ -826,6 +825,7 @@ static void gpencil_primitive_update_strokes(bContext *C, tGPDprimitive *tgpi) int last_valid = 0; /* find first valid contact point */ + int i; for (i = 0; i < gps->totpoints; i++) { if (depth_arr[i] != FLT_MAX) { break; diff --git a/source/blender/editors/gpencil/gpencil_sculpt_paint.c b/source/blender/editors/gpencil/gpencil_sculpt_paint.c index 4a5da10cdbf..30b32f54442 100644 --- a/source/blender/editors/gpencil/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil/gpencil_sculpt_paint.c @@ -546,12 +546,11 @@ static void gpencil_brush_grab_apply_cached(tGP_BrushEditData *gso, return; } - int i; float inverse_diff_mat[4][4]; invert_m4_m4(inverse_diff_mat, diff_mat); /* Apply dvec to all of the stored points */ - for (i = 0; i < data->size; i++) { + for (int i = 0; i < data->size; i++) { bGPDspoint *pt = &gps->points[data->points[i]]; float delta[3] = {0.0f}; diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil/gpencil_vertex_ops.c index 36ce7d3dc47..69e50beb66e 100644 --- a/source/blender/editors/gpencil/gpencil_vertex_ops.c +++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c @@ -682,7 +682,6 @@ static int gpencil_material_to_vertex_exec(bContext *C, wmOperator *op) char name[32] = ""; Material *ma = NULL; GPMatArray *mat_elm = NULL; - int i; bool changed = false; @@ -744,6 +743,7 @@ static int gpencil_material_to_vertex_exec(bContext *C, wmOperator *op) /* Check if material exist. */ bool found = false; + int i; for (i = 0; i < totmat; i++) { mat_elm = &mat_table[i]; if (mat_elm->ma == NULL) { @@ -796,6 +796,7 @@ static int gpencil_material_to_vertex_exec(bContext *C, wmOperator *op) /* Update all points. */ bGPDspoint *pt; + int i; for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { copy_v3_v3(pt->vert_color, gp_style->stroke_rgba); pt->vert_color[3] = 1.0f; diff --git a/source/blender/editors/interface/interface_align.c b/source/blender/editors/interface/interface_align.c index e92adc8a2ec..d626c57b121 100644 --- a/source/blender/editors/interface/interface_align.c +++ b/source/blender/editors/interface/interface_align.c @@ -393,7 +393,6 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region) ButAlign *butal_array; ButAlign *butal, *butal_other; int side; - int i, j; /* First loop: we count number of buttons belonging to an align group, * and clear their align flag. @@ -452,9 +451,11 @@ void ui_block_align_calc(uiBlock *block, const ARegion *region) /* Third loop: for each pair of buttons in the same align group, * we compute their potential proximity. Note that each pair is checked only once, and that we * break early in case we know all remaining pairs will always be too far away. */ + int i; for (i = 0, butal = butal_array; i < num_buttons; i++, butal++) { const short alignnr = butal->but->alignnr; + int j; for (j = i + 1, butal_other = &butal_array[i + 1]; j < num_buttons; j++, butal_other++) { const float max_delta = MAX_DELTA; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 4d53018cd32..bcb8a10be02 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -2162,7 +2162,6 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, const uiWidgetColors *wcol, const rcti *rect) { - uint i; float fx, fy; uiButCurveProfile *but_profile = (uiButCurveProfile *)but; @@ -2241,7 +2240,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, /* Create array of the positions of the table's points. */ float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords"); - for (i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len); + for (uint i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len); i++) { /* Only add the points from the table here. */ table_coords[i][0] = pts[i].x; table_coords[i][1] = pts[i].y; @@ -2284,7 +2283,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, GPU_blend(GPU_BLEND_ALPHA); GPU_polygon_smooth(false); immBegin(GPU_PRIM_TRIS, 3 * tot_triangles); - for (i = 0; i < tot_triangles; i++) { + for (uint i = 0; i < tot_triangles; i++) { for (uint j = 0; j < 3; j++) { uint *tri = tri_indices[i]; fx = rect->xmin + zoomx * (table_coords[tri[j]][0] - offsx); @@ -2301,7 +2300,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, immUniformColor3ubvAlpha((const uchar *)wcol->item, 255); GPU_line_smooth(true); immBegin(GPU_PRIM_LINE_STRIP, tot_points - 1); - for (i = 0; i < tot_points - 1; i++) { + for (uint i = 0; i < tot_points - 1; i++) { fx = rect->xmin + zoomx * (table_coords[i][0] - offsx); fy = rect->ymin + zoomy * (table_coords[i][1] - offsy); immVertex2f(pos, fx, fy); @@ -2313,7 +2312,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, pts = profile->path; tot_points = (uint)profile->path_len; int selected_free_points = 0; - for (i = 0; i < tot_points; i++) { + for (uint i = 0; i < tot_points; i++) { if (point_draw_handles(&pts[i])) { selected_free_points++; } @@ -2325,7 +2324,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, GPU_line_smooth(true); immBegin(GPU_PRIM_LINES, selected_free_points * 4); float ptx, pty; - for (i = 0; i < tot_points; i++) { + for (uint i = 0; i < tot_points; i++) { if (point_draw_handles(&pts[i])) { ptx = rect->xmin + zoomx * (pts[i].x - offsx); pty = rect->ymin + zoomy * (pts[i].y - offsy); @@ -2372,7 +2371,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, GPU_blend(GPU_BLEND_NONE); GPU_point_size(max_ff(3.0f, min_ff(UI_DPI_FAC / but->block->aspect * 5.0f, 5.0f))); immBegin(GPU_PRIM_POINTS, tot_points); - for (i = 0; i < tot_points; i++) { + for (uint i = 0; i < tot_points; i++) { fx = rect->xmin + zoomx * (pts[i].x - offsx); fy = rect->ymin + zoomy * (pts[i].y - offsy); immAttr4fv(col, (pts[i].flag & PROF_SELECT) ? color_vert_select : color_vert); @@ -2386,7 +2385,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, GPU_blend(GPU_BLEND_NONE); GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 4.0f, 4.0f))); immBegin(GPU_PRIM_POINTS, selected_free_points * 2); - for (i = 0; i < tot_points; i++) { + for (uint i = 0; i < tot_points; i++) { if (point_draw_handles(&pts[i])) { fx = rect->xmin + zoomx * (pts[i].h1_loc[0] - offsx); fy = rect->ymin + zoomy * (pts[i].h1_loc[1] - offsy); @@ -2408,7 +2407,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, if (tot_points > 0 && pts) { GPU_point_size(max_ff(2.0f, min_ff(UI_DPI_FAC / but->block->aspect * 3.0f, 3.0f))); immBegin(GPU_PRIM_POINTS, tot_points); - for (i = 0; i < tot_points; i++) { + for (uint i = 0; i < tot_points; i++) { fx = rect->xmin + zoomx * (pts[i].x - offsx); fy = rect->ymin + zoomy * (pts[i].y - offsy); immAttr4fv(col, color_sample); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index cadc2264bf4..b5f902adfb5 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -975,7 +975,7 @@ static void init_iconfile_list(struct ListBase *list) { IconFile *ifile; struct direntry *dir; - int totfile, i, index = 1; + int index = 1; const char *icondir; BLI_listbase_clear(list); @@ -985,9 +985,9 @@ static void init_iconfile_list(struct ListBase *list) return; } - totfile = BLI_filelist_dir_contents(icondir, &dir); + int totfile = BLI_filelist_dir_contents(icondir, &dir); - for (i = 0; i < totfile; i++) { + for (int i = 0; i < totfile; i++) { if ((dir[i].type & S_IFREG)) { const char *filename = dir[i].relname; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index da3ab7556ed..62321cb1e73 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -457,14 +457,14 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index) uiBut *but = arg_but; PointerRNA *ptr = &but->rnapoin; PropertyRNA *prop = but->rnaprop; - int i, index = POINTER_AS_INT(arg_index); + int index = POINTER_AS_INT(arg_index); const int shift = win->eventstate->shift; const int len = RNA_property_array_length(ptr, prop); if (!shift) { RNA_property_boolean_set_index(ptr, prop, index, true); - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { if (i != index) { RNA_property_boolean_set_index(ptr, prop, i, 0); } @@ -2584,14 +2584,14 @@ void uiItemsEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname } const EnumPropertyItem *item; - int totitem, i; + int totitem; bool free; uiLayout *split = uiLayoutSplit(layout, 0.0f, false); uiLayout *column = uiLayoutColumn(split, false); RNA_property_enum_items_gettexted(block->evil_C, ptr, prop, &item, &totitem, &free); - for (i = 0; i < totitem; i++) { + for (int i = 0; i < totitem; i++) { if (item[i].identifier[0]) { uiItemEnumR_prop(column, item[i].name, item[i].icon, ptr, prop, item[i].value); ui_but_tip_from_enum_item(block->buttons.last, &item[i]); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 5c4877534f6..6e2229ce3e3 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1636,8 +1636,6 @@ static void align_sub_panels(Panel *panel) /* returns 1 when it did something */ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag) { - int i; - /* count active, not tabbed panels */ int tot = 0; LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { @@ -1666,6 +1664,7 @@ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag) /* While we are dragging, we sort on location and update #Panel.sortorder. */ qsort(panelsort, tot, sizeof(PanelSort), find_highest_panel); + int i; for (ps = panelsort, i = 0; i < tot; i++, ps++) { ps->orig->sortorder = i; } @@ -1682,7 +1681,7 @@ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag) ps->panel->ofsy = -get_panel_size_y(ps->panel); ps->panel->ofsx += ps->panel->runtime.region_ofsx; - for (i = 0; i < tot - 1; i++, ps++) { + for (int i = 0; i < tot - 1; i++, ps++) { PanelSort *psnext = ps + 1; const bool use_box = ps->panel->type && ps->panel->type->flag & PNL_DRAW_BOX; @@ -1704,7 +1703,7 @@ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag) /* we interpolate */ bool changed = false; ps = panelsort; - for (i = 0; i < tot; i++, ps++) { + for (int i = 0; i < tot; i++, ps++) { if ((ps->panel->flag & PNL_SELECT) == 0) { if ((ps->orig->ofsx != ps->panel->ofsx) || (ps->orig->ofsy != ps->panel->ofsy)) { ps->orig->ofsx = round_fl_to_int(fac * (float)ps->panel->ofsx + @@ -1726,6 +1725,7 @@ static bool uiAlignPanelStep(ARegion *region, const float fac, const bool drag) } /* Free `panelsort` array. */ + int i; for (ps = panelsort, i = 0; i < tot; i++, ps++) { MEM_freeN(ps->panel); } diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index f472c56e280..0edc755902a 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -167,7 +167,6 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region float background_color[3]; float tone_bg; - int i; wmOrtho2_region_pixelspace(region); @@ -204,7 +203,7 @@ static void ui_tooltip_region_draw_cb(const bContext *UNUSED(C), ARegion *region bbox.xmin += 0.5f * pad_px; /* add padding to the text */ bbox.ymax -= 0.25f * pad_px; - for (i = 0; i < data->fields_len; i++) { + for (int i = 0; i < data->fields_len; i++) { const uiTooltipField *field = &data->fields[i]; const uiTooltipField *field_next = (i + 1) != data->fields_len ? &data->fields[i + 1] : NULL; diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 08d3ad0f23c..77a9d9f549a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -4255,7 +4255,7 @@ static void curvemap_buttons_layout(uiLayout *layout, uiBut *bt; const float dx = UI_UNIT_X; int icon, size; - int bg = -1, i; + int bg = -1; block = uiLayoutGetBlock(layout); @@ -4464,7 +4464,7 @@ static void curvemap_buttons_layout(uiLayout *layout, curve_but->gradient_type = bg; /* sliders for selected point */ - for (i = 0; i < cm->totpoint; i++) { + for (int i = 0; i < cm->totpoint; i++) { if (cm->curve[i].flag & CUMA_SELECT) { cmp = &cm->curve[i]; break; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index ab0f6d90caa..0cbb8f268a2 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -5002,12 +5002,7 @@ static void draw_disk_shaded(float start, bool shaded) { const float radius_ext_scale = (0.5f / radius_ext); /* 1 / (2 * radius_ext) */ - int i; - float s, c; - float y1, y2; - float fac; - uchar r_col[4]; uint pos, col; GPUVertFormat *format = immVertexFormat(); @@ -5022,24 +5017,24 @@ static void draw_disk_shaded(float start, } immBegin(GPU_PRIM_TRI_STRIP, subd * 2); - for (i = 0; i < subd; i++) { - float a; - - a = start + ((i) / (float)(subd - 1)) * angle; - s = sinf(a); - c = cosf(a); - y1 = s * radius_int; - y2 = s * radius_ext; + for (int i = 0; i < subd; i++) { + float a = start + ((i) / (float)(subd - 1)) * angle; + float s = sinf(a); + float c = cosf(a); + float y1 = s * radius_int; + float y2 = s * radius_ext; if (shaded) { - fac = (y1 + radius_ext) * radius_ext_scale; + uchar r_col[4]; + float fac = (y1 + radius_ext) * radius_ext_scale; color_blend_v4_v4v4(r_col, col1, col2, fac); immAttr4ubv(col, r_col); } immVertex2f(pos, c * radius_int, s * radius_int); if (shaded) { - fac = (y2 + radius_ext) * radius_ext_scale; + uchar r_col[4]; + float fac = (y2 + radius_ext) * radius_ext_scale; color_blend_v4_v4v4(r_col, col1, col2, fac); immAttr4ubv(col, r_col); } diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index c6b29f79137..32caf043119 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -1723,13 +1723,10 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b) const float cent_b[2] = {BLI_rctf_cent_x(rect_b), BLI_rctf_cent_y(rect_b)}; float fac_max = 0.0f; - float tfac; - int i; - - for (i = 0; i < 2; i++) { + for (int i = 0; i < 2; i++) { /* axis translation normalized to scale */ - tfac = fabsf(cent_a[i] - cent_b[i]) / min_ff(size_a[i], size_b[i]); + float tfac = fabsf(cent_a[i] - cent_b[i]) / min_ff(size_a[i], size_b[i]); fac_max = max_ff(fac_max, tfac); if (fac_max >= 1.0f) { break; diff --git a/source/blender/editors/lattice/editlattice_select.c b/source/blender/editors/lattice/editlattice_select.c index 49cf4779496..4497ca1a379 100644 --- a/source/blender/editors/lattice/editlattice_select.c +++ b/source/blender/editors/lattice/editlattice_select.c @@ -177,9 +177,6 @@ void LATTICE_OT_select_random(wmOperatorType *ot) static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool extend) { const int tot = lt->pntsu * lt->pntsv * lt->pntsw; - int i; - BPoint *bp; - BLI_bitmap *selpoints; bool flip_uvw[3] = {false}; flip_uvw[axis] = true; @@ -190,13 +187,13 @@ static void ed_lattice_select_mirrored(Lattice *lt, const int axis, const bool e } /* store "original" selection */ - selpoints = BLI_BITMAP_NEW(tot, __func__); + BLI_bitmap *selpoints = BLI_BITMAP_NEW(tot, __func__); BKE_lattice_bitmap_from_flag(lt, selpoints, SELECT, false, false); /* actual (de)selection */ - for (i = 0; i < tot; i++) { + for (int i = 0; i < tot; i++) { const int i_flip = BKE_lattice_index_flip(lt, i, flip_uvw[0], flip_uvw[1], flip_uvw[2]); - bp = <->def[i]; + BPoint *bp = <->def[i]; if (!bp->hide) { if (BLI_BITMAP_TEST(selpoints, i_flip)) { bp->f1 |= SELECT; diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index e43eea35a91..770a53d8691 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -76,8 +76,7 @@ static void setup_vertex_point(Mask *mask, */ int point_index = reference_point - spline->points; int delta = new_point == spline->points ? 1 : -1; - int i = 0; - for (i = 0; i < spline->tot_point - 1; i++) { + for (int i = 0; i < spline->tot_point - 1; i++) { MaskSplinePoint *current_point; point_index += delta; @@ -199,9 +198,7 @@ static void finSelectedSplinePoint(MaskLayer *mask_layer, } while (cur_spline) { - int i; - - for (i = 0; i < cur_spline->tot_point; i++) { + for (int i = 0; i < cur_spline->tot_point; i++) { MaskSplinePoint *cur_point = &cur_spline->points[i]; if (MASKPOINT_ISSEL_ANY(cur_point)) { @@ -694,19 +691,17 @@ static int create_primitive_from_points( bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type) { ScrArea *area = CTX_wm_area(C); - Mask *mask; - MaskLayer *mask_layer; - MaskSpline *new_spline; - float scale, location[2], frame_size[2]; - int i, width, height; int size = RNA_float_get(op->ptr, "size"); + int width, height; ED_mask_get_size(area, &width, &height); - scale = (float)size / max_ii(width, height); + float scale = (float)size / max_ii(width, height); /* Get location in mask space. */ + float frame_size[2]; frame_size[0] = width; frame_size[1] = height; + float location[2]; RNA_float_get_array(op->ptr, "location", location); location[0] /= width; location[1] /= height; @@ -717,12 +712,12 @@ static int create_primitive_from_points( location[1] -= 0.5f * scale; bool added_mask = false; - mask_layer = ED_mask_layer_ensure(C, &added_mask); - mask = CTX_data_edit_mask(C); + MaskLayer *mask_layer = ED_mask_layer_ensure(C, &added_mask); + Mask *mask = CTX_data_edit_mask(C); ED_mask_select_toggle_all(mask, SEL_DESELECT); - new_spline = BKE_mask_spline_add(mask_layer); + MaskSpline *new_spline = BKE_mask_spline_add(mask_layer); new_spline->flag = MASK_SPLINE_CYCLIC | SELECT; new_spline->points = MEM_recallocN(new_spline->points, sizeof(MaskSplinePoint) * num_points); @@ -731,7 +726,7 @@ static int create_primitive_from_points( const int spline_index = BKE_mask_layer_shape_spline_to_index(mask_layer, new_spline); - for (i = 0; i < num_points; i++) { + for (int i = 0; i < num_points; i++) { new_spline->tot_point = i + 1; MaskSplinePoint *new_point = &new_spline->points[i]; diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 51f3a94efde..c9fe03dc599 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -262,15 +262,16 @@ static bool spline_under_mouse_get(const bContext *C, const float threshold = 19.0f; ScrArea *area = CTX_wm_area(C); SpaceClip *sc = CTX_wm_space_clip(C); - int width, height; - float pixel_co[2]; float closest_dist_squared = 0.0f; MaskLayer *closest_layer = NULL; MaskSpline *closest_spline = NULL; bool undistort = false; *r_mask_layer = NULL; *r_mask_spline = NULL; + + int width, height; ED_mask_get_size(area, &width, &height); + float pixel_co[2]; pixel_co[0] = co[0] * width; pixel_co[1] = co[1] * height; if (sc != NULL) { @@ -285,16 +286,13 @@ static bool spline_under_mouse_get(const bContext *C, for (MaskSpline *spline = mask_layer->splines.first; spline != NULL; spline = spline->next) { MaskSplinePoint *points_array; float min[2], max[2], center[2]; - float dist_squared; - int i; - float max_bb_side; if ((spline->flag & SELECT) == 0) { continue; } points_array = BKE_mask_spline_point_array(spline); INIT_MINMAX2(min, max); - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point_deform = &points_array[i]; BezTriple *bezt = &point_deform->bezt; @@ -311,8 +309,8 @@ static bool spline_under_mouse_get(const bContext *C, center[0] = (min[0] + max[0]) / 2.0f * width; center[1] = (min[1] + max[1]) / 2.0f * height; - dist_squared = len_squared_v2v2(pixel_co, center); - max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height); + float dist_squared = len_squared_v2v2(pixel_co, center); + float max_bb_side = min_ff((max[0] - min[0]) * width, (max[1] - min[1]) * height); if (dist_squared <= max_bb_side * max_bb_side * 0.5f && (closest_spline == NULL || dist_squared < closest_dist_squared)) { closest_layer = mask_layer; @@ -350,9 +348,7 @@ static bool spline_under_mouse_get(const bContext *C, static bool slide_point_check_initial_feather(MaskSpline *spline) { - int i; - - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; if (point->bezt.weight != 0.0f) { @@ -569,9 +565,7 @@ static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event) static void slide_point_delta_all_feather(SlidePointData *data, float delta) { - int i; - - for (i = 0; i < data->spline->tot_point; i++) { + for (int i = 0; i < data->spline->tot_point; i++) { MaskSplinePoint *point = &data->spline->points[i]; MaskSplinePoint *orig_point = &data->orig_spline->points[i]; @@ -584,16 +578,13 @@ static void slide_point_delta_all_feather(SlidePointData *data, float delta) static void slide_point_restore_spline(SlidePointData *data) { - int i; - - for (i = 0; i < data->spline->tot_point; i++) { + for (int i = 0; i < data->spline->tot_point; i++) { MaskSplinePoint *point = &data->spline->points[i]; MaskSplinePoint *orig_point = &data->orig_spline->points[i]; - int j; point->bezt = orig_point->bezt; - for (j = 0; j < point->tot_uw; j++) { + for (int j = 0; j < point->tot_uw; j++) { point->uw[j] = orig_point->uw[j]; } } @@ -818,13 +809,11 @@ static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else if (data->action == SLIDE_ACTION_SPLINE) { - int i; - if (data->orig_spline == NULL) { data->orig_spline = BKE_mask_spline_copy(data->spline); } - for (i = 0; i < data->spline->tot_point; i++) { + for (int i = 0; i < data->spline->tot_point; i++) { MaskSplinePoint *point = &data->spline->points[i]; add_v2_v2(point->bezt.vec[0], delta); add_v2_v2(point->bezt.vec[1], delta); @@ -1330,13 +1319,13 @@ void MASK_OT_cyclic_toggle(wmOperatorType *ot) static void delete_feather_points(MaskSplinePoint *point) { - int i, count = 0; + int count = 0; if (!point->tot_uw) { return; } - for (i = 0; i < point->tot_uw; i++) { + for (int i = 0; i < point->tot_uw; i++) { if ((point->uw[i].flag & SELECT) == 0) { count++; } @@ -1353,7 +1342,7 @@ static void delete_feather_points(MaskSplinePoint *point) new_uw = MEM_callocN(count * sizeof(MaskSplinePointUW), "new mask uw points"); - for (i = 0; i < point->tot_uw; i++) { + for (int i = 0; i < point->tot_uw; i++) { if ((point->uw[i].flag & SELECT) == 0) { new_uw[j++] = point->uw[i]; } @@ -1383,11 +1372,11 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) while (spline) { const int tot_point_orig = spline->tot_point; - int i, count = 0; + int count = 0; MaskSpline *next_spline = spline->next; /* count unselected points */ - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; if (!MASKPOINT_ISSEL_ANY(point)) { @@ -1409,11 +1398,10 @@ static int delete_exec(bContext *C, wmOperator *UNUSED(op)) } else { MaskSplinePoint *new_points; - int j; new_points = MEM_callocN(count * sizeof(MaskSplinePoint), "deleteMaskPoints"); - for (i = 0, j = 0; i < tot_point_orig; i++) { + for (int i = 0, j = 0; i < tot_point_orig; i++) { MaskSplinePoint *point = &spline->points[i]; if (!MASKPOINT_ISSEL_ANY(point)) { diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index 82d8a1dc85f..cdc6ece1e84 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -55,9 +55,7 @@ /* 'check' select */ bool ED_mask_spline_select_check(const MaskSpline *spline) { - int i; - - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; if (MASKPOINT_ISSEL_ANY(point)) { @@ -97,8 +95,6 @@ bool ED_mask_select_check(const Mask *mask) /* 'sel' select */ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select) { - int i; - if (do_select) { spline->flag |= SELECT; } @@ -106,7 +102,7 @@ void ED_mask_spline_select_set(MaskSpline *spline, const bool do_select) spline->flag &= ~SELECT; } - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; BKE_mask_point_select_set(point, do_select); @@ -151,8 +147,7 @@ void ED_mask_select_toggle_all(Mask *mask, int action) continue; } LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { - int i; - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; BKE_mask_point_select_set(point, !MASKPOINT_ISSEL_ANY(point)); } @@ -654,7 +649,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) ARegion *region = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); - int i; float zoomx, zoomy, offset[2], ellipse[2]; int width, height; @@ -692,7 +686,7 @@ static int circle_select_exec(bContext *C, wmOperator *op) LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { MaskSplinePoint *points_array = BKE_mask_spline_point_array(spline); - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { MaskSplinePoint *point = &spline->points[i]; MaskSplinePoint *point_deform = &points_array[i]; @@ -871,10 +865,9 @@ static int mask_select_more_less(bContext *C, bool more) LISTBASE_FOREACH (MaskSpline *, spline, &mask_layer->splines) { const bool cyclic = (spline->flag & MASK_SPLINE_CYCLIC) != 0; bool start_sel, end_sel, prev_sel, cur_sel; - int i; /* reselect point if any handle is selected to make the result more predictable */ - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { BKE_mask_point_select_set(spline->points + i, MASKPOINT_ISSEL_ANY(spline->points + i)); } @@ -892,7 +885,7 @@ static int mask_select_more_less(bContext *C, bool more) end_sel = false; } - for (i = 0; i < spline->tot_point; i++) { + for (int i = 0; i < spline->tot_point; i++) { if (i == 0 && !cyclic) { continue; } @@ -908,7 +901,7 @@ static int mask_select_more_less(bContext *C, bool more) } } - for (i = spline->tot_point - 1; i >= 0; i--) { + for (int i = spline->tot_point - 1; i >= 0; i--) { if (i == spline->tot_point - 1 && !cyclic) { continue; } diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index b303c4c7e4e..b349def4637 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -58,7 +58,6 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) MPoly *polys, *mp_orig; const int *index_array = NULL; int totpoly; - int i; BLI_assert((flag & ~(SELECT | ME_HIDE)) == 0); @@ -87,7 +86,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) if (me_orig != NULL && me_eval != NULL && me_orig->totpoly == me->totpoly) { /* Update the COW copy of the mesh. */ - for (i = 0; i < me->totpoly; i++) { + for (int i = 0; i < me->totpoly; i++) { me_orig->mpoly[i].flag = me->mpoly[i].flag; } @@ -101,7 +100,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) totpoly = me_eval->totpoly; /* loop over final derived polys */ - for (i = 0; i < totpoly; i++) { + for (int i = 0; i < totpoly; i++) { if (index_array[i] != ORIGINDEX_NONE) { /* Copy flags onto the final derived poly from the original mesh poly */ mp_orig = me->mpoly + index_array[i]; diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index 515fbab86bc..90ef42c6f48 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -672,12 +672,10 @@ static int linehit_compare(const void *vlh1, const void *vlh2) */ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) { - KnifeLineHit *linehits, *lhi, *lhj; - int i, j, n; bool is_double = false; - n = kcd->totlinehit; - linehits = kcd->linehits; + int n = kcd->totlinehit; + KnifeLineHit *linehits = kcd->linehits; if (n == 0) { return; } @@ -688,11 +686,11 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) * by a vertex hit that is very near. Mark such edge hits using * l == -1 and then do another pass to actually remove. * Also remove all but one of a series of vertex hits for the same vertex. */ - for (i = 0; i < n; i++) { - lhi = &linehits[i]; + for (int i = 0; i < n; i++) { + KnifeLineHit *lhi = &linehits[i]; if (lhi->v) { - for (j = i - 1; j >= 0; j--) { - lhj = &linehits[j]; + for (int j = i - 1; j >= 0; j--) { + KnifeLineHit *lhj = &linehits[j]; if (!lhj->kfe || fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) { break; @@ -703,8 +701,8 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) is_double = true; } } - for (j = i + 1; j < n; j++) { - lhj = &linehits[j]; + for (int j = i + 1; j < n; j++) { + KnifeLineHit *lhj = &linehits[j]; if (fabsf(lhi->l - lhj->l) > KNIFE_FLT_EPSBIG || fabsf(lhi->m - lhj->m) > KNIFE_FLT_EPSBIG) { break; @@ -719,11 +717,11 @@ static void prepare_linehits_for_cut(KnifeTool_OpData *kcd) if (is_double) { /* delete-in-place loop: copying from pos j to pos i+1 */ - i = 0; - j = 1; + int i = 0; + int j = 1; while (j < n) { - lhi = &linehits[i]; - lhj = &linehits[j]; + KnifeLineHit *lhi = &linehits[i]; + KnifeLineHit *lhj = &linehits[j]; if (lhj->l == -1.0f) { j++; /* skip copying this one */ } diff --git a/source/blender/editors/mesh/mesh_data.c b/source/blender/editors/mesh/mesh_data.c index 22ea222cf01..1537be0aef6 100644 --- a/source/blender/editors/mesh/mesh_data.c +++ b/source/blender/editors/mesh/mesh_data.c @@ -171,11 +171,10 @@ static void mesh_uv_reset_array(float **fuv, const int len) } else if (len > 2) { float fac = 0.0f, dfac = 1.0f / (float)len; - int i; dfac *= (float)M_PI * 2.0f; - for (i = 0; i < len; i++) { + for (int i = 0; i < len; i++) { fuv[i][0] = 0.5f * sinf(fac) + 0.5f; fuv[i][1] = 0.5f * cosf(fac) + 0.5f; @@ -201,9 +200,8 @@ static void mesh_uv_reset_bmface(BMFace *f, const int cd_loop_uv_offset) static void mesh_uv_reset_mface(MPoly *mp, MLoopUV *mloopuv) { float **fuv = BLI_array_alloca(fuv, mp->totloop); - int i; - for (i = 0; i < mp->totloop; i++) { + for (int i = 0; i < mp->totloop; i++) { fuv[i] = mloopuv[mp->loopstart + i].uv; } @@ -234,13 +232,10 @@ void ED_mesh_uv_loop_reset_ex(struct Mesh *me, const int layernum) } else { /* Collect Mesh UVs */ - MLoopUV *mloopuv; - int i; - BLI_assert(CustomData_has_layer(&me->ldata, CD_MLOOPUV)); - mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); + MLoopUV *mloopuv = CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, layernum); - for (i = 0; i < me->totpoly; i++) { + for (int i = 0; i < me->totpoly; i++) { mesh_uv_reset_mface(&me->mpoly[i], mloopuv); } } @@ -1061,15 +1056,12 @@ void ED_mesh_update(Mesh *mesh, bContext *C, bool calc_edges, bool calc_edges_lo static void mesh_add_verts(Mesh *mesh, int len) { - CustomData vdata; - MVert *mvert; - int i, totvert; - if (len == 0) { return; } - totvert = mesh->totvert + len; + int totvert = mesh->totvert + len; + CustomData vdata; CustomData_copy(&mesh->vdata, &vdata, CD_MASK_MESH.vmask, CD_DEFAULT, totvert); CustomData_copy_data(&mesh->vdata, &vdata, 0, 0, mesh->totvert); @@ -1084,8 +1076,8 @@ static void mesh_add_verts(Mesh *mesh, int len) /* scan the input list and insert the new vertices */ /* set default flags */ - mvert = &mesh->mvert[mesh->totvert]; - for (i = 0; i < len; i++, mvert++) { + MVert *mvert = &mesh->mvert[mesh->totvert]; + for (int i = 0; i < len; i++, mvert++) { mvert->flag |= SELECT; } diff --git a/source/blender/editors/object/object_bake_api.c b/source/blender/editors/object/object_bake_api.c index 4d55aff1d1f..19097d95743 100644 --- a/source/blender/editors/object/object_bake_api.c +++ b/source/blender/editors/object/object_bake_api.c @@ -301,8 +301,7 @@ static bool write_internal_bake_pixels(Image *image, /* force OpenGL reload */ static void refresh_images(BakeImages *bake_images) { - int i; - for (i = 0; i < bake_images->size; i++) { + for (int i = 0; i < bake_images->size; i++) { Image *ima = bake_images->data[i].image; LISTBASE_FOREACH (ImageTile *, tile, &ima->tiles) { if (tile->ok == IMA_OK_LOADED) { @@ -413,10 +412,7 @@ static bool is_noncolor_pass(eScenePassType pass_type) /* if all is good tag image and return true */ static bool bake_object_check(ViewLayer *view_layer, Object *ob, ReportList *reports) { - Image *image; Base *base = BKE_view_layer_base_find(view_layer, ob); - void *lock; - int i; if (base == NULL) { BKE_reportf(reports, RPT_ERROR, "Object \"%s\" is not in view layer", ob->id.name + 2); @@ -440,10 +436,11 @@ static bool bake_object_check(ViewLayer *view_layer, Object *ob, ReportList *rep return false; } - for (i = 0; i < ob->totcol; i++) { + for (int i = 0; i < ob->totcol; i++) { bNodeTree *ntree = NULL; bNode *node = NULL; const int mat_nr = i + 1; + Image *image; ED_object_get_active_image(ob, mat_nr, &image, NULL, &node, &ntree); if (image) { @@ -462,6 +459,7 @@ static bool bake_object_check(ViewLayer *view_layer, Object *ob, ReportList *rep } } + void *lock; ibuf = BKE_image_acquire_ibuf(image, NULL, &lock); if (ibuf) { @@ -637,13 +635,12 @@ static void bake_images_clear(Main *bmain, const bool is_tangent) static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images) { const int tot_mat = ob->totcol; - int i, j; int tot_images = 0; /* error handling and tag (in case multiple materials share the same image) */ BKE_main_id_tag_idcode(bmain, ID_IM, LIB_TAG_DOIT, false); - for (i = 0; i < tot_mat; i++) { + for (int i = 0; i < tot_mat; i++) { Image *image; ED_object_get_active_image(ob, i + 1, &image, NULL, NULL, NULL); @@ -652,7 +649,7 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images) bake_images->lookup[i] = -1; } else if (image->id.tag & LIB_TAG_DOIT) { - for (j = 0; j < i; j++) { + for (int j = 0; j < i; j++) { if (bake_images->data[j].image == image) { bake_images->lookup[i] = j; break; @@ -675,15 +672,12 @@ static void build_image_lookup(Main *bmain, Object *ob, BakeImages *bake_images) */ static size_t init_internal_images(BakeImages *bake_images, ReportList *reports) { - int i; size_t tot_size = 0; - for (i = 0; i < bake_images->size; i++) { - ImBuf *ibuf; - void *lock; - + for (int i = 0; i < bake_images->size; i++) { BakeImage *bk_image = &bake_images->data[i]; - ibuf = BKE_image_acquire_ibuf(bk_image->image, NULL, &lock); + void *lock; + ImBuf *ibuf = BKE_image_acquire_ibuf(bk_image->image, NULL, &lock); if (ibuf) { bk_image->width = ibuf->x; @@ -1228,8 +1222,7 @@ static int bake(Render *re, cleanup: if (highpoly) { - int i; - for (i = 0; i < tot_highpoly; i++) { + for (int i = 0; i < tot_highpoly; i++) { if (highpoly[i].me != NULL) { BKE_id_free(NULL, &highpoly[i].me->id); } diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index da00a88ab65..4884df1edb6 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -153,21 +153,18 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Object *ob_src = CTX_data_active_object(C); if (ob_src) { - Mesh *me_eval; - int num_data, i; - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH; cddata_masks.lmask |= CD_MASK_MLOOPUV; - me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks); - num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks); + int num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPUV); RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { + for (int i = 0; i < num_data; i++) { tmp_item.value = i; tmp_item.identifier = tmp_item.name = CustomData_get_layer_name( &me_eval->ldata, CD_MLOOPUV, i); @@ -179,21 +176,18 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Object *ob_src = CTX_data_active_object(C); if (ob_src) { - Mesh *me_eval; - int num_data, i; - Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); CustomData_MeshMasks cddata_masks = CD_MASK_BAREMESH; cddata_masks.lmask |= CD_MASK_MLOOPCOL; - me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks); - num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); + Mesh *me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_src_eval, &cddata_masks); + int num_data = CustomData_number_of_layers(&me_eval->ldata, CD_MLOOPCOL); RNA_enum_item_add_separator(&item, &totitem); - for (i = 0; i < num_data; i++) { + for (int i = 0; i < num_data; i++) { tmp_item.value = i; tmp_item.identifier = tmp_item.name = CustomData_get_layer_name( &me_eval->ldata, CD_MLOOPCOL, i); diff --git a/source/blender/editors/object/object_facemap_ops.c b/source/blender/editors/object/object_facemap_ops.c index 32668598df1..4e2b1eb21b6 100644 --- a/source/blender/editors/object/object_facemap_ops.c +++ b/source/blender/editors/object/object_facemap_ops.c @@ -136,10 +136,8 @@ static void object_fmap_remap_object_mode(Object *ob, const int *remap) Mesh *me = ob->data; if (CustomData_has_layer(&me->pdata, CD_FACEMAP)) { int *map = CustomData_get_layer(&me->pdata, CD_FACEMAP); - int i; - if (map) { - for (i = 0; i < me->totpoly; i++) { + for (int i = 0; i < me->totpoly; i++) { if (map[i] != -1) { map[i] = remap[map[i]]; } diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 52b572fb0dd..e2d043c3206 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -834,11 +834,10 @@ static int apply_objects_internal(bContext *C, } else if (ob->type == OB_FONT) { Curve *cu = ob->data; - int i; scale = mat3_to_scale(rsmat); - for (i = 0; i < cu->totbox; i++) { + for (int i = 0; i < cu->totbox; i++) { TextBox *tb = &cu->tb[i]; tb->x *= scale; tb->y *= scale; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index de9cca38a6e..b8811408339 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -148,11 +148,9 @@ void ED_vgroup_data_clamp_range(ID *id, const int total) int dvert_tot; if (ED_vgroup_parray_alloc(id, &dvert_arr, &dvert_tot, false)) { - int i; - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { MDeformVert *dv = dvert_arr[i]; - int j; - for (j = 0; j < dv->totweight; j++) { + for (int j = 0; j < dv->totweight; j++) { if (dv->dw[j].def_nr >= total) { BKE_defvert_remove_group(dv, &dv->dw[j]); j--; @@ -213,18 +211,17 @@ bool ED_vgroup_parray_alloc(ID *id, if (me->dvert) { MVert *mvert = me->mvert; MDeformVert *dvert = me->dvert; - int i; *dvert_tot = me->totvert; *dvert_arr = MEM_mallocN(sizeof(void *) * me->totvert, "vgroup parray from me"); if (use_vert_sel) { - for (i = 0; i < me->totvert; i++) { + for (int i = 0; i < me->totvert; i++) { (*dvert_arr)[i] = (mvert[i].flag & SELECT) ? &dvert[i] : NULL; } } else { - for (i = 0; i < me->totvert; i++) { + for (int i = 0; i < me->totvert; i++) { (*dvert_arr)[i] = me->dvert + i; } } @@ -234,8 +231,6 @@ bool ED_vgroup_parray_alloc(ID *id, return false; } case ID_LT: { - int i = 0; - Lattice *lt = (Lattice *)id; lt = (lt->editlatt) ? lt->editlatt->latt : lt; @@ -245,12 +240,12 @@ bool ED_vgroup_parray_alloc(ID *id, *dvert_arr = MEM_mallocN(sizeof(void *) * (*dvert_tot), "vgroup parray from me"); if (use_vert_sel) { - for (i = 0; i < *dvert_tot; i++) { + for (int i = 0; i < *dvert_tot; i++) { (*dvert_arr)[i] = (def->f1 & SELECT) ? <->dvert[i] : NULL; } } else { - for (i = 0; i < *dvert_tot; i++) { + for (int i = 0; i < *dvert_tot; i++) { (*dvert_arr)[i] = lt->dvert + i; } } @@ -328,7 +323,6 @@ void ED_vgroup_parray_mirror_assign(Object *ob, MDeformVert **dvert_array, const BMEditMesh *em = BKE_editmesh_from_object(ob); MDeformVert **dvert_array_all = NULL; int dvert_tot_all; - int i; /* get an array of all verts, not only selected */ if (ED_vgroup_parray_alloc(ob->data, &dvert_array_all, &dvert_tot_all, false) == false) { @@ -340,7 +334,7 @@ void ED_vgroup_parray_mirror_assign(Object *ob, MDeformVert **dvert_array, const BM_mesh_elem_table_ensure(em->bm, BM_VERT); } - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { if (dvert_array[i] == NULL) { /* its unselected, check if its mirror is */ int i_sel = ED_mesh_mirror_get_vert(ob, i); @@ -362,17 +356,14 @@ void ED_vgroup_parray_remove_zero(MDeformVert **dvert_array, const bool keep_single) { MDeformVert *dv; - int i; - - for (i = 0; i < dvert_tot; i++) { - int j; + for (int i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; } - j = dv->totweight; + int j = dv->totweight; while (j--) { MDeformWeight *dw; @@ -482,9 +473,7 @@ void ED_vgroup_parray_to_weight_array(const MDeformVert **dvert_array, float *dvert_weights, const int def_nr) { - int i; - - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { const MDeformVert *dv = dvert_array[i]; dvert_weights[i] = dv ? BKE_defvert_find_weight(dv, def_nr) : 0.0f; } @@ -1163,7 +1152,7 @@ static bool vgroup_normalize(Object *ob) { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; - int i, dvert_tot = 0; + int dvert_tot = 0; const int def_nr = ob->actdef - 1; const bool use_vert_sel = vertex_group_use_vert_sel(ob); @@ -1177,7 +1166,7 @@ static bool vgroup_normalize(Object *ob) if (dvert_array) { float weight_max = 0.0f; - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1191,7 +1180,7 @@ static bool vgroup_normalize(Object *ob) } if (weight_max > 0.0f) { - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { @@ -1599,7 +1588,7 @@ static void vgroup_levels_subset(Object *ob, { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; - int i, dvert_tot = 0; + int dvert_tot = 0; const bool use_vert_sel = vertex_group_use_vert_sel(ob); const bool use_mirror = (ob->type == OB_MESH) ? @@ -1610,15 +1599,13 @@ static void vgroup_levels_subset(Object *ob, if (dvert_array) { - for (i = 0; i < dvert_tot; i++) { - int j; - + for (int i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; } - j = vgroup_tot; + int j = vgroup_tot; while (j--) { if (vgroup_validmap[j]) { dw = BKE_defvert_find_index(dv, j); @@ -1857,7 +1844,7 @@ static void vgroup_invert_subset(Object *ob, { MDeformWeight *dw; MDeformVert *dv, **dvert_array = NULL; - int i, dvert_tot = 0; + int dvert_tot = 0; const bool use_vert_sel = vertex_group_use_vert_sel(ob); const bool use_mirror = (ob->type == OB_MESH) ? (((Mesh *)ob->data)->editflag & ME_EDIT_MIRROR_X) != 0 : @@ -1866,15 +1853,13 @@ static void vgroup_invert_subset(Object *ob, ED_vgroup_parray_alloc(ob->data, &dvert_array, &dvert_tot, use_vert_sel); if (dvert_array) { - for (i = 0; i < dvert_tot; i++) { - int j; - + for (int i = 0; i < dvert_tot; i++) { /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; } - j = vgroup_tot; + int j = vgroup_tot; while (j--) { if (vgroup_validmap[j]) { @@ -2271,21 +2256,20 @@ static void vgroup_quantize_subset(Object *ob, if (dvert_array) { const float steps_fl = steps; MDeformVert *dv; - int i; if (use_mirror && use_vert_sel) { ED_vgroup_parray_mirror_assign(ob, dvert_array, dvert_tot); } - for (i = 0; i < dvert_tot; i++) { + for (int i = 0; i < dvert_tot; i++) { MDeformWeight *dw; - int j; /* in case its not selected */ if (!(dv = dvert_array[i])) { continue; } + int j; for (j = 0, dw = dv->dw; j < dv->totweight; j++, dw++) { if ((dw->def_nr < vgroup_tot) && vgroup_validmap[dw->def_nr]) { dw->weight = floorf((dw->weight * steps_fl) + 0.5f) / steps_fl; @@ -2628,18 +2612,14 @@ static void vgroup_assign_verts(Object *ob, const float weight) } } else { - MVert *mv; - MDeformVert *dv; - int i; - if (!me->dvert) { BKE_object_defgroup_data_create(&me->id); } - mv = me->mvert; - dv = me->dvert; + MVert *mv = me->mvert; + MDeformVert *dv = me->dvert; - for (i = 0; i < me->totvert; i++, mv++, dv++) { + for (int i = 0; i < me->totvert; i++, mv++, dv++) { if (mv->flag & SELECT) { MDeformWeight *dw; dw = BKE_defvert_ensure_index(dv, def_nr); diff --git a/source/blender/editors/object/object_warp.c b/source/blender/editors/object/object_warp.c index 00f9330c8a7..b36a8543d67 100644 --- a/source/blender/editors/object/object_warp.c +++ b/source/blender/editors/object/object_warp.c @@ -71,11 +71,8 @@ static void object_warp_transverts_minmax_x(TransVertStore *tvs, const float x_ofs = (mat_view[3][0] - center_view[0]); float min = FLT_MAX, max = -FLT_MAX; - TransVert *tv; - int i; - - tv = tvs->transverts; - for (i = 0; i < tvs->transverts_tot; i++, tv++) { + TransVert *tv = tvs->transverts; + for (int i = 0; i < tvs->transverts_tot; i++, tv++) { float val; /* convert objectspace->viewspace */ @@ -97,7 +94,6 @@ static void object_warp_transverts(TransVertStore *tvs, const float max) { TransVert *tv; - int i; const float angle = -angle_; /* cache vars for tiny speedup */ #if 1 @@ -123,7 +119,7 @@ static void object_warp_transverts(TransVertStore *tvs, } tv = tvs->transverts; - for (i = 0; i < tvs->transverts_tot; i++, tv++) { + for (int i = 0; i < tvs->transverts_tot; i++, tv++) { float co[3], co_add[2]; float val, phi; diff --git a/source/blender/editors/physics/particle_edit_undo.c b/source/blender/editors/physics/particle_edit_undo.c index 205c04f54a9..8db6c4c853e 100644 --- a/source/blender/editors/physics/particle_edit_undo.c +++ b/source/blender/editors/physics/particle_edit_undo.c @@ -57,7 +57,6 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit) { PTCacheEditPoint *point; - int i; size_t mem_used_prev = MEM_get_memory_in_use(); @@ -68,7 +67,7 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit) pa = undo->particles = MEM_dupallocN(edit->psys->particles); - for (i = 0; i < edit->totpoint; i++, pa++) { + for (int i = 0; i < edit->totpoint; i++, pa++) { pa->hair = MEM_dupallocN(pa->hair); } @@ -81,7 +80,7 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit) pm = undo->mem_cache.first; for (; pm; pm = pm->next) { - for (i = 0; i < BPHYS_TOT_DATA; i++) { + for (int i = 0; i < BPHYS_TOT_DATA; i++) { pm->data[i] = MEM_dupallocN(pm->data[i]); } } @@ -90,7 +89,7 @@ static void undoptcache_from_editcache(PTCacheUndo *undo, PTCacheEdit *edit) point = undo->points = MEM_dupallocN(edit->points); undo->totpoint = edit->totpoint; - for (i = 0; i < edit->totpoint; i++, point++) { + for (int i = 0; i < edit->totpoint; i++, point++) { point->keys = MEM_dupallocN(point->keys); /* no need to update edit key->co & key->time pointers here */ } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 41e30adf724..0eda5877bb4 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -721,7 +721,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, MVert *mvert; Mesh *mesh, *target_mesh; int numverts; - int i, k; + int k; float from_ob_imat[4][4], to_ob_imat[4][4]; float from_imat[4][4], to_imat[4][4]; @@ -763,7 +763,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, mvert = mesh->mvert; /* convert to global coordinates */ - for (i = 0; i < numverts; i++) { + for (int i = 0; i < numverts; i++) { mul_m4_v3(to_mat, mvert[i].co); } @@ -780,6 +780,7 @@ static bool remap_hair_emitter(Depsgraph *depsgraph, return false; } + int i; for (i = 0, tpa = target_psys->particles, pa = psys->particles; i < target_psys->totpart; i++, tpa++, pa++) { float from_co[3]; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 8ec58b4c75e..2da9dd01ceb 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -3303,7 +3303,6 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const char temp_str[MAX_METADATA_STR]; int line_width; int ofs_y = 0; - short i; int len; const float height = BLF_height_max(fontid); const float margin = height / 8; @@ -3317,7 +3316,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const const float ymax = (rect->ymax - margin) - descender; if (is_top) { - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { /* first line */ if (i == 0) { bool do_newline = false; @@ -3382,7 +3381,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, const rctf *rect, int fontid, const IMB_metadata_foreach(ibuf, metadata_custom_draw_fields, &ctx); int ofs_x = 0; ofs_y = ctx.current_y; - for (i = 5; i < 10; i++) { + for (int i = 5; i < 10; i++) { len = BLI_snprintf_rlen(temp_str, MAX_METADATA_STR, "%s: ", meta_data_list[i]); if (metadata_is_valid(ibuf, temp_str, i, len)) { BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f); diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index f4d7869e40a..3d8c718c8a9 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -911,7 +911,6 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc) GPU_matrix_translate_2f(vc->region->winrct.xmin, vc->region->winrct.ymin); if (brush->paint_curve && brush->paint_curve->points) { - int i; PaintCurve *pc = brush->paint_curve; PaintCurvePoint *cp = pc->points; @@ -928,7 +927,7 @@ static void paint_draw_curve_cursor(Brush *brush, ViewContext *vc) UI_GetThemeColorType4fv(TH_PAINT_CURVE_HANDLE, SPACE_VIEW3D, handle_col); UI_GetThemeColorType4fv(TH_PAINT_CURVE_PIVOT, SPACE_VIEW3D, pivot_col); - for (i = 0; i < pc->tot_points - 1; i++, cp++) { + for (int i = 0; i < pc->tot_points - 1; i++, cp++) { int j; PaintCurvePoint *cp_next = cp + 1; float data[(PAINT_CURVE_NUM_SEGMENTS + 1) * 2]; diff --git a/source/blender/editors/sculpt_paint/paint_curve.c b/source/blender/editors/sculpt_paint/paint_curve.c index 458f021ddb4..c63af64a87a 100644 --- a/source/blender/editors/sculpt_paint/paint_curve.c +++ b/source/blender/editors/sculpt_paint/paint_curve.c @@ -189,23 +189,20 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) Paint *p = BKE_paint_get_active_from_context(C); Brush *br = p->brush; Main *bmain = CTX_data_main(C); - PaintCurve *pc; - PaintCurvePoint *pcp; wmWindow *window = CTX_wm_window(C); ARegion *region = CTX_wm_region(C); const float vec[3] = {loc[0], loc[1], 0.0}; - int add_index; - int i; - pc = br->paint_curve; + PaintCurve *pc = br->paint_curve; if (!pc) { br->paint_curve = pc = BKE_paint_curve_add(bmain, "PaintCurve"); } ED_paintcurve_undo_push_begin(op->type->name); - pcp = MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint), "PaintCurvePoint"); - add_index = pc->add_index; + PaintCurvePoint *pcp = MEM_mallocN((pc->tot_points + 1) * sizeof(PaintCurvePoint), + "PaintCurvePoint"); + int add_index = pc->add_index; if (pc->points) { if (add_index > 0) { @@ -229,7 +226,7 @@ static void paintcurve_point_add(bContext *C, wmOperator *op, const int loc[2]) copy_v3_v3(pcp[add_index].bez.vec[2], vec); /* last step, clear selection from all bezier handles expect the next */ - for (i = 0; i < pc->tot_points; i++) { + for (int i = 0; i < pc->tot_points; i++) { pcp[i].bez.f1 = pcp[i].bez.f2 = pcp[i].bez.f3 = 0; } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 3886b78286b..d44654f4fd5 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -2676,7 +2676,6 @@ static void project_bucket_clip_face(const bool is_ortho, /* calc center */ float cent[2] = {0.0f, 0.0f}; /*float up[2] = {0.0f, 1.0f};*/ - int i; bool doubles; (*tot) = 0; @@ -2757,7 +2756,7 @@ static void project_bucket_clip_face(const bool is_ortho, /* now we have all points we need, collect their angles and sort them clockwise */ - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { cent[0] += isectVCosSS[i][0]; cent[1] += isectVCosSS[i][1]; } @@ -2767,7 +2766,7 @@ static void project_bucket_clip_face(const bool is_ortho, /* Collect angles for every point around the center point */ #if 0 /* uses a few more cycles then the above loop */ - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { isectVCosSS[i][2] = angle_2d_clockwise(up, cent, isectVCosSS[i]); } #endif @@ -2776,7 +2775,7 @@ static void project_bucket_clip_face(const bool is_ortho, v1_clipSS[0] = cent[0]; v1_clipSS[1] = cent[1] + 1.0f; - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { v2_clipSS[0] = isectVCosSS[i][0] - cent[0]; v2_clipSS[1] = isectVCosSS[i][1] - cent[1]; isectVCosSS[i][2] = atan2f(v1_clipSS[0] * v2_clipSS[1] - v1_clipSS[1] * v2_clipSS[0], @@ -2794,11 +2793,10 @@ static void project_bucket_clip_face(const bool is_ortho, while (doubles == true) { doubles = false; - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { if (fabsf(isectVCosSS[(i + 1) % *tot][0] - isectVCosSS[i][0]) < PROJ_PIXEL_TOLERANCE && fabsf(isectVCosSS[(i + 1) % *tot][1] - isectVCosSS[i][1]) < PROJ_PIXEL_TOLERANCE) { - int j; - for (j = i; j < (*tot) - 1; j++) { + for (int j = i; j < (*tot) - 1; j++) { isectVCosSS[j][0] = isectVCosSS[j + 1][0]; isectVCosSS[j][1] = isectVCosSS[j + 1][1]; } @@ -2817,13 +2815,13 @@ static void project_bucket_clip_face(const bool is_ortho, } if (is_ortho) { - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { barycentric_weights_v2(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w); interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } } else { - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { barycentric_weights_v2_persp(v1coSS, v2coSS, v3coSS, isectVCosSS[i], w); interp_v2_v2v2v2(bucket_bounds_uv[i], uv1co, uv2co, uv3co, w); } @@ -2864,7 +2862,7 @@ static void project_bucket_clip_face(const bool is_ortho, uv3co[1]); printf("["); - for (i = 0; i < (*tot); i++) { + for (int i = 0; i < (*tot); i++) { printf("(%f, %f),", bucket_bounds_uv[i][0], bucket_bounds_uv[i][1]); } printf("]),\\\n"); @@ -5874,8 +5872,6 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m ProjStrokeHandle *ps_handle; Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; - int i; - bool is_multi_view; char symmetry_flag_views[ARRAY_SIZE(ps_handle->ps_views)] = {0}; ps_handle = MEM_callocN(sizeof(ProjStrokeHandle), "ProjStrokeHandle"); @@ -5893,9 +5889,9 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m ps_handle->symmetry_flags = settings->imapaint.paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; ps_handle->ps_views_tot = 1 + (pow_i(2, count_bits_i(ps_handle->symmetry_flags)) - 1); - is_multi_view = (ps_handle->ps_views_tot != 1); + bool is_multi_view = (ps_handle->ps_views_tot != 1); - for (i = 0; i < ps_handle->ps_views_tot; i++) { + for (int i = 0; i < ps_handle->ps_views_tot; i++) { ProjPaintState *ps = MEM_callocN(sizeof(ProjPaintState), "ProjectionPaintState"); ps_handle->ps_views[i] = ps; } @@ -5918,7 +5914,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m BLI_assert(index == ps_handle->ps_views_tot); } - for (i = 0; i < ps_handle->ps_views_tot; i++) { + for (int i = 0; i < ps_handle->ps_views_tot; i++) { ProjPaintState *ps = ps_handle->ps_views[i]; project_state_init(C, ob, ps, mode); @@ -5936,7 +5932,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m /* allocate and initialize spatial data structures */ - for (i = 0; i < ps_handle->ps_views_tot; i++) { + for (int i = 0; i < ps_handle->ps_views_tot; i++) { ProjPaintState *ps = ps_handle->ps_views[i]; ps->source = (ps->tool == PAINT_TOOL_FILL) ? PROJ_SRC_VIEW_FILL : PROJ_SRC_VIEW; @@ -5961,7 +5957,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m return ps_handle; fail: - for (i = 0; i < ps_handle->ps_views_tot; i++) { + for (int i = 0; i < ps_handle->ps_views_tot; i++) { ProjPaintState *ps = ps_handle->ps_views[i]; MEM_freeN(ps); } diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index e709224f370..db7120ed301 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -711,15 +711,12 @@ static float paint_space_stroke_spacing(bContext *C, static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing) { - int i; const int n = 100 / spacing; const float h = spacing / 50.0f; const float x0 = x - 1; - float sum; - - sum = 0; - for (i = 0; i < n; i++) { + float sum = 0; + for (int i = 0; i < n; i++) { float xx; xx = fabsf(x0 + i * h); @@ -734,21 +731,16 @@ static float paint_stroke_overlapped_curve(Brush *br, float x, float spacing) static float paint_stroke_integrate_overlap(Brush *br, float factor) { - int i; - int m; - float g; - float max; - float spacing = br->spacing * factor; if (!(br->flag & BRUSH_SPACE_ATTEN && (br->spacing < 100))) { return 1.0; } - m = 10; - g = 1.0f / m; - max = 0; - for (i = 0; i < m; i++) { + int m = 10; + float g = 1.0f / m; + float max = 0; + for (int i = 0; i < m; i++) { float overlap = fabs(paint_stroke_overlapped_curve(br, i * g, spacing)); if (overlap > max) { @@ -1151,13 +1143,11 @@ static void paint_stroke_add_sample( static void paint_stroke_sample_average(const PaintStroke *stroke, PaintSample *average) { - int i; - memset(average, 0, sizeof(*average)); BLI_assert(stroke->num_samples > 0); - for (i = 0; i < stroke->num_samples; i++) { + for (int i = 0; i < stroke->num_samples; i++) { add_v2_v2(average->mouse, stroke->samples[i].mouse); average->pressure += stroke->samples[i].pressure; } diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c index d05b1673c9a..b831687ca67 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_ops.c @@ -68,9 +68,6 @@ static void tag_object_after_update(Object *object) static bool vertex_color_set(Object *ob, uint paintcol) { Mesh *me; - const MPoly *mp; - int i, j; - if (((me = BKE_mesh_from_object(ob)) == NULL) || (ED_mesh_color_ensure(me, NULL) == false)) { return false; } @@ -78,15 +75,15 @@ static bool vertex_color_set(Object *ob, uint paintcol) const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const bool use_vert_sel = (me->editflag & ME_EDIT_PAINT_VERT_SEL) != 0; - mp = me->mpoly; - for (i = 0; i < me->totpoly; i++, mp++) { + const MPoly *mp = me->mpoly; + for (int i = 0; i < me->totpoly; i++, mp++) { MLoopCol *lcol = me->mloopcol + mp->loopstart; if (use_face_sel && !(mp->flag & ME_FACE_SEL)) { continue; } - j = 0; + int j = 0; do { uint vidx = me->mloop[mp->loopstart + j].v; if (!(use_vert_sel && !(me->mvert[vidx].flag & SELECT))) { @@ -211,7 +208,6 @@ static void vertex_color_smooth_looptag(Mesh *me, const bool *mlooptag) const bool use_face_sel = (me->editflag & ME_EDIT_PAINT_FACE_SEL) != 0; const MPoly *mp; int(*scol)[4]; - int i, j; bool has_shared = false; /* if no mloopcol: do not do */ @@ -223,11 +219,12 @@ static void vertex_color_smooth_looptag(Mesh *me, const bool *mlooptag) scol = MEM_callocN(sizeof(int) * me->totvert * 5, "scol"); + int i; for (i = 0, mp = me->mpoly; i < me->totpoly; i++, mp++) { if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) { const MLoop *ml = me->mloop + mp->loopstart; MLoopCol *lcol = me->mloopcol + mp->loopstart; - for (j = 0; j < mp->totloop; j++, ml++, lcol++) { + for (int j = 0; j < mp->totloop; j++, ml++, lcol++) { scol[ml->v][0] += lcol->r; scol[ml->v][1] += lcol->g; scol[ml->v][2] += lcol->b; @@ -250,7 +247,7 @@ static void vertex_color_smooth_looptag(Mesh *me, const bool *mlooptag) if ((use_face_sel == false) || (mp->flag & ME_FACE_SEL)) { const MLoop *ml = me->mloop + mp->loopstart; MLoopCol *lcol = me->mloopcol + mp->loopstart; - for (j = 0; j < mp->totloop; j++, ml++, lcol++) { + for (int j = 0; j < mp->totloop; j++, ml++, lcol++) { if (mlooptag[mp->loopstart + j]) { lcol->r = scol[ml->v][0]; lcol->g = scol[ml->v][1]; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c index 637ce8193c1..7120f6a8748 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_color_utils.c @@ -435,9 +435,7 @@ BLI_INLINE uint mcol_softlight(uint col_src, uint col_dst, int fac) cp_dst = (uchar *)&col_dst; cp_mix = (uchar *)&col_mix; - int i = 0; - - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { if (cp_src[i] < 127) { temp = ((2 * ((cp_dst[i] / 2) + 64)) * cp_src[i]) / 255; } diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index fd800ca2c18..287e1eb03d1 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -327,17 +327,14 @@ static bool sculpt_undo_restore_color(bContext *C, SculptUndoNode *unode) ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); SculptSession *ss = ob->sculpt; - MVert *mvert; - MPropCol *vcol; - int *index, i; if (unode->maxvert) { /* regular mesh restore */ - index = unode->index; - mvert = ss->mvert; - vcol = ss->vcol; + int *index = unode->index; + MVert *mvert = ss->mvert; + MPropCol *vcol = ss->vcol; - for (i = 0; i < unode->totvert; i++) { + for (int i = 0; i < unode->totvert; i++) { copy_v4_v4(vcol[index[i]].color, unode->col[i]); mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } @@ -927,16 +924,14 @@ SculptUndoNode *SCULPT_undo_get_first_node() static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, SculptUndoNode *unode) { PBVHNode *node = unode->node; - BLI_bitmap **grid_hidden; - int i, *grid_indices, totgrid; - - grid_hidden = BKE_pbvh_grid_hidden(pbvh); + BLI_bitmap **grid_hidden = BKE_pbvh_grid_hidden(pbvh); + int *grid_indices, totgrid; BKE_pbvh_node_get_grids(pbvh, node, &grid_indices, &totgrid, NULL, NULL, NULL); unode->grid_hidden = MEM_callocN(sizeof(*unode->grid_hidden) * totgrid, "unode->grid_hidden"); - for (i = 0; i < totgrid; i++) { + for (int i = 0; i < totgrid; i++) { if (grid_hidden[grid_indices[i]]) { unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]); } @@ -1087,11 +1082,10 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) MVert *mvert; const int *vert_indices; int allvert; - int i; BKE_pbvh_node_num_verts(pbvh, node, NULL, &allvert); BKE_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); - for (i = 0; i < allvert; i++) { + for (int i = 0; i < allvert; i++) { BLI_BITMAP_SET(unode->vert_hidden, i, mvert[vert_indices[i]].flag & ME_HIDE); } } diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index d7cf2e4d544..fd713e7094a 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -658,8 +658,8 @@ static void buttons_id_remap(ScrArea *UNUSED(area), SpaceLink *slink, ID *old_id if (sbuts->path) { ButsContextPath *path = sbuts->path; - int i; + int i; for (i = 0; i < path->len; i++) { if (path->ptr[i].owner_id == old_id) { break; diff --git a/source/blender/editors/space_clip/clip_buttons.c b/source/blender/editors/space_clip/clip_buttons.c index 2e7ee3498b5..f3bac697044 100644 --- a/source/blender/editors/space_clip/clip_buttons.c +++ b/source/blender/editors/space_clip/clip_buttons.c @@ -384,7 +384,6 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) } else if (event == B_MARKER_OFFSET) { float offset[2], delta[2]; - int i; offset[0] = cb->track_offset[0] / width; offset[1] = cb->track_offset[1] / height; @@ -392,7 +391,7 @@ static void marker_block_handler(bContext *C, void *arg_cb, int event) sub_v2_v2v2(delta, offset, cb->track->offset); copy_v2_v2(cb->track->offset, offset); - for (i = 0; i < cb->track->markersnr; i++) { + for (int i = 0; i < cb->track->markersnr; i++) { sub_v2_v2(cb->track->markers[i].pos, delta); } diff --git a/source/blender/editors/space_clip/clip_draw.c b/source/blender/editors/space_clip/clip_draw.c index e12e4eb2231..4759075555b 100644 --- a/source/blender/editors/space_clip/clip_draw.c +++ b/source/blender/editors/space_clip/clip_draw.c @@ -871,16 +871,11 @@ static void draw_marker_areas(SpaceClip *sc, static float get_shortest_pattern_side(MovieTrackingMarker *marker) { - int i, next; float len_sq = FLT_MAX; - for (i = 0; i < 4; i++) { - float cur_len; - - next = (i + 1) % 4; - - cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); - + for (int i = 0; i < 4; i++) { + int next = (i + 1) % 4; + float cur_len = len_squared_v2v2(marker->pattern_corners[i], marker->pattern_corners[next]); len_sq = min_ff(cur_len, len_sq); } @@ -983,7 +978,6 @@ static void draw_marker_slide_zones(SpaceClip *sc, } if ((sc->flag & SC_SHOW_MARKER_PATTERN) && ((track->pat_flag & SELECT) == sel || outline)) { - int i; float pat_min[2], pat_max[2]; /* float dx = 12.0f / width, dy = 12.0f / height;*/ /* XXX UNUSED */ float tilt_ctrl[2]; @@ -993,7 +987,7 @@ static void draw_marker_slide_zones(SpaceClip *sc, } /* pattern's corners sliding squares */ - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { draw_marker_slide_square(marker->pattern_corners[i][0], marker->pattern_corners[i][1], patdx / 1.5f, @@ -1381,8 +1375,7 @@ static void draw_plane_marker_ex(SpaceClip *sc, immUniformColor3fv(selected_color); } - int i; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { draw_marker_slide_square(plane_marker->corners[i][0], plane_marker->corners[i][1], 3.0f * px[0], diff --git a/source/blender/editors/space_clip/clip_editor.c b/source/blender/editors/space_clip/clip_editor.c index 83096b4eded..b2c80faec0b 100644 --- a/source/blender/editors/space_clip/clip_editor.c +++ b/source/blender/editors/space_clip/clip_editor.c @@ -940,11 +940,10 @@ static void start_prefetch_threads(MovieClip *clip, short *do_update, float *progress) { - PrefetchQueue queue; - TaskPool *task_pool; - int i, tot_thread = BLI_task_scheduler_num_threads(); + int tot_thread = BLI_task_scheduler_num_threads(); /* initialize queue */ + PrefetchQueue queue; BLI_spin_init(&queue.spin); queue.current_frame = current_frame; @@ -959,8 +958,8 @@ static void start_prefetch_threads(MovieClip *clip, queue.do_update = do_update; queue.progress = progress; - task_pool = BLI_task_pool_create(&queue, TASK_PRIORITY_LOW); - for (i = 0; i < tot_thread; i++) { + TaskPool *task_pool = BLI_task_pool_create(&queue, TASK_PRIORITY_LOW); + for (int i = 0; i < tot_thread; i++) { BLI_task_pool_push(task_pool, prefetch_task_func, clip, false, NULL); } BLI_task_pool_work_and_wait(task_pool); diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 8532d8420f9..013731a50d6 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -1412,17 +1412,16 @@ static void do_sequence_proxy(void *pjv, ProxyJob *pj = pjv; MovieClip *clip = pj->clip; Scene *scene = pj->scene; - TaskPool *task_pool; int sfra = SFRA, efra = EFRA; ProxyThread *handles; - int i, tot_thread = BLI_task_scheduler_num_threads(); + int tot_thread = BLI_task_scheduler_num_threads(); int width, height; - ProxyQueue queue; if (build_undistort_count) { BKE_movieclip_get_size(clip, NULL, &width, &height); } + ProxyQueue queue; BLI_spin_init(&queue.spin); queue.cfra = sfra; @@ -1432,9 +1431,9 @@ static void do_sequence_proxy(void *pjv, queue.do_update = do_update; queue.progress = progress; - task_pool = BLI_task_pool_create(&queue, TASK_PRIORITY_LOW); + TaskPool *task_pool = BLI_task_pool_create(&queue, TASK_PRIORITY_LOW); handles = MEM_callocN(sizeof(ProxyThread) * tot_thread, "proxy threaded handles"); - for (i = 0; i < tot_thread; i++) { + for (int i = 0; i < tot_thread; i++) { ProxyThread *handle = &handles[i]; handle->clip = clip; @@ -1456,7 +1455,7 @@ static void do_sequence_proxy(void *pjv, BLI_task_pool_free(task_pool); if (build_undistort_count) { - for (i = 0; i < tot_thread; i++) { + for (int i = 0; i < tot_thread; i++) { ProxyThread *handle = &handles[i]; BKE_tracking_distortion_free(handle->distortion); } diff --git a/source/blender/editors/space_clip/clip_utils.c b/source/blender/editors/space_clip/clip_utils.c index bcbf843f51c..cbf43bb7ff0 100644 --- a/source/blender/editors/space_clip/clip_utils.c +++ b/source/blender/editors/space_clip/clip_utils.c @@ -297,11 +297,8 @@ void clip_graph_tracking_iterate(SpaceClip *sc, MovieClip *clip = ED_space_clip_get_clip(sc); MovieTracking *tracking = &clip->tracking; ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); - MovieTrackingTrack *track; - - for (track = tracksbase->first; track; track = track->next) { - int i; + LISTBASE_FOREACH (MovieTrackingTrack *, track, tracksbase) { if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) { continue; } @@ -310,7 +307,7 @@ void clip_graph_tracking_iterate(SpaceClip *sc, continue; } - for (i = 0; i < track->markersnr; i++) { + for (int i = 0; i < track->markersnr; i++) { MovieTrackingMarker *marker = &track->markers[i]; if (marker->flag & MARKER_DISABLED) { diff --git a/source/blender/editors/space_clip/tracking_ops.c b/source/blender/editors/space_clip/tracking_ops.c index 177a0bc2bcf..05fa7a6b587 100644 --- a/source/blender/editors/space_clip/tracking_ops.c +++ b/source/blender/editors/space_clip/tracking_ops.c @@ -511,7 +511,6 @@ static int mouse_to_tilt_distance_squared(const MovieTrackingMarker *marker, static bool slide_check_corners(float (*corners)[2]) { - int i, next, prev; float cross = 0.0f; const float p[2] = {0.0f, 0.0f}; @@ -519,16 +518,16 @@ static bool slide_check_corners(float (*corners)[2]) return false; } - for (i = 0; i < 4; i++) { - float v1[2], v2[2], cur_cross; + for (int i = 0; i < 4; i++) { + float v1[2], v2[2]; - next = (i + 1) % 4; - prev = (4 + i - 1) % 4; + int next = (i + 1) % 4; + int prev = (4 + i - 1) % 4; sub_v2_v2v2(v1, corners[i], corners[prev]); sub_v2_v2v2(v2, corners[next], corners[i]); - cur_cross = cross_v2v2(v1, v2); + float cur_cross = cross_v2v2(v1, v2); if (fabsf(cur_cross) > FLT_EPSILON) { if (cross == 0.0f) { diff --git a/source/blender/editors/space_clip/tracking_select.c b/source/blender/editors/space_clip/tracking_select.c index 80d0dd773b2..08b95bd46c5 100644 --- a/source/blender/editors/space_clip/tracking_select.c +++ b/source/blender/editors/space_clip/tracking_select.c @@ -546,9 +546,8 @@ static int box_select_exec(bContext *C, wmOperator *op) for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) { if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) { MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr); - int i; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { if (BLI_rctf_isect_pt_v(&rectf, plane_marker->corners[i])) { if (select) { plane_track->flag |= SELECT; @@ -651,9 +650,8 @@ static int do_lasso_select_marker(bContext *C, for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) { if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) { MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr); - int i; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { float screen_co[2]; /* marker in screen coords */ @@ -812,9 +810,8 @@ static int circle_select_exec(bContext *C, wmOperator *op) for (plane_track = plane_tracks_base->first; plane_track; plane_track = plane_track->next) { if ((plane_track->flag & PLANE_TRACK_HIDDEN) == 0) { MovieTrackingPlaneMarker *plane_marker = BKE_tracking_plane_marker_get(plane_track, framenr); - int i; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { if (point_inside_ellipse(plane_marker->corners[i], offset, ellipse)) { if (select) { plane_track->flag |= SELECT; diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 0ade50814e0..5f0e6c8361e 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -943,11 +943,9 @@ void filelist_init_icons(void) void filelist_free_icons(void) { - int i; - BLI_assert(G.background == false); - for (i = 0; i < SPECIAL_IMG_MAX; i++) { + for (int i = 0; i < SPECIAL_IMG_MAX; i++) { IMB_freeImBuf(gSpecialFileImages[i]); gSpecialFileImages[i] = NULL; } diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 88c8c6b2939..306d6cba50e 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -861,15 +861,13 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche { int match = 0; - int i; - FileDirEntry *file; int n = filelist_files_ensure(sfile->files); /* select any file that matches the pattern, this includes exact match * if the user selects a single file by entering the filename */ - for (i = 0; i < n; i++) { - file = filelist_file(sfile->files, i); + for (int i = 0; i < n; i++) { + FileDirEntry *file = filelist_file(sfile->files, i); /* Do not check whether file is a file or dir here! Causes T44243 * (we do accept dirs at this stage). */ if (fnmatch(pattern, file->relpath, 0) == 0) { @@ -941,9 +939,8 @@ int autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v)) if (str[0] && sfile->files) { AutoComplete *autocpl = UI_autocomplete_begin(str, FILE_MAX); int nentries = filelist_files_ensure(sfile->files); - int i; - for (i = 0; i < nentries; i++) { + for (int i = 0; i < nentries; i++) { FileDirEntry *file = filelist_file(sfile->files, i); UI_autocomplete_update_name(autocpl, file->relpath); } diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 0b3c98a392e..329b5fe67fd 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -645,11 +645,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) wchar_t wline[FILE_MAXDIR]; __int64 tmp; char tmps[4], *name; - int i; tmp = GetLogicalDrives(); - for (i = 0; i < 26; i++) { + for (int i = 0; i < 26; i++) { if ((tmp >> i) & 1) { tmps[0] = 'A' + i; tmps[1] = ':'; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 70d29b52630..a99fcf60b23 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -500,11 +500,7 @@ static void draw_fcurve_samples(SpaceGraph *sipo, ARegion *region, FCurve *fcu) static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2d, uint pos) { SpaceGraph *sipo = (SpaceGraph *)ac->sl; - float samplefreq; - float stime, etime; - float unitFac, offset; short mapping_flag = ANIM_get_normalization_flags(ac); - int i, n; /* when opening a blend file on a different sized screen or while dragging the toolbar this can * happen best just bail out in this case. */ @@ -517,7 +513,9 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2 fcurve_for_draw.driver = NULL; /* compute unit correction factor */ - unitFac = ANIM_unit_mapping_get_factor(ac->scene, id, &fcurve_for_draw, mapping_flag, &offset); + float offset; + float unitFac = ANIM_unit_mapping_get_factor( + ac->scene, id, &fcurve_for_draw, mapping_flag, &offset); /* Note about sampling frequency: * Ideally, this is chosen such that we have 1-2 pixels = 1 segment @@ -535,7 +533,7 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2 /* TODO: perhaps we should have 1.0 frames * as upper limit so that curves don't get too distorted? */ float pixels_per_sample = 1.5f; - samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d); + float samplefreq = pixels_per_sample / UI_view2d_scale_get_x(v2d); if (sipo->flag & SIPO_BEAUTYDRAW_OFF) { /* Low Precision = coarse lower-bound clamping @@ -559,20 +557,21 @@ static void draw_fcurve_curve(bAnimContext *ac, ID *id, FCurve *fcu_, View2D *v2 } /* the start/end times are simply the horizontal extents of the 'cur' rect */ - stime = v2d->cur.xmin; - etime = v2d->cur.xmax + samplefreq; /* + samplefreq here so that last item gets included... */ + float stime = v2d->cur.xmin; + float etime = v2d->cur.xmax + + samplefreq; /* + samplefreq here so that last item gets included... */ /* at each sampling interval, add a new vertex * - apply the unit correction factor to the calculated values so that * the displayed values appear correctly in the viewport */ - n = roundf((etime - stime) / samplefreq); + int n = roundf((etime - stime) / samplefreq); if (n > 0) { immBegin(GPU_PRIM_LINE_STRIP, (n + 1)); - for (i = 0; i <= n; i++) { + for (int i = 0; i <= n; i++) { float ctime = stime + i * samplefreq; immVertex2f(pos, ctime, (evaluate_fcurve(&fcurve_for_draw, ctime) + offset) * unitFac); } diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index 68f4bd0ff38..f8382a17c59 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -100,12 +100,10 @@ static bool add_reroute_intersect_check(bNodeLink *link, float result[2]) { float coord_array[NODE_LINK_RESOL + 1][2]; - int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) { - - for (i = 0; i < tot - 1; i++) { - for (b = 0; b < NODE_LINK_RESOL; b++) { + for (int i = 0; i < tot - 1; i++) { + for (int b = 0; b < NODE_LINK_RESOL; b++) { if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { result[0] = (mcoords[i][0] + mcoords[i + 1][0]) / 2.0f; result[1] = (mcoords[i][1] + mcoords[i + 1][1]) / 2.0f; diff --git a/source/blender/editors/space_node/node_relationships.c b/source/blender/editors/space_node/node_relationships.c index a09c70b794a..57fd84a4521 100644 --- a/source/blender/editors/space_node/node_relationships.c +++ b/source/blender/editors/space_node/node_relationships.c @@ -322,7 +322,7 @@ static void snode_autoconnect(Main *bmain, ListBase *nodelist = MEM_callocN(sizeof(ListBase), "items_list"); bNodeListItem *nli; bNode *node; - int i, numlinks = 0; + int numlinks = 0; for (node = ntree->nodes.first; node; node = node->next) { if (node->flag & NODE_SELECT) { @@ -376,7 +376,7 @@ static void snode_autoconnect(Main *bmain, /* no selected inputs, connect by finding suitable match */ int num_inputs = BLI_listbase_count(&node_to->inputs); - for (i = 0; i < num_inputs; i++) { + for (int i = 0; i < num_inputs; i++) { /* find the best guess input socket */ sock_to = best_socket_input(ntree, node_to, i, replace); @@ -1007,12 +1007,10 @@ void NODE_OT_link_make(wmOperatorType *ot) static bool cut_links_intersect(bNodeLink *link, const float mcoords[][2], int tot) { float coord_array[NODE_LINK_RESOL + 1][2]; - int i, b; if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) { - - for (i = 0; i < tot - 1; i++) { - for (b = 0; b < NODE_LINK_RESOL; b++) { + for (int i = 0; i < tot - 1; i++) { + for (int b = 0; b < NODE_LINK_RESOL; b++) { if (isect_seg_seg_v2(mcoords[i], mcoords[i + 1], coord_array[b], coord_array[b + 1]) > 0) { return 1; } @@ -1536,11 +1534,10 @@ void ED_node_link_intersect_test(ScrArea *area, int test) if (node_link_bezier_points(NULL, NULL, link, coord_array, NODE_LINK_RESOL)) { float dist = FLT_MAX; - int i; /* loop over link coords to find shortest dist to * upper left node edge of a intersected line segment */ - for (i = 0; i < NODE_LINK_RESOL; i++) { + for (int i = 0; i < NODE_LINK_RESOL; i++) { /* check if the node rect intersetcts the line from this point to next one */ if (BLI_rctf_isect_segment(&select->totr, coord_array[i], coord_array[i + 1])) { /* store the shortest distance to the upper left edge diff --git a/source/blender/editors/space_node/node_templates.c b/source/blender/editors/space_node/node_templates.c index c5be96470ec..a7e2ad8fc1c 100644 --- a/source/blender/editors/space_node/node_templates.c +++ b/source/blender/editors/space_node/node_templates.c @@ -500,20 +500,20 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) int totitems; char name[UI_MAX_NAME_STR]; const char *cur_node_name = NULL; - int i, num = 0; + int num = 0; int icon = ICON_NONE; arg->node_type = ntype; ui_node_link_items(arg, SOCK_OUT, &items, &totitems); - for (i = 0; i < totitems; i++) { + for (int i = 0; i < totitems; i++) { if (ui_compatible_sockets(items[i].socket_type, sock->type)) { num++; } } - for (i = 0; i < totitems; i++) { + for (int i = 0; i < totitems; i++) { if (!ui_compatible_sockets(items[i].socket_type, sock->type)) { continue; } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index a35feb62c9d..962c4e4c59d 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -823,7 +823,6 @@ int sequencer_image_seq_get_minmax_frame(wmOperator *op, void sequencer_image_seq_reserve_frames( wmOperator *op, StripElem *se, int len, int minframe, int numdigits) { - int i; char *filename = NULL; RNA_BEGIN (op->ptr, itemptr, "files") { filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0); @@ -837,7 +836,7 @@ void sequencer_image_seq_reserve_frames( /* Strip the frame from filename and substitute with `#`. */ BLI_path_frame_strip(filename, ext); - for (i = 0; i < len; i++, se++) { + for (int i = 0; i < len; i++, se++) { BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped)); BLI_path_frame(filename_stripped, minframe + i, numdigits); BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 70735a8ec82..662be2491a0 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -242,7 +242,6 @@ static void draw_seq_waveform(View2D *v2d, int x2_offset = min_ff(v2d->cur.xmax + 1.0f, x2); if (seq->sound && ((sseq->flag & SEQ_ALL_WAVEFORMS) || (seq->flag & SEQ_AUDIO_DRAW_WAVEFORM))) { - int i, j, p; int length = floor((x2_offset - x1_offset) / stepsize) + 1; float ymid = (y1 + y2) / 2.0f; float yscale = (y2 - y1) / 2.0f; @@ -303,15 +302,15 @@ static void draw_seq_waveform(View2D *v2d, immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); immBegin(GPU_PRIM_TRI_STRIP, length * 2); - for (i = 0; i < length; i++) { + for (int i = 0; i < length; i++) { float sampleoffset = startsample + ((x1_offset - x1) / stepsize + i) * samplestep; - p = sampleoffset; + int p = sampleoffset; value1 = waveform->data[p * 3]; value2 = waveform->data[p * 3 + 1]; if (samplestep > 1.0f) { - for (j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) { + for (int j = p + 1; (j < waveform->length) && (j < p + samplestep); j++) { if (value1 > waveform->data[j * 3]) { value1 = waveform->data[j * 3]; } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index f175c2a7419..e446a1a5ed7 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -1482,7 +1482,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); float mouseloc[2]; - int num_seq, i; + int num_seq; View2D *v2d = UI_view2d_fromcontext(C); /* Recursively count the trimmed elements. */ @@ -1506,7 +1506,7 @@ static int sequencer_slip_invoke(bContext *C, wmOperator *op, const wmEvent *eve slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true); - for (i = 0; i < num_seq; i++) { + for (int i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); } @@ -1611,21 +1611,19 @@ static void sequencer_slip_apply_limits(SlipData *data, int *offset) static int sequencer_slip_exec(bContext *C, wmOperator *op) { - SlipData *data; Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); - int num_seq, i; int offset = RNA_int_get(op->ptr, "offset"); bool success = false; /* Recursively count the trimmed elements. */ - num_seq = slip_count_sequences_recursive(ed->seqbasep, true); + int num_seq = slip_count_sequences_recursive(ed->seqbasep, true); if (num_seq == 0) { return OPERATOR_CANCELLED; } - data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); + SlipData *data = op->customdata = MEM_mallocN(sizeof(SlipData), "trimdata"); data->ts = MEM_mallocN(num_seq * sizeof(TransSeq), "trimdata_transform"); data->seq_array = MEM_mallocN(num_seq * sizeof(Sequence *), "trimdata_sequences"); data->trim = MEM_mallocN(num_seq * sizeof(bool), "trimdata_trim"); @@ -1633,7 +1631,7 @@ static int sequencer_slip_exec(bContext *C, wmOperator *op) slip_add_sequences_recursive(ed->seqbasep, data->seq_array, data->trim, 0, true); - for (i = 0; i < num_seq; i++) { + for (int i = 0; i < num_seq; i++) { transseq_backup(data->ts + i, data->seq_array[i]); } @@ -1749,14 +1747,13 @@ static int sequencer_slip_modal(bContext *C, wmOperator *op, const wmEvent *even case EVT_ESCKEY: case RIGHTMOUSE: { - int i; Editing *ed = BKE_sequencer_editing_get(scene, false); - for (i = 0; i < data->num_seq; i++) { + for (int i = 0; i < data->num_seq; i++) { transseq_restore(data->ts + i, data->seq_array[i]); } - for (i = 0; i < data->num_seq; i++) { + for (int i = 0; i < data->num_seq; i++) { Sequence *seq = data->seq_array[i]; BKE_sequence_reload_new_file(bmain, scene, seq, false); BKE_sequence_calc(scene, seq); diff --git a/source/blender/editors/space_sequencer/sequencer_scopes.c b/source/blender/editors/space_sequencer/sequencer_scopes.c index 58a6f274310..1639870fee2 100644 --- a/source/blender/editors/space_sequencer/sequencer_scopes.c +++ b/source/blender/editors/space_sequencer/sequencer_scopes.c @@ -123,11 +123,9 @@ static void wform_put_border(uchar *tgt, int w, int h) static void wform_put_gridrow(uchar *tgt, float perc, int w, int h) { - int i; - tgt += (int)(perc / 100.0f * h) * w * 4; - for (i = 0; i < w * 2; i++) { + for (int i = 0; i < w * 2; i++) { tgt[0] = 255; tgt += 4; @@ -415,11 +413,10 @@ static void draw_histogram_marker(ImBuf *ibuf, int x) { uchar *p = (uchar *)ibuf->rect; int barh = ibuf->y * 0.1; - int i; p += 4 * (x + ibuf->x * (ibuf->y - barh + 1)); - for (i = 0; i < barh - 1; i++) { + for (int i = 0; i < barh - 1; i++) { p[0] = p[1] = p[2] = 255; p += ibuf->x * 4; } @@ -429,11 +426,10 @@ static void draw_histogram_bar(ImBuf *ibuf, int x, float val, int col) { uchar *p = (uchar *)ibuf->rect; int barh = ibuf->y * val * 0.9f; - int i; p += 4 * (x + ibuf->x); - for (i = 0; i < barh; i++) { + for (int i = 0; i < barh; i++) { p[col] = 255; p += ibuf->x * 4; } diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c index 955b4dba5e8..96a1776d763 100644 --- a/source/blender/editors/space_sequencer/sequencer_select.c +++ b/source/blender/editors/space_sequencer/sequencer_select.c @@ -1388,9 +1388,8 @@ static bool select_grouped_effect(Editing *ed, Sequence *actseq, const int chann Sequence *seq; bool changed = false; bool effects[SEQ_TYPE_MAX + 1]; - int i; - for (i = 0; i <= SEQ_TYPE_MAX; i++) { + for (int i = 0; i <= SEQ_TYPE_MAX; i++) { effects[i] = false; } diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 688dce3c54e..2ae8d4cde7a 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -2914,9 +2914,9 @@ typedef struct SetSelection { static int flatten_width(SpaceText *st, const char *str) { - int i, total = 0; + int total = 0; - for (i = 0; str[i]; i += BLI_str_utf8_size_safe(str + i)) { + for (int i = 0; str[i]; i += BLI_str_utf8_size_safe(str + i)) { if (str[i] == '\t') { total += st->tabnumber - total % st->tabnumber; } diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index da44815b31a..f3300f21628 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -905,7 +905,7 @@ void ED_view3d_grid_steps(const Scene *scene, float r_grid_steps[STEPS_LEN]) { const void *usys; - int i, len; + int len; BKE_unit_system_get(scene->unit.system, B_UNIT_LENGTH, &usys, &len); float grid_scale = v3d->grid; BLI_assert(STEPS_LEN >= len); @@ -918,6 +918,7 @@ void ED_view3d_grid_steps(const Scene *scene, grid_scale /= scene->unit.scale_length; + int i; for (i = 0; i < len; i++) { r_grid_steps[i] = (float)BKE_unit_scalar_get(usys, len - 1 - i) * grid_scale; } @@ -932,7 +933,7 @@ void ED_view3d_grid_steps(const Scene *scene, grid_scale /= powf(v3d->gridsubdiv, 3); } int subdiv = 1; - for (i = 0;; i++) { + for (int i = 0;; i++) { r_grid_steps[i] = grid_scale * subdiv; if (i == STEPS_LEN - 1) { diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index ab08c9a804a..8b9f0fdb972 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -333,10 +333,9 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) else if (ob_act && (ob_act->mode & OB_MODE_EDIT) && (ob_act->type == OB_FONT)) { Curve *cu = ob_act_eval->data; EditFont *ef = cu->editfont; - int i; zero_v3(lastofs); - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { add_v2_v2(lastofs, ef->textcurs[i]); } mul_v2_fl(lastofs, 1.0f / 4.0f); @@ -4877,11 +4876,10 @@ static void calc_local_clipping(float clip_local[6][4], { BoundBox clipbb_local; float imat[4][4]; - int i; invert_m4_m4(imat, mat); - for (i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { mul_v3_m4v3(clipbb_local.vec[i], imat, clipbb->vec[i]); } diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 7562bf6f75c..4bc64a337f5 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -1658,8 +1658,7 @@ static Base *object_mouse_select_menu(bContext *C, static bool selectbuffer_has_bones(const uint *buffer, const uint hits) { - uint i; - for (i = 0; i < hits; i++) { + for (uint i = 0; i < hits; i++) { if (buffer[(4 * i) + 3] & 0xFFFF0000) { return true; } @@ -2127,11 +2126,10 @@ static bool ed_object_select_pick(bContext *C, if (basact->object->type == OB_CAMERA) { MovieClip *clip = BKE_object_movieclip_get(scene, basact->object, false); if (clip != NULL && oldbasact == basact) { - int i, hitresult; bool changed = false; - for (i = 0; i < hits; i++) { - hitresult = buffer[3 + (i * 4)]; + for (int i = 0; i < hits; i++) { + int hitresult = buffer[3 + (i * 4)]; /* if there's bundles in buffer select bundles first, * so non-camera elements should be ignored in buffer */ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 54a3ebb8c0c..84eac3bbf8f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -913,12 +913,11 @@ static void drawObjectConstraint(TransInfo *t) * Without drawing the first light, users have little clue what they are doing. */ short options = DRAWLIGHT; - int i; float tmp_axismtx[3][3]; FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; - for (i = 0; i < tc->data_len; i++, td++) { + for (int i = 0; i < tc->data_len; i++, td++) { float co[3]; float(*axismtx)[3]; diff --git a/source/blender/editors/transform/transform_convert_mask.c b/source/blender/editors/transform/transform_convert_mask.c index 6f34c49bdac..340f14c6800 100644 --- a/source/blender/editors/transform/transform_convert_mask.c +++ b/source/blender/editors/transform/transform_convert_mask.c @@ -138,12 +138,11 @@ static void MaskPointToTransData(Scene *scene, invert_m3_m3(parent_inverse_matrix, parent_matrix); if (is_prop_edit || is_sel_point) { - int i; tdm->point = point; copy_m3_m3(tdm->vec, bezt->vec); - for (i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) { copy_m3_m3(tdm->parent_matrix, parent_matrix); copy_m3_m3(tdm->parent_inverse_matrix, parent_inverse_matrix); -- cgit v1.2.3