Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2020-09-09 19:41:07 +0300
committerJacques Lucke <jacques@blender.org>2020-09-09 19:41:07 +0300
commit63916f5941b443dfc8566682bb75374e5abd553f (patch)
treefb0704701f1d4d9acbddf4a6fbc62c819d8d4c36 /source/blender/editors/sculpt_paint
parent0cff2c944f9c2cd3ac873fe826c4399fc2f32159 (diff)
Cleanup: reduce variable scope
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_cursor.c3
-rw-r--r--source/blender/editors/sculpt_paint/paint_curve.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_image_proj.c30
-rw-r--r--source/blender/editors/sculpt_paint/paint_stroke.c24
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_ops.c15
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex_color_utils.c4
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_undo.c22
7 files changed, 41 insertions, 70 deletions
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);
}
}