diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-03-24 10:38:07 +0400 |
commit | ab4a2aaf4a4b2b4e416aa1f113b30362cbe0dec3 (patch) | |
tree | 81af4c18519181490074508dbe9a8d515eab634f /source/blender/editors/sculpt_paint | |
parent | 5a90ea77bc1333efe4e1e54984a080550ed3f707 (diff) |
style cleanup: follow style guide for formatting of if/for/while loops, and else if's
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 36 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_hide.c | 42 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 347 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 24 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 54 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_undo.c | 74 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 30 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 413 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 430 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 129 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_uv.c | 16 |
11 files changed, 807 insertions, 788 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index ea1e3eb47af..be50b842914 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -341,7 +341,7 @@ static int sculpt_get_brush_geometry(bContext* C, ViewContext *vc, window[0] = x + vc->ar->winrct.xmin; window[1] = y + vc->ar->winrct.ymin; - if(vc->obact->sculpt && vc->obact->sculpt->pbvh && + if (vc->obact->sculpt && vc->obact->sculpt->pbvh && sculpt_stroke_get_location(C, location, window)) { *pixel_radius = project_brush_radius(vc, @@ -375,7 +375,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, rctf quad; /* check for overlay mode */ - if(!(brush->flag & BRUSH_TEXTURE_OVERLAY) || + if (!(brush->flag & BRUSH_TEXTURE_OVERLAY) || !(ELEM(brush->mtex.brush_map_mode, MTEX_MAP_MODE_FIXED, MTEX_MAP_MODE_TILED))) return; @@ -392,7 +392,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, GL_VIEWPORT_BIT| GL_TEXTURE_BIT); - if(load_tex(sd, brush, vc)) { + if (load_tex(sd, brush, vc)) { glEnable(GL_BLEND); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); @@ -403,7 +403,7 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, glPushMatrix(); glLoadIdentity(); - if(brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { + if (brush->mtex.brush_map_mode == MTEX_MAP_MODE_FIXED) { /* brush rotation */ glTranslatef(0.5, 0.5, 0); glRotatef((double)RAD2DEGF((brush->flag & BRUSH_RAKE) ? @@ -412,13 +412,13 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, glTranslatef(-0.5f, -0.5f, 0); /* scale based on tablet pressure */ - if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { + if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) { glTranslatef(0.5f, 0.5f, 0); glScalef(1.0f/sd->pressure_value, 1.0f/sd->pressure_value, 1); glTranslatef(-0.5f, -0.5f, 0); } - if(sd->draw_anchored) { + if (sd->draw_anchored) { const float *aim = sd->anchored_initial_mouse; const rcti *win = &vc->ar->winrct; quad.xmin = aim[0]-sd->anchored_size - win->xmin; @@ -473,12 +473,12 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, float unprojected_radius, projected_radius; /* update the brush's cached 3D radius */ - if(!brush_use_locked_size(vc->scene, brush)) { + if (!brush_use_locked_size(vc->scene, brush)) { /* get 2D brush radius */ - if(sd->draw_anchored) + if (sd->draw_anchored) projected_radius = sd->anchored_size; else { - if(brush->flag & BRUSH_ANCHORED) + if (brush->flag & BRUSH_ANCHORED) projected_radius = 8; else projected_radius = brush_size(vc->scene, brush); @@ -489,7 +489,7 @@ static void paint_cursor_on_hit(Sculpt *sd, Brush *brush, ViewContext *vc, projected_radius); /* scale 3D brush radius by pressure */ - if(sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) + if (sd->draw_pressure && brush_use_size_pressure(vc->scene, brush)) unprojected_radius *= sd->pressure_value; /* set cached value in either Brush or UnifiedPaintSettings */ @@ -515,7 +515,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) final_radius = brush_size(scene, brush); /* check that brush drawing is enabled */ - if(!(paint->flags & PAINT_SHOW_BRUSH)) + if (!(paint->flags & PAINT_SHOW_BRUSH)) return; /* can't use stroke vc here because this will be called during @@ -524,7 +524,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* TODO: as sculpt and other paint modes are unified, this * special mode of drawing will go away */ - if(vc.obact->sculpt) { + if (vc.obact->sculpt) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; float location[3]; int pixel_radius, hit; @@ -541,7 +541,7 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) const float dx = sd->last_x - x; const float dy = sd->last_y - y; - if(dx*dx + dy*dy >= r*r) { + if (dx*dx + dy*dy >= r*r) { sd->last_angle = atan2(dx, dy); sd->last_x = u*sd->last_x + v*x; @@ -555,13 +555,13 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) /* draw overlay */ paint_draw_alpha_overlay(sd, brush, &vc, x, y); - if(brush_use_locked_size(scene, brush)) + if (brush_use_locked_size(scene, brush)) brush_set_size(scene, brush, pixel_radius); /* check if brush is subtracting, use different color then */ /* TODO: no way currently to know state of pen flip or * invert key modifier without starting a stroke */ - if((!(brush->flag & BRUSH_INVERTED) ^ + if ((!(brush->flag & BRUSH_INVERTED) ^ !(brush->flag & BRUSH_DIR_IN)) && ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, @@ -569,10 +569,10 @@ static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused)) outline_col = brush->sub_col; /* only do if brush is over the mesh */ - if(hit) + if (hit) paint_cursor_on_hit(sd, brush, &vc, location); - if(sd->draw_anchored) { + if (sd->draw_anchored) { final_radius = sd->anchored_size; translation[0] = sd->anchored_initial_mouse[0] - vc.ar->winrct.xmin; translation[1] = sd->anchored_initial_mouse[1] - vc.ar->winrct.ymin; @@ -602,6 +602,6 @@ void paint_cursor_start(bContext *C, int (*poll)(bContext *C)) { Paint *p = paint_get_active(CTX_data_scene(C)); - if(p && !p->paint_cursor) + if (p && !p->paint_cursor) p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL); } diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index fbb0df401f9..fcf7d2eba68 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -74,8 +74,8 @@ static int planes_contain_v3(float (*planes)[4], int totplane, const float p[3]) { int i; - for(i = 0; i < totplane; i++) { - if(dot_v3v3(planes[i], p) + planes[i][3] > 0) + for (i = 0; i < totplane; i++) { + if (dot_v3v3(planes[i], p) + planes[i][3] > 0) return 0; } @@ -87,7 +87,7 @@ static int is_effected(PartialVisArea area, float planes[4][4], const float co[3]) { - if(area == PARTIALVIS_ALL) + if (area == PARTIALVIS_ALL) return 1; else { int inside = planes_contain_v3(planes, 4, co); @@ -112,23 +112,23 @@ static void partialvis_update_mesh(Object *ob, sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); - for(i = 0; i < totvert; i++) { + for (i = 0; i < totvert; i++) { MVert *v = &mvert[vert_indices[i]]; /* hide vertex if in the hide volume */ - if(is_effected(area, planes, v->co)) { - if(action == PARTIALVIS_HIDE) + if (is_effected(area, planes, v->co)) { + if (action == PARTIALVIS_HIDE) v->flag |= ME_HIDE; else v->flag &= ~ME_HIDE; any_changed = 1; } - if(!(v->flag & ME_HIDE)) + if (!(v->flag & ME_HIDE)) any_visible = 1; } - if(any_changed) { + if (any_changed) { BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, !any_visible); } @@ -157,12 +157,12 @@ static void partialvis_update_grids(Object *ob, sculpt_undo_push_node(ob, node, SCULPT_UNDO_HIDDEN); any_changed = 0; - for(i = 0; i < totgrid; i++) { + for (i = 0; i < totgrid; i++) { int any_hidden = 0; int g = grid_indices[i], x, y; BLI_bitmap gh = grid_hidden[g]; - if(!gh) { + if (!gh) { switch(action) { case PARTIALVIS_HIDE: /* create grid flags data */ @@ -174,7 +174,7 @@ static void partialvis_update_grids(Object *ob, continue; } } - else if(action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) { + else if (action == PARTIALVIS_SHOW && area == PARTIALVIS_ALL) { /* special case if we're showing all, just free the grid */ MEM_freeN(gh); @@ -184,12 +184,12 @@ static void partialvis_update_grids(Object *ob, continue; } - for(y = 0; y < gridsize; y++) { - for(x = 0; x < gridsize; x++) { + for (y = 0; y < gridsize; y++) { + for (x = 0; x < gridsize; x++) { const float *co = grids[g][y * gridsize + x].co; /* skip grid element if not in the effected area */ - if(is_effected(area, planes, co)) { + if (is_effected(area, planes, co)) { /* set or clear the hide flag */ BLI_BITMAP_MODIFY(gh, y * gridsize + x, action == PARTIALVIS_HIDE); @@ -198,7 +198,7 @@ static void partialvis_update_grids(Object *ob, } /* keep track of whether any elements are still hidden */ - if(BLI_BITMAP_GET(gh, y * gridsize + x)) + if (BLI_BITMAP_GET(gh, y * gridsize + x)) any_hidden = 1; else any_visible = 1; @@ -207,14 +207,14 @@ static void partialvis_update_grids(Object *ob, /* if everything in the grid is now visible, free the grid flags */ - if(!any_hidden) { + if (!any_hidden) { MEM_freeN(gh); grid_hidden[g] = NULL; } } /* mark updates if anything was hidden/shown */ - if(any_changed) { + if (any_changed) { BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, !any_visible); multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED); @@ -310,7 +310,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) break; } - for(i = 0; i < totnode; i++) { + for (i = 0; i < totnode; i++) { switch(pbvh_type) { case PBVH_FACES: partialvis_update_mesh(ob, pbvh, nodes[i], action, area, clip_planes); @@ -321,7 +321,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) } } - if(nodes) + if (nodes) MEM_freeN(nodes); /* end undo */ @@ -329,7 +329,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) /* ensure that edges and faces get hidden as well (not used by sculpt but it looks wrong when entering editmode otherwise) */ - if(pbvh_type == PBVH_FACES) { + if (pbvh_type == PBVH_FACES) { mesh_flush_hidden_from_verts(me->mvert, me->mloop, me->medge, me->totedge, me->mpoly, me->totpoly); @@ -344,7 +344,7 @@ static int hide_show_invoke(bContext *C, wmOperator *op, wmEvent *event) { PartialVisArea area = RNA_enum_get(op->ptr, "area"); - if(area != PARTIALVIS_ALL) + if (area != PARTIALVIS_ALL) return WM_border_select_invoke(C, op, event); else return op->type->exec(C, op); diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a19d00b4926..40b04437cdf 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -403,13 +403,14 @@ static void undo_copy_tile(UndoImageTile *tile, ImBuf *tmpibuf, ImBuf *ibuf, int IMB_rectcpy(tmpibuf, ibuf, 0, 0, tile->x*IMAPAINT_TILE_SIZE, tile->y*IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); - if(ibuf->rect_float) { + if (ibuf->rect_float) { SWAP(void*, tmpibuf->rect_float, tile->rect); - } else { + } + else { SWAP(void*, tmpibuf->rect, tile->rect); } - if(restore) + if (restore) IMB_rectcpy(ibuf, tmpibuf, tile->x*IMAPAINT_TILE_SIZE, tile->y*IMAPAINT_TILE_SIZE, 0, 0, IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE); } @@ -421,10 +422,10 @@ static void *image_undo_push_tile(Image *ima, ImBuf *ibuf, ImBuf **tmpibuf, int int allocsize; short use_float = ibuf->rect_float ? 1 : 0; - for(tile=lb->first; tile; tile=tile->next) - if(tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) - if(tile->use_float == use_float) - if(strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0) + for (tile=lb->first; tile; tile=tile->next) + if (tile->x == x_tile && tile->y == y_tile && ima->gen_type == tile->gen_type && ima->source == tile->source) + if (tile->use_float == use_float) + if (strcmp(tile->idname, ima->id.name)==0 && strcmp(tile->ibufname, ibuf->name)==0) return tile->rect; if (*tmpibuf==NULL) @@ -463,11 +464,11 @@ static void image_undo_restore(bContext *C, ListBase *lb) tmpibuf= IMB_allocImBuf(IMAPAINT_TILE_SIZE, IMAPAINT_TILE_SIZE, 32, IB_rectfloat|IB_rect); - for(tile=lb->first; tile; tile=tile->next) { + for (tile=lb->first; tile; tile=tile->next) { short use_float; /* find image based on name, pointer becomes invalid with global undo */ - if(ima && strcmp(tile->idname, ima->id.name)==0) { + if (ima && strcmp(tile->idname, ima->id.name)==0) { /* ima is valid */ } else { @@ -476,7 +477,7 @@ static void image_undo_restore(bContext *C, ListBase *lb) ibuf= BKE_image_get_ibuf(ima, NULL); - if(ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) { + if (ima && ibuf && strcmp(tile->ibufname, ibuf->name)!=0) { /* current ImBuf filename was changed, probably current frame * was changed when paiting on image sequence, rather than storing * full image user (which isn't so obvious, btw) try to find ImBuf with @@ -499,9 +500,9 @@ static void image_undo_restore(bContext *C, ListBase *lb) undo_copy_tile(tile, tmpibuf, ibuf, 1); GPU_free_image(ima); /* force OpenGL reload */ - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ } @@ -513,7 +514,7 @@ static void image_undo_free(ListBase *lb) { UndoImageTile *tile; - for(tile=lb->first; tile; tile=tile->next) + for (tile=lb->first; tile; tile=tile->next) MEM_freeN(tile->rect); } @@ -523,7 +524,7 @@ static Image *imapaint_face_image(const ImagePaintState *s, int face_index) { Image *ima; - if(scene_use_new_shading_nodes(s->scene)) { + if (scene_use_new_shading_nodes(s->scene)) { MFace *mf = s->me->mface+face_index; ED_object_get_active_image(s->ob, mf->mat_nr, &ima, NULL, NULL); } @@ -539,7 +540,7 @@ static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtfa { Image *ima; - if(ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ + if (ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */ MFace *mf = ps->dm_mface+face_index; ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL); } @@ -815,7 +816,7 @@ static int project_paint_PickColor(const ProjPaintState *ps, float pt[2], float static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], float v3[4], float w[3], int is_ortho) { /* if all are behind us, return false */ - if(v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) + if (v1[2] > pt[2] && v2[2] > pt[2] && v3[2] > pt[2]) return 0; /* do a 2D point in try intersection */ @@ -825,7 +826,7 @@ static int project_paint_occlude_ptv(float pt[3], float v1[4], float v2[4], floa /* From here on we know there IS an intersection */ /* if ALL of the verts are infront of us then we know it intersects ? */ - if(v1[2] < pt[2] && v2[2] < pt[2] && v3[2] < pt[2]) { + if (v1[2] < pt[2] && v2[2] < pt[2] && v3[2] < pt[2]) { return 1; } else { @@ -889,14 +890,14 @@ static int project_bucket_point_occluded(const ProjPaintState *ps, LinkNode *buc if (orig_face != face_index) { mf = ps->dm_mface + face_index; - if(do_clip) + if (do_clip) isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], 0); else isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v2], ps->screenCoords[mf->v3], w, ps->is_ortho); /* Note, if isect_ret==-1 then we don't want to test the other side of the quad */ if (isect_ret==0 && mf->v4) { - if(do_clip) + if (do_clip) isect_ret = project_paint_occlude_ptv_clip(ps, mf, pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], 1); else isect_ret = project_paint_occlude_ptv(pixelScreenCo, ps->screenCoords[mf->v1], ps->screenCoords[mf->v3], ps->screenCoords[mf->v4], w, ps->is_ortho); @@ -1392,7 +1393,8 @@ static float project_paint_uvpixel_mask( else { return 0.0f; } - } else { + } + else { mask = 1.0f; } @@ -2095,7 +2097,7 @@ static void project_bucket_clip_face( /* now we have all points we need, collect their angles and sort them clockwise */ - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { cent[0] += isectVCosSS[i][0]; cent[1] += isectVCosSS[i][1]; } @@ -2108,7 +2110,7 @@ static void project_bucket_clip_face( #if 0 /* uses a few more cycles then the above loop */ - for(i=0; i<(*tot); i++) { + for (i=0; i<(*tot); i++) { isectVCosSS[i][2] = angle_2d_clockwise(up, cent, isectVCosSS[i]); } #endif @@ -2116,7 +2118,7 @@ static void project_bucket_clip_face( v1_clipSS[0] = cent[0]; /* Abuse this var for the loop below */ v1_clipSS[1] = cent[1] + 1.0f; - for(i=0; i<(*tot); i++) { + for (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], v1_clipSS[0]*v2_clipSS[0]+v1_clipSS[1]*v2_clipSS[1]); @@ -2141,12 +2143,12 @@ static void project_bucket_clip_face( doubles = TRUE; while (doubles==TRUE) { doubles = FALSE; - for(i=1; i<(*tot); i++) { + for (i=1; i<(*tot); i++) { if (fabsf(isectVCosSS[i-1][0]-isectVCosSS[i][0]) < PROJ_GEOM_TOLERANCE && fabsf(isectVCosSS[i-1][1]-isectVCosSS[i][1]) < PROJ_GEOM_TOLERANCE) { int j; - for(j=i+1; j<(*tot); j++) { + for (j=i+1; j<(*tot); j++) { isectVCosSS[j-1][0] = isectVCosSS[j][0]; isectVCosSS[j-1][1] = isectVCosSS[j][1]; } @@ -2165,13 +2167,13 @@ static void project_bucket_clip_face( if (is_ortho) { - for(i=0; i<(*tot); i++) { + for (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 (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); } @@ -2405,12 +2407,12 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i if (pixel_bounds_array(uv_clip, &bounds_px, ibuf->x, ibuf->y, uv_clip_tot)) { - if(clamp_u) { + if (clamp_u) { CLAMP(bounds_px.xmin, 0, ibuf->x); CLAMP(bounds_px.xmax, 0, ibuf->x); } - if(clamp_v) { + if (clamp_v) { CLAMP(bounds_px.ymin, 0, ibuf->y); CLAMP(bounds_px.ymax, 0, ibuf->y); } @@ -2429,7 +2431,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* Note about IsectPoly2Df_twoside, checking the face or uv flipping doesnt work, * could check the poly direction but better to do this */ - if( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) || + if ( (do_backfacecull && IsectPoly2Df(uv, uv_clip, uv_clip_tot)) || (do_backfacecull==0 && IsectPoly2Df_twoside(uv, uv_clip, uv_clip_tot))) { has_x_isect = has_isect = 1; @@ -2438,7 +2440,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i else screen_px_from_persp(uv, v1coSS, v2coSS, v3coSS, uv1co, uv2co, uv3co, pixelScreenCo, w); /* a pity we need to get the worldspace pixel location here */ - if(do_clip) { + if (do_clip) { interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) { continue; /* Watch out that no code below this needs to run */ @@ -2479,7 +2481,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i #endif } } - } while(side--); + } while (side--); @@ -2659,7 +2661,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i } /* a pity we need to get the worldspace pixel location here */ - if(do_clip) { + if (do_clip) { if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); @@ -2952,7 +2954,7 @@ static void project_paint_begin(ProjPaintState *ps) /* ---- end defines ---- */ - if(ps->source==PROJ_SRC_VIEW) + if (ps->source==PROJ_SRC_VIEW) ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */ /* paint onto the derived mesh */ @@ -2963,7 +2965,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE); ps->dm_release= TRUE; } - else if(ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) { + else if (ps->ob->derivedFinal && CustomData_has_layer( &ps->ob->derivedFinal->faceData, CD_MTFACE)) { ps->dm = ps->ob->derivedFinal; ps->dm_release= FALSE; } @@ -2974,7 +2976,7 @@ static void project_paint_begin(ProjPaintState *ps) if ( !CustomData_has_layer( &ps->dm->faceData, CD_MTFACE) ) { - if(ps->dm_release) + if (ps->dm_release) ps->dm->release(ps->dm); ps->dm = NULL; @@ -3019,7 +3021,7 @@ static void project_paint_begin(ProjPaintState *ps) } /* when using subsurf or multires, mface arrays are thrown away, we need to keep a copy */ - if(ps->dm->type != DM_TYPE_CDDM) { + if (ps->dm->type != DM_TYPE_CDDM) { ps->dm_mvert= MEM_dupallocN(ps->dm_mvert); ps->dm_mface= MEM_dupallocN(ps->dm_mface); /* looks like these are ok for now.*/ @@ -3040,7 +3042,7 @@ static void project_paint_begin(ProjPaintState *ps) invert_m4_m4(ps->ob->imat, ps->ob->obmat); - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { /* normal drawing */ ps->winx= ps->ar->winx; ps->winy= ps->ar->winy; @@ -3126,7 +3128,7 @@ static void project_paint_begin(ProjPaintState *ps) projScreenCo= *ps->screenCoords; if (ps->is_ortho) { - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { mul_v3_m4v3(projScreenCo, ps->projectMat, mv->co); /* screen space, not clamped */ @@ -3136,7 +3138,7 @@ static void project_paint_begin(ProjPaintState *ps) } } else { - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++, projScreenCo+=4) { copy_v3_v3(projScreenCo, mv->co); projScreenCo[3] = 1.0f; @@ -3169,7 +3171,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->screenMax[1] += projMargin; ps->screenMin[1] -= projMargin; - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { #ifdef PROJ_DEBUG_WINCLIP CLAMP(ps->screenMin[0], (float)(-diameter), (float)(ps->winx + diameter)); CLAMP(ps->screenMax[0], (float)(-diameter), (float)(ps->winx + diameter)); @@ -3235,7 +3237,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->vertFlags = MEM_callocN(sizeof(char) * ps->dm_totvert, "paint-vertFlags"); - for(a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++) { + for (a=0, mv=ps->dm_mvert; a < ps->dm_totvert; a++, mv++) { normal_short_to_float_v3(no, mv->no); if (ps->is_ortho) { @@ -3254,7 +3256,7 @@ static void project_paint_begin(ProjPaintState *ps) } - for(face_index = 0, tf = ps->dm_mtface, mf = ps->dm_mface; face_index < ps->dm_totface; mf++, tf++, face_index++) { + for (face_index = 0, tf = ps->dm_mtface, mf = ps->dm_mface; face_index < ps->dm_totface; mf++, tf++, face_index++) { #ifndef PROJ_DEBUG_NOSEAMBLEED /* add face user if we have bleed enabled, set the UV seam flags later */ @@ -3400,7 +3402,7 @@ static void project_paint_end(ProjPaintState *ps) int a; /* build undo data from original pixel colors */ - if(U.uiflag & USER_GLOBALUNDO) { + if (U.uiflag & USER_GLOBALUNDO) { ProjPixel *projPixel; ImBuf *tmpibuf = NULL, *tmpibuf_float = NULL; LinkNode *pixel_node; @@ -3419,7 +3421,7 @@ static void project_paint_end(ProjPaintState *ps) int last_image_index = -1; int last_tile_width=0; - for(a=0, last_projIma=ps->projImages; a < ps->image_tot; a++, last_projIma++) { + for (a=0, last_projIma=ps->projImages; a < ps->image_tot; a++, last_projIma++) { int size = sizeof(void **) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->x) * IMAPAINT_TILE_NUMBER(last_projIma->ibuf->y); last_projIma->undoRect = (void **) BLI_memarena_alloc(arena, size); memset(last_projIma->undoRect, 0, size); @@ -3428,7 +3430,7 @@ static void project_paint_end(ProjPaintState *ps) for (bucket_index = 0; bucket_index < bucket_tot; bucket_index++) { /* loop through all pixels */ - for(pixel_node= ps->bucketRect[bucket_index]; pixel_node; pixel_node= pixel_node->next) { + for (pixel_node= ps->bucketRect[bucket_index]; pixel_node; pixel_node= pixel_node->next) { /* ok we have a pixel, was it modified? */ projPixel = (ProjPixel *)pixel_node->link; @@ -3506,18 +3508,18 @@ static void project_paint_end(ProjPaintState *ps) } /* copy for subsurf/multires, so throw away */ - if(ps->dm->type != DM_TYPE_CDDM) { - if(ps->dm_mvert) MEM_freeN(ps->dm_mvert); - if(ps->dm_mface) MEM_freeN(ps->dm_mface); + if (ps->dm->type != DM_TYPE_CDDM) { + if (ps->dm_mvert) MEM_freeN(ps->dm_mvert); + if (ps->dm_mface) MEM_freeN(ps->dm_mface); /* looks like these don't need copying */ #if 0 - if(ps->dm_mtface) MEM_freeN(ps->dm_mtface); - if(ps->dm_mtface_clone) MEM_freeN(ps->dm_mtface_clone); - if(ps->dm_mtface_stencil) MEM_freeN(ps->dm_mtface_stencil); + if (ps->dm_mtface) MEM_freeN(ps->dm_mtface); + if (ps->dm_mtface_clone) MEM_freeN(ps->dm_mtface_clone); + if (ps->dm_mtface_stencil) MEM_freeN(ps->dm_mtface_stencil); #endif } - if(ps->dm_release) + if (ps->dm_release) ps->dm->release(ps->dm); } @@ -3589,7 +3591,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) /* run this per painting onto each mouse location */ static int project_bucket_iter_init(ProjPaintState *ps, const float mval_f[2]) { - if(ps->source==PROJ_SRC_VIEW) { + if (ps->source==PROJ_SRC_VIEW) { float min_brush[2], max_brush[2]; const float radius = (float)brush_size(ps->scene, ps->brush); @@ -3791,17 +3793,17 @@ static void do_projectpaint_draw_f(ProjPaintState *ps, ProjPixel *projPixel, flo { if (ps->is_texbrush) { /* rgba already holds a texture result here from higher level function */ - if(use_color_correction){ + if (use_color_correction) { float rgba_br[3]; srgb_to_linearrgb_v3_v3(rgba_br, ps->brush->rgb); mul_v3_v3(rgba, rgba_br); } - else{ + else { mul_v3_v3(rgba, ps->brush->rgb); } } else { - if(use_color_correction){ + if (use_color_correction) { srgb_to_linearrgb_v3_v3(rgba, ps->brush->rgb); } else { @@ -3879,7 +3881,7 @@ static void *do_projectpaint_thread(void *ph_v) project_bucket_init(ps, thread_index, bucket_index, &bucket_bounds); } - if(ps->source != PROJ_SRC_VIEW) { + if (ps->source != PROJ_SRC_VIEW) { /* Re-Projection, simple, no brushes! */ @@ -3887,7 +3889,7 @@ static void *do_projectpaint_thread(void *ph_v) projPixel = (ProjPixel *)node->link; bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL, projPixel->projCoSS[0], projPixel->projCoSS[1]); - if(projPixel->newColor.ch[3]) { + if (projPixel->newColor.ch[3]) { mask = ((float)projPixel->mask)/65535.0f; blend_color_mix_accum(projPixel->pixel.ch_pt, projPixel->origColor.ch, projPixel->newColor.ch, (int)(mask*projPixel->newColor.ch[3])); @@ -3914,7 +3916,8 @@ static void *do_projectpaint_thread(void *ph_v) /* note, for clone and smear, we only use the alpha, could be a special function */ brush_sample_tex(ps->scene, ps->brush, projPixel->projCoSS, rgba, thread_index); alpha = rgba[3]; - } else { + } + else { alpha = 1.0f; } @@ -3986,7 +3989,7 @@ static void *do_projectpaint_thread(void *ph_v) } } - if(lock_alpha) { + if (lock_alpha) { if (is_floatbuf) projPixel->pixel.f_pt[3]= projPixel->origColor.f[3]; else projPixel->pixel.ch_pt[3]= projPixel->origColor.ch[3]; } @@ -4035,7 +4038,7 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp BLI_init_threads(&threads, do_projectpaint_thread, ps->thread_tot); /* get the threads running */ - for(a=0; a < ps->thread_tot; a++) { + for (a=0; a < ps->thread_tot; a++) { /* set defaults in handles */ //memset(&handles[a], 0, sizeof(BakeShade)); @@ -4068,9 +4071,9 @@ static int project_paint_op(void *state, ImBuf *UNUSED(ibufb), const float lastp /* move threaded bounds back into ps->projectPartialRedraws */ - for(i=0; i < ps->image_tot; i++) { + for (i=0; i < ps->image_tot; i++) { int touch = 0; - for(a=0; a < ps->thread_tot; a++) { + for (a=0; a < ps->thread_tot; a++) { touch |= partial_redraw_array_merge(ps->projImages[i].partRedrawRect, handles[a].projImages[i].partRedrawRect, PROJ_BOUNDBOX_SQUARED); } @@ -4112,7 +4115,7 @@ static int project_paint_stroke(ProjPaintState *ps, BrushPainter *painter, const redraw= project_paint_sub_stroke(ps, painter, prevmval_i, mval_i, time, pressure); - if(project_image_refresh_tagged(ps)) + if (project_image_refresh_tagged(ps)) return redraw; return 0; @@ -4166,14 +4169,14 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) { - if(ibuf->rect_float) + if (ibuf->rect_float) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ - if(ibuf->mipmap[0]) + if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* todo: should set_tpage create ->rect? */ - if(texpaint || (sima && sima->lock)) { + if (texpaint || (sima && sima->lock)) { int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; /* Testing with partial update in uv editor too */ @@ -4197,7 +4200,8 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh if (set) { IMAPAINT_FLOAT_RGB_COPY(rrgbf, rgb); - } else { + } + else { IMAPAINT_FLOAT_RGB_COPY(rgb, rrgbf); } } @@ -4206,7 +4210,8 @@ static void imapaint_ibuf_get_set_rgb(ImBuf *ibuf, int x, int y, short torus, sh if (set) { IMAPAINT_FLOAT_RGB_TO_CHAR(rrgb, rgb) - } else { + } + else { IMAPAINT_CHAR_RGB_TO_FLOAT(rgb, rrgb) } } @@ -4340,7 +4345,7 @@ static void imapaint_lift_smear(ImBuf *ibuf, ImBuf *ibufb, int *pos) imapaint_set_region(region, 0, 0, pos[0], pos[1], ibufb->x, ibufb->y); tot= imapaint_torus_split_region(region, ibufb, ibuf); - for(a=0; a<tot; a++) + for (a=0; a<tot; a++) IMB_rectblend(ibufb, ibuf, region[a].destx, region[a].desty, region[a].srcx, region[a].srcy, region[a].width, region[a].height, IMB_BLEND_COPY_RGB); @@ -4385,17 +4390,17 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], imapaint_convert_brushco(ibufb, pos, bpos); /* lift from canvas */ - if(s->tool == PAINT_TOOL_SOFTEN) { + if (s->tool == PAINT_TOOL_SOFTEN) { imapaint_lift_soften(s->canvas, ibufb, bpos, torus); } - else if(s->tool == PAINT_TOOL_SMEAR) { + else if (s->tool == PAINT_TOOL_SMEAR) { if (lastpos[0]==pos[0] && lastpos[1]==pos[1]) return 0; imapaint_convert_brushco(ibufb, lastpos, blastpos); imapaint_lift_smear(s->canvas, ibufb, blastpos); } - else if(s->tool == PAINT_TOOL_CLONE && s->clonecanvas) { + else if (s->tool == PAINT_TOOL_CLONE && s->clonecanvas) { liftpos[0]= pos[0] - offset[0]*s->canvas->x; liftpos[1]= pos[1] - offset[1]*s->canvas->y; @@ -4405,7 +4410,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], frombuf= (clonebuf)? clonebuf: ibufb; - if(torus) { + if (torus) { imapaint_set_region(region, bpos[0], bpos[1], 0, 0, frombuf->x, frombuf->y); tot= imapaint_torus_split_region(region, s->canvas, frombuf); } @@ -4415,7 +4420,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], } /* blend into canvas */ - for(a=0; a<tot; a++) { + for (a=0; a<tot; a++) { imapaint_dirty_region(s->image, s->canvas, region[a].destx, region[a].desty, region[a].width, region[a].height); @@ -4426,7 +4431,7 @@ static int imapaint_paint_op(void *state, ImBuf *ibufb, const float lastpos[2], region[a].width, region[a].height, blend); } - if(clonebuf) IMB_freeImBuf(clonebuf); + if (clonebuf) IMB_freeImBuf(clonebuf); return 1; } @@ -4453,35 +4458,35 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) ImBuf *ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL); /* verify that we can paint and set canvas */ - if(ima==NULL) { + if (ima==NULL) { return 0; } - else if(ima->packedfile && ima->rr) { + else if (ima->packedfile && ima->rr) { s->warnpackedfile = ima->id.name + 2; return 0; } - else if(ibuf && ibuf->channels!=4) { + else if (ibuf && ibuf->channels!=4) { s->warnmultifile = ima->id.name + 2; return 0; } - else if(!ibuf || !(ibuf->rect || ibuf->rect_float)) + else if (!ibuf || !(ibuf->rect || ibuf->rect_float)) return 0; s->image= ima; s->canvas= ibuf; /* set clone canvas */ - if(s->tool == PAINT_TOOL_CLONE) { + if (s->tool == PAINT_TOOL_CLONE) { ima= s->brush->clone.image; ibuf= BKE_image_get_ibuf(ima, s->sima? &s->sima->iuser: NULL); - if(!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) + if (!ima || !ibuf || !(ibuf->rect || ibuf->rect_float)) return 0; s->clonecanvas= ibuf; /* temporarily add float rect for cloning */ - if(s->canvas->rect_float && !s->clonecanvas->rect_float) { + if (s->canvas->rect_float && !s->clonecanvas->rect_float) { int profile = IB_PROFILE_NONE; /* Don't want to color manage, but don't disturb existing profiles */ @@ -4492,7 +4497,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) SWAP(int, s->clonecanvas->profile, profile); } - else if(!s->canvas->rect_float && !s->clonecanvas->rect) + else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); } @@ -4510,7 +4515,7 @@ static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, ImBuf *ibuf= BKE_image_get_ibuf(image, s->sima? &s->sima->iuser: NULL); float pos[2]; - if(!ibuf) + if (!ibuf) return 0; pos[0] = uv[0]*ibuf->x; @@ -4543,7 +4548,7 @@ static int imapaint_paint_stroke(ViewContext *vc, ImagePaintState *s, BrushPaint newimage = imapaint_face_image(s, newfaceindex); ibuf= BKE_image_get_ibuf(newimage, s->sima? &s->sima->iuser: NULL); - if(ibuf && ibuf->rect) + if (ibuf && ibuf->rect) imapaint_pick_uv(s->scene, s->ob, newfaceindex, mval, newuv); else { newimage = NULL; @@ -4621,7 +4626,7 @@ static Brush *uv_sculpt_brush(bContext *C) Scene *scene= CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - if(!settings->uvsculpt) + if (!settings->uvsculpt) return NULL; return paint_brush(&settings->uvsculpt->paint); } @@ -4630,19 +4635,19 @@ static int image_paint_poll(bContext *C) { Object *obact = CTX_data_active_object(C); - if(!image_paint_brush(C)) + if (!image_paint_brush(C)) return 0; - if((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { + if ((obact && obact->mode & OB_MODE_TEXTURE_PAINT) && CTX_wm_region_view3d(C)) { return 1; } else { SpaceImage *sima= CTX_wm_space_image(C); - if(sima) { + if (sima) { ARegion *ar= CTX_wm_region(C); - if((sima->flag & SI_DRAWTOOL) && ar->regiontype==RGN_TYPE_WINDOW) + if ((sima->flag & SI_DRAWTOOL) && ar->regiontype==RGN_TYPE_WINDOW) return 1; } } @@ -4659,15 +4664,15 @@ static int uv_sculpt_brush_poll(bContext *C) Scene *scene = CTX_data_scene(C); ToolSettings *toolsettings = scene->toolsettings; - if(!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH) + if (!uv_sculpt_brush(C) || !obedit || obedit->type != OB_MESH) return 0; em = BMEdit_FromObject(obedit); ret = EDBM_texFaceCheck(em); - if(ret && sima) { + if (ret && sima) { ARegion *ar= CTX_wm_region(C); - if((toolsettings->use_uv_sculpt) && ar->regiontype==RGN_TYPE_WINDOW) + if ((toolsettings->use_uv_sculpt) && ar->regiontype==RGN_TYPE_WINDOW) return 1; } @@ -4676,7 +4681,7 @@ static int uv_sculpt_brush_poll(bContext *C) static int image_paint_3d_poll(bContext *C) { - if(CTX_wm_region_view3d(C)) + if (CTX_wm_region_view3d(C)) return image_paint_poll(C); return 0; @@ -4686,9 +4691,9 @@ static int image_paint_2d_clone_poll(bContext *C) { Brush *brush= image_paint_brush(C); - if(!CTX_wm_region_view3d(C) && image_paint_poll(C)) - if(brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) - if(brush->clone.image) + if (!CTX_wm_region_view3d(C) && image_paint_poll(C)) + if (brush && (brush->imagepaint_tool == PAINT_TOOL_CLONE)) + if (brush->clone.image) return 1; return 0; @@ -4723,15 +4728,15 @@ typedef struct PaintOperation { static void paint_redraw(bContext *C, ImagePaintState *s, int final) { - if(final) { - if(s->image) + if (final) { + if (s->image) GPU_free_image(s->image); /* compositor listener deals with updating */ WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image); } else { - if(!s->sima || !s->sima->lock) + if (!s->sima || !s->sima->lock) ED_region_tag_redraw(CTX_wm_region(C)); else WM_event_add_notifier(C, NC_IMAGE|NA_EDITED, s->image); @@ -4779,7 +4784,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->seam_bleed_px = settings->imapaint.seam_bleed; /* pixel num to bleed */ #endif - if(ps->do_mask_normal) { + if (ps->do_mask_normal) { ps->normal_angle_inner = settings->imapaint.normal_angle; ps->normal_angle = (ps->normal_angle_inner + 90.0f) * 0.5f; } @@ -4791,16 +4796,16 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps) ps->normal_angle *= (float)(M_PI_2 / 90); ps->normal_angle_range = ps->normal_angle - ps->normal_angle_inner; - if(ps->normal_angle_range <= 0.0f) + if (ps->normal_angle_range <= 0.0f) ps->do_mask_normal = 0; /* no need to do blending */ } static void paint_brush_init_tex(Brush *brush) { /* init mtex nodes */ - if(brush) { + if (brush) { MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */ } @@ -4818,16 +4823,16 @@ static int texture_paint_init(bContext *C, wmOperator *op) /* XXX: Soften tool does not support projection painting atm, so just disable * projection for this brush */ - if(brush->imagepaint_tool == PAINT_TOOL_SOFTEN) { + if (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) { settings->imapaint.flag |= IMAGEPAINT_PROJECT_DISABLE; pop->restore_projection = 1; } /* initialize from context */ - if(CTX_wm_region_view3d(C)) { + if (CTX_wm_region_view3d(C)) { pop->mode= PAINT_MODE_3D; - if(!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) + if (!(settings->imapaint.flag & IMAGEPAINT_PROJECT_DISABLE)) pop->mode= PAINT_MODE_3D_PROJECT; else view3d_set_viewcontext(C, &pop->vc); @@ -4842,12 +4847,12 @@ static int texture_paint_init(bContext *C, wmOperator *op) pop->s.brush = brush; pop->s.tool = brush->imagepaint_tool; - if(pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) + if (pop->mode == PAINT_MODE_3D && (pop->s.tool == PAINT_TOOL_CLONE)) pop->s.tool = PAINT_TOOL_DRAW; pop->s.blend = brush->blend; pop->orig_brush_size= brush_size(scene, brush); - if(pop->mode != PAINT_MODE_2D) { + if (pop->mode != PAINT_MODE_2D) { pop->s.ob = OBACT; pop->s.me = get_mesh(pop->s.ob); if (!pop->s.me) return 0; @@ -4855,10 +4860,10 @@ static int texture_paint_init(bContext *C, wmOperator *op) else { pop->s.image = pop->s.sima->image; - if(!imapaint_canvas_set(&pop->s, pop->s.image)) { - if(pop->s.warnmultifile) + if (!imapaint_canvas_set(&pop->s, pop->s.image)) { + if (pop->s.warnmultifile) BKE_report(op->reports, RPT_WARNING, "Image requires 4 color channels to paint"); - if(pop->s.warnpackedfile) + if (pop->s.warnpackedfile) BKE_report(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted"); return 0; @@ -4868,7 +4873,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) paint_brush_init_tex(pop->s.brush); /* note, if we have no UVs on the derived mesh, then we must return here */ - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { /* initialize all data from the context */ project_state_init(C, OBACT, &pop->ps); @@ -4887,7 +4892,7 @@ static int texture_paint_init(bContext *C, wmOperator *op) /* allocate and initialize spacial data structures */ project_paint_begin(&pop->ps); - if(pop->ps.dm==NULL) + if (pop->ps.dm==NULL) return 0; } @@ -4914,13 +4919,13 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) time= RNA_float_get(itemptr, "time"); pressure= RNA_float_get(itemptr, "pressure"); - if(pop->first) + if (pop->first) project_paint_begin_clone(&pop->ps, mouse); - if(pop->mode == PAINT_MODE_3D) + if (pop->mode == PAINT_MODE_3D) view3d_operator_needs_opengl(C); - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { redraw= project_paint_stroke(&pop->ps, pop->painter, pop->prevmouse, mouse, time, pressure); pop->prevmouse[0]= mouse[0]; pop->prevmouse[1]= mouse[1]; @@ -4932,7 +4937,7 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) pop->prevmouse[1]= mouse[1]; } - if(redraw) + if (redraw) paint_redraw(C, &pop->s, 0); pop->first= 0; @@ -4940,9 +4945,9 @@ static void paint_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) static void paint_brush_exit_tex(Brush *brush) { - if(brush) { + if (brush) { MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); } } @@ -4953,10 +4958,10 @@ static void paint_exit(bContext *C, wmOperator *op) ToolSettings *settings= scene->toolsettings; PaintOperation *pop= op->customdata; - if(pop->timer) + if (pop->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), pop->timer); - if(pop->restore_projection) + if (pop->restore_projection) settings->imapaint.flag &= ~IMAGEPAINT_PROJECT_DISABLE; paint_brush_exit_tex(pop->s.brush); @@ -4965,7 +4970,7 @@ static void paint_exit(bContext *C, wmOperator *op) imapaint_canvas_free(&pop->s); brush_painter_free(pop->painter); - if(pop->mode == PAINT_MODE_3D_PROJECT) { + if (pop->mode == PAINT_MODE_3D_PROJECT) { brush_set_size(scene, pop->ps.brush, pop->orig_brush_size); paint_brush_exit_tex(pop->ps.brush); @@ -4975,9 +4980,9 @@ static void paint_exit(bContext *C, wmOperator *op) paint_redraw(C, &pop->s, 1); undo_paint_push_end(UNDO_PAINT_IMAGE); - if(pop->s.warnmultifile) + if (pop->s.warnmultifile) BKE_reportf(op->reports, RPT_WARNING, "Image requires 4 color channels to paint: %s", pop->s.warnmultifile); - if(pop->s.warnpackedfile) + if (pop->s.warnpackedfile) BKE_reportf(op->reports, RPT_WARNING, "Packed MultiLayer files cannot be painted: %s", pop->s.warnpackedfile); MEM_freeN(pop); @@ -4985,7 +4990,7 @@ static void paint_exit(bContext *C, wmOperator *op) static int paint_exec(bContext *C, wmOperator *op) { - if(!texture_paint_init(C, op)) { + if (!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -5015,19 +5020,19 @@ static void paint_apply_event(bContext *C, wmOperator *op, wmEvent *event) tablet= 0; pop->s.blend= pop->s.brush->blend; - if(event->custom == EVT_DATA_TABLET) { + if (event->custom == EVT_DATA_TABLET) { wmtab= event->customdata; tablet= (wmtab->Active != EVT_TABLET_NONE); pressure= wmtab->Pressure; - if(wmtab->Active == EVT_TABLET_ERASER) + if (wmtab->Active == EVT_TABLET_ERASER) pop->s.blend= IMB_BLEND_ERASE_ALPHA; } else { /* otherwise airbrush becomes 1.0 pressure instantly */ pressure= pop->prev_pressure ? pop->prev_pressure : 1.0f; } - if(pop->first) { + if (pop->first) { pop->prevmouse[0]= event->mval[0]; pop->prevmouse[1]= event->mval[1]; pop->starttime= time; @@ -5064,7 +5069,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) { PaintOperation *pop; - if(!texture_paint_init(C, op)) { + if (!texture_paint_init(C, op)) { MEM_freeN(op->customdata); return OPERATOR_CANCELLED; } @@ -5074,7 +5079,7 @@ static int paint_invoke(bContext *C, wmOperator *op, wmEvent *event) pop= op->customdata; WM_event_add_modal_handler(C, op); - if(pop->s.brush->flag & BRUSH_AIRBRUSH) + if (pop->s.brush->flag & BRUSH_AIRBRUSH) pop->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f); return OPERATOR_RUNNING_MODAL; @@ -5095,7 +5100,7 @@ static int paint_modal(bContext *C, wmOperator *op, wmEvent *event) paint_apply_event(C, op, event); break; case TIMER: - if(event->customdata == pop->timer) + if (event->customdata == pop->timer) paint_apply_event(C, op, event); break; } @@ -5134,7 +5139,7 @@ int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { RegionView3D *rv3d= CTX_wm_region_view3d(C); - if(!rv3d) { + if (!rv3d) { SpaceImage *sima= CTX_wm_space_image(C); ARegion *ar= CTX_wm_region(C); @@ -5160,7 +5165,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) Paint *paint= paint_get_active(scene); Brush *brush= paint_brush(paint); - if(paint && brush && paint->flags & PAINT_SHOW_BRUSH) { + if (paint && brush && paint->flags & PAINT_SHOW_BRUSH) { ToolSettings *ts; float zoomx, zoomy; const float size= (float)brush_size(scene, brush); @@ -5172,7 +5177,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) use_zoom= get_imapaint_zoom(C, &zoomx, &zoomy) && !(ts->use_uv_sculpt && (scene->basact->object->mode == OB_MODE_EDIT)); - if(use_zoom){ + if (use_zoom) { pixel_size = MAX2(size * zoomx, size * zoomy); } else { @@ -5180,7 +5185,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) } /* fade out the brush (cheap trick to work around brush interfearing with sampling [#])*/ - if(pixel_size < PX_SIZE_FADE_MIN) { + if (pixel_size < PX_SIZE_FADE_MIN) { return; } else if (pixel_size < PX_SIZE_FADE_MAX) { @@ -5192,7 +5197,7 @@ static void brush_drawcursor(bContext *C, int x, int y, void *UNUSED(customdata) glTranslatef((float)x, (float)y, 0.0f); /* No need to scale for uv sculpting, on the contrary it might be useful to keep unscaled */ - if(use_zoom) + if (use_zoom) glScalef(zoomx, zoomy, 1.0f); glColor4f(brush->add_col[0], brush->add_col[1], brush->add_col[2], alpha); @@ -5214,11 +5219,11 @@ static void toggle_paint_cursor(bContext *C, int enable) Scene *scene = CTX_data_scene(C); ToolSettings *settings= scene->toolsettings; - if(settings->imapaint.paintcursor && !enable) { + if (settings->imapaint.paintcursor && !enable) { WM_paint_cursor_end(wm, settings->imapaint.paintcursor); settings->imapaint.paintcursor = NULL; } - else if(enable) + else if (enable) settings->imapaint.paintcursor= WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL); } @@ -5231,7 +5236,7 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) { ImagePaintSettings *imapaint = &settings->imapaint; - if(!imapaint->paintcursor) { + if (!imapaint->paintcursor) { imapaint->paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL); @@ -5241,8 +5246,8 @@ void ED_space_image_paint_update(wmWindowManager *wm, ToolSettings *settings) void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings) { - if(settings->use_uv_sculpt) { - if(!settings->uvsculpt) { + if (settings->use_uv_sculpt) { + if (!settings->uvsculpt) { settings->uvsculpt = MEM_callocN(sizeof(*settings->uvsculpt), "UV Smooth paint"); settings->uv_sculpt_tool = UV_SCULPT_TOOL_GRAB; settings->uv_sculpt_settings = UV_SCULPT_LOCK_BORDERS | UV_SCULPT_ALL_ISLANDS; @@ -5255,7 +5260,7 @@ void ED_space_image_uv_sculpt_update(wmWindowManager *wm, ToolSettings *settings brush_drawcursor, NULL); } else { - if(settings->uvsculpt) + if (settings->uvsculpt) settings->uvsculpt->paint.flags &= ~PAINT_SHOW_BRUSH; } } @@ -5402,12 +5407,12 @@ static int sample_color_modal(bContext *C, wmOperator *op, wmEvent *event) /* same as image_paint_poll but fail when face mask mode is enabled */ static int image_paint_sample_color_poll(bContext *C) { - if(image_paint_poll(C)) { - if(CTX_wm_view3d(C)) { + if (image_paint_poll(C)) { + if (CTX_wm_view3d(C)) { Object *obact = CTX_data_active_object(C); if (obact && obact->mode & OB_MODE_TEXTURE_PAINT) { Mesh *me= get_mesh(obact); - if(me) { + if (me) { return !(me->editflag & ME_EDIT_PAINT_MASK); } } @@ -5462,7 +5467,7 @@ static int set_clone_cursor_invoke(bContext *C, wmOperator *op, wmEvent *event) view3d_operator_needs_opengl(C); - if(!ED_view3d_autodist(scene, ar, v3d, event->mval, location)) + if (!ED_view3d_autodist(scene, ar, v3d, event->mval, location)) return OPERATOR_CANCELLED; RNA_float_set_array(op->ptr, "location", location); @@ -5492,9 +5497,9 @@ void PAINT_OT_clone_cursor_set(wmOperatorType *ot) static int texture_paint_toggle_poll(bContext *C) { - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; - if(CTX_data_active_object(C)==NULL) + if (CTX_data_active_object(C)==NULL) return 0; return 1; @@ -5506,7 +5511,7 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) Object *ob= CTX_data_active_object(C); Mesh *me= NULL; - if(ob==NULL) + if (ob==NULL) return OPERATOR_CANCELLED; if (object_data_is_libdata(ob)) { @@ -5516,15 +5521,15 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) me= get_mesh(ob); - if(!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { + if (!(ob->mode & OB_MODE_TEXTURE_PAINT) && !me) { BKE_report(op->reports, RPT_ERROR, "Can only enter texture paint mode for mesh objects"); return OPERATOR_CANCELLED; } - if(ob->mode & OB_MODE_TEXTURE_PAINT) { + if (ob->mode & OB_MODE_TEXTURE_PAINT) { ob->mode &= ~OB_MODE_TEXTURE_PAINT; - if(U.glreslimit != 0) + if (U.glreslimit != 0) GPU_free_images(); GPU_paint_set_mipmap(1); @@ -5533,13 +5538,13 @@ static int texture_paint_toggle_exec(bContext *C, wmOperator *op) else { ob->mode |= OB_MODE_TEXTURE_PAINT; - if(me->mtface==NULL) + if (me->mtface==NULL) me->mtface= CustomData_add_layer(&me->fdata, CD_MTFACE, CD_DEFAULT, NULL, me->totface); paint_init(&scene->toolsettings->imapaint.paint, PAINT_CURSOR_TEXTURE_PAINT); - if(U.glreslimit != 0) + if (U.glreslimit != 0) GPU_free_images(); GPU_paint_set_mipmap(0); @@ -5568,8 +5573,8 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) static int texture_paint_poll(bContext *C) { - if(texture_paint_toggle_poll(C)) - if(CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) + if (texture_paint_toggle_poll(C)) + if (CTX_data_active_object(C)->mode & OB_MODE_TEXTURE_PAINT) return 1; return 0; @@ -5611,12 +5616,12 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) project_state_init(C, OBACT, &ps); - if(ps.ob==NULL || ps.ob->type != OB_MESH) { + if (ps.ob==NULL || ps.ob->type != OB_MESH) { BKE_report(op->reports, RPT_ERROR, "No active mesh object"); return OPERATOR_CANCELLED; } - if(image==NULL) { + if (image==NULL) { BKE_report(op->reports, RPT_ERROR, "Image could not be found"); return OPERATOR_CANCELLED; } @@ -5624,31 +5629,31 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ps.reproject_image= image; ps.reproject_ibuf= BKE_image_get_ibuf(image, NULL); - if(ps.reproject_ibuf==NULL || ps.reproject_ibuf->rect==NULL) { + if (ps.reproject_ibuf==NULL || ps.reproject_ibuf->rect==NULL) { BKE_report(op->reports, RPT_ERROR, "Image data could not be found"); return OPERATOR_CANCELLED; } idgroup= IDP_GetProperties(&image->id, 0); - if(idgroup) { + if (idgroup) { view_data= IDP_GetPropertyTypeFromGroup(idgroup, PROJ_VIEW_DATA_ID, IDP_ARRAY); /* type check to make sure its ok */ - if(view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) { + if (view_data->len != PROJ_VIEW_DATA_SIZE || view_data->subtype != IDP_FLOAT) { BKE_report(op->reports, RPT_ERROR, "Image project data invalid"); return OPERATOR_CANCELLED; } } - if(view_data) { + if (view_data) { /* image has stored view projection info */ ps.source= PROJ_SRC_IMAGE_VIEW; } else { ps.source= PROJ_SRC_IMAGE_CAM; - if(scene->camera==NULL) { + if (scene->camera==NULL) { BKE_report(op->reports, RPT_ERROR, "No active camera set"); return OPERATOR_CANCELLED; } @@ -5670,7 +5675,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) /* allocate and initialize spacial data structures */ project_paint_begin(&ps); - if(ps.dm==NULL) { + if (ps.dm==NULL) { brush_set_size(scene, ps.brush, orig_brush_size); return OPERATOR_CANCELLED; } @@ -5738,11 +5743,11 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxsize); - if(w > maxsize) w= maxsize; - if(h > maxsize) h= maxsize; + if (w > maxsize) w= maxsize; + if (h > maxsize) h= maxsize; ibuf= ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, err_out); - if(!ibuf) { + if (!ibuf) { /* Mostly happens when OpenGL offscreen buffer was failed to create, */ /* but could be other reasons. Should be handled in the future. nazgul */ BKE_reportf(op->reports, RPT_ERROR, "Failed to create OpenGL offscreen buffer: %s", err_out); @@ -5751,7 +5756,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) image= BKE_add_image_imbuf(ibuf); - if(image) { + if (image) { /* now for the trickyness. store the view projection here! * re-projection will reuse this */ View3D *v3d= CTX_wm_view3d(C); diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 86af3505f65..046a3b374ba 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -175,9 +175,9 @@ static int brush_reset_exec(bContext *C, wmOperator *UNUSED(op)) struct Brush *brush = paint_brush(paint); Object *ob = CTX_data_active_object(C); - if(!ob) return OPERATOR_CANCELLED; + if (!ob) return OPERATOR_CANCELLED; - if(ob->mode & OB_MODE_SCULPT) + if (ob->mode & OB_MODE_SCULPT) brush_reset_sculpt(brush); /* TODO: other modes */ @@ -208,15 +208,15 @@ static Brush *brush_tool_cycle(Main *bmain, Brush *brush_orig, const int tool, c { struct Brush *brush; - if(!brush_orig && !(brush_orig= bmain->brush.first)) { + if (!brush_orig && !(brush_orig= bmain->brush.first)) { return NULL; } /* get the next brush with the active tool */ - for(brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; + for (brush= brush_orig->id.next ? brush_orig->id.next : bmain->brush.first; brush != brush_orig; brush= brush->id.next ? brush->id.next : bmain->brush.first) { - if((brush->ob_mode & ob_mode) && + if ((brush->ob_mode & ob_mode) && (brush_tool(brush, tool_offset) == tool)) { return brush; } @@ -231,7 +231,7 @@ static int brush_generic_tool_set(Main *bmain, Paint *paint, const int tool, con brush= brush_tool_cycle(bmain, brush_orig, tool, tool_offset, ob_mode); - if(brush) { + if (brush) { paint_brush_set(paint, brush); WM_main_add_notifier(NC_BRUSH|NA_EDITED, brush); return OPERATOR_FINISHED; @@ -252,7 +252,7 @@ static int brush_select_exec(bContext *C, wmOperator *op) int tool, paint_mode= RNA_enum_get(op->ptr, "paint_mode"); size_t tool_offset; - if(paint_mode == OB_MODE_ACTIVE) { + if (paint_mode == OB_MODE_ACTIVE) { /* select current paint mode */ paint_mode = CTX_data_active_object(C)->mode & (OB_MODE_SCULPT| @@ -487,7 +487,7 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint, brush_path = BLI_sprintfN("tool_settings.%s.brush", paint); set_brush_rc_path(ptr, brush_path, "data_path_primary", prop); - if(secondary_prop) { + if (secondary_prop) { set_brush_rc_path(ptr, ups_path, "use_secondary", secondary_prop); set_brush_rc_path(ptr, ups_path, "data_path_secondary", prop); } @@ -499,11 +499,11 @@ static void set_brush_rc_props(PointerRNA *ptr, const char *paint, set_brush_rc_path(ptr, brush_path, "rotation_path", "texture_slot.angle"); RNA_string_set(ptr, "image_id", brush_path); - if(flags & RC_COLOR) + if (flags & RC_COLOR) set_brush_rc_path(ptr, brush_path, "fill_color_path", "color"); else RNA_string_set(ptr, "fill_color_path", ""); - if(flags & RC_ZOOM) + if (flags & RC_ZOOM) RNA_string_set(ptr, "zoom_path", "space_data.zoom"); else RNA_string_set(ptr, "zoom_path", ""); @@ -522,7 +522,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_SHIFT, 0); set_brush_rc_props(kmi->ptr, paint, "strength", "use_unified_strength", flags); - if(flags & RC_ROTATION) { + if (flags & RC_ROTATION) { kmi = WM_keymap_add_item(keymap, "WM_OT_radial_control", FKEY, KM_PRESS, KM_CTRL, 0); set_brush_rc_props(kmi->ptr, paint, "texture_slot.angle", NULL, flags); } @@ -561,7 +561,7 @@ void ED_keymap_paint(wmKeyConfig *keyconf) /* Partial visibility, sculpt-only for now */ paint_partial_visibility_keys(keymap); - for(i=0; i<=5; i++) + for (i=0; i<=5; i++) RNA_int_set(WM_keymap_add_item(keymap, "OBJECT_OT_subdivision_set", ZEROKEY+i, KM_PRESS, KM_CTRL, 0)->ptr, "level", i); /* multires switch */ diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index d306abef9d0..28fee887cd8 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -95,7 +95,7 @@ static void paint_draw_smooth_stroke(bContext *C, int x, int y, void *customdata glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - if(stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { + if (stroke && brush && (brush->flag & BRUSH_SMOOTH_STROKE)) { ARegion *ar = CTX_wm_region(C); sdrawline(x, y, (int)stroke->last_mouse_position[0] - ar->winrct.xmin, (int)stroke->last_mouse_position[1] - ar->winrct.ymin); @@ -112,14 +112,14 @@ static float event_tablet_data(wmEvent *event, int *pen_flip) int erasor = 0; float pressure = 1; - if(event->custom == EVT_DATA_TABLET) { + if (event->custom == EVT_DATA_TABLET) { wmTabletData *wmtab= event->customdata; erasor = (wmtab->Active == EVT_TABLET_ERASER); pressure = (wmtab->Active != EVT_TABLET_NONE) ? wmtab->Pressure : 1; } - if(pen_flip) + if (pen_flip) (*pen_flip) = erasor; return pressure; @@ -143,7 +143,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* TODO: as sculpt and other paint modes are unified, this * separation will go away */ - if(stroke->vc.obact->sculpt) { + if (stroke->vc.obact->sculpt) { float delta[2]; brush_jitter_pos(scene, brush, mouse_in, mouse); @@ -151,7 +151,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev /* XXX: meh, this is round about because * brush_jitter_pos isn't written in the best way to * be reused here */ - if(brush->flag & BRUSH_JITTER_PRESSURE) { + if (brush->flag & BRUSH_JITTER_PRESSURE) { sub_v2_v2v2(delta, mouse, mouse_in); mul_v2_fl(delta, pressure); add_v2_v2v2(mouse, mouse_in, delta); @@ -162,7 +162,7 @@ static void paint_brush_stroke_add_step(bContext *C, wmOperator *op, wmEvent *ev } /* TODO: can remove the if statement once all modes have this */ - if(stroke->get_location) + if (stroke->get_location) stroke->get_location(C, location, mouse); else zero_v3(location); @@ -197,7 +197,7 @@ static int paint_smooth_stroke(PaintStroke *stroke, float output[2], wmEvent *ev /* If the mouse is moving within the radius of the last move, * don't update the mouse position. This allows sharp turns. */ - if(dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) + if (dx*dx + dy*dy < stroke->brush->smooth_stroke_radius * stroke->brush->smooth_stroke_radius) return 0; output[0] = event->x * v + stroke->last_mouse_position[0] * u; @@ -214,7 +214,7 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const PaintStroke *stroke = op->customdata; int cnt = 0; - if(paint_space_stroke_enabled(stroke->brush)) { + if (paint_space_stroke_enabled(stroke->brush)) { float mouse[2]; float vec[2]; float length, scale; @@ -224,24 +224,24 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const length = len_v2(vec); - if(length > FLT_EPSILON) { + if (length > FLT_EPSILON) { const Scene *scene = CTX_data_scene(C); int steps; int i; float pressure= 1.0f; /* XXX mysterious :) what has 'use size' do with this here... if you don't check for it, pressure fails */ - if(brush_use_size_pressure(scene, stroke->brush)) + if (brush_use_size_pressure(scene, stroke->brush)) pressure = event_tablet_data(event, NULL); - if(pressure > FLT_EPSILON) { + if (pressure > FLT_EPSILON) { scale = (brush_size(scene, stroke->brush)*pressure*stroke->brush->spacing/50.0f) / length; - if(scale > FLT_EPSILON) { + if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); steps = (int)(1.0f / scale); - for(i = 0; i < steps; ++i, ++cnt) { + for (i = 0; i < steps; ++i, ++cnt) { add_v2_v2(mouse, vec); paint_brush_stroke_add_step(C, op, event, mouse); } @@ -302,16 +302,16 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) if (event->type == NDOF_MOTION) return OPERATOR_PASS_THROUGH; - if(!stroke->stroke_started) { + if (!stroke->stroke_started) { stroke->last_mouse_position[0] = event->x; stroke->last_mouse_position[1] = event->y; stroke->stroke_started = stroke->test_start(C, op, event); - if(stroke->stroke_started) { + if (stroke->stroke_started) { stroke->smooth_stroke_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), paint_poll, paint_draw_smooth_stroke, stroke); - if(stroke->brush->flag & BRUSH_AIRBRUSH) + if (stroke->brush->flag & BRUSH_AIRBRUSH) stroke->timer = WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, stroke->brush->rate); } @@ -319,26 +319,26 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) //ED_region_tag_redraw(ar); } - if(event->type == stroke->event_type && event->val == KM_RELEASE) { + if (event->type == stroke->event_type && event->val == KM_RELEASE) { /* exit stroke, free data */ - if(stroke->smooth_stroke_cursor) + if (stroke->smooth_stroke_cursor) WM_paint_cursor_end(CTX_wm_manager(C), stroke->smooth_stroke_cursor); - if(stroke->timer) + if (stroke->timer) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), stroke->timer); stroke->done(C, stroke); MEM_freeN(stroke); return OPERATOR_FINISHED; } - else if( (first) || + else if ( (first) || (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) || (event->type == TIMER && (event->customdata == stroke->timer)) ) { - if(stroke->stroke_started) { - if(paint_smooth_stroke(stroke, mouse, event)) { - if(paint_space_stroke_enabled(stroke->brush)) { - if(!paint_space_stroke(C, op, event, mouse)) { + if (stroke->stroke_started) { + if (paint_smooth_stroke(stroke, mouse, event)) { + if (paint_space_stroke_enabled(stroke->brush)) { + if (!paint_space_stroke(C, op, event, mouse)) { //ED_region_tag_redraw(ar); } } @@ -354,7 +354,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, wmEvent *event) /* we want the stroke to have the first daub at the start location * instead of waiting till we have moved the space distance */ - if(first && + if (first && stroke->stroke_started && paint_space_stroke_enabled(stroke->brush) && !(stroke->brush->flag & BRUSH_ANCHORED) && @@ -371,7 +371,7 @@ int paint_stroke_exec(bContext *C, wmOperator *op) PaintStroke *stroke = op->customdata; /* only when executed for the first time */ - if(stroke->stroke_started == 0) { + if (stroke->stroke_started == 0) { /* XXX stroke->last_mouse_position is unset, this may cause problems */ stroke->test_start(C, op, NULL); stroke->stroke_started= 1; @@ -394,7 +394,7 @@ int paint_stroke_cancel(bContext *C, wmOperator *op) { PaintStroke *stroke = op->customdata; - if(stroke->done) + if (stroke->done) stroke->done(C, stroke); MEM_freeN(stroke); diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c index b00910195ff..8406c8b20af 100644 --- a/source/blender/editors/sculpt_paint/paint_undo.c +++ b/source/blender/editors/sculpt_paint/paint_undo.c @@ -71,13 +71,13 @@ static UndoStack MeshUndoStack = {UNDO_PAINT_MESH, {NULL, NULL}, NULL}; static void undo_restore(bContext *C, UndoStack *UNUSED(stack), UndoElem *uel) { - if(uel && uel->restore) + if (uel && uel->restore) uel->restore(C, &uel->elems); } static void undo_elem_free(UndoStack *UNUSED(stack), UndoElem *uel) { - if(uel && uel->free) { + if (uel && uel->free) { uel->free(&uel->elems); BLI_freelistN(&uel->elems); } @@ -93,7 +93,7 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor * know how much memory the undo used to remove old undo elements */ /* remove all undos after (also when stack->current==NULL) */ - while(stack->elems.last != stack->current) { + while (stack->elems.last != stack->current) { uel= stack->elems.last; undo_elem_free(stack, uel); BLI_freelinkN(&stack->elems, uel); @@ -111,13 +111,13 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor /* limit amount to the maximum amount*/ nr= 0; uel= stack->elems.last; - while(uel) { + while (uel) { nr++; - if(nr==U.undosteps) break; + if (nr==U.undosteps) break; uel= uel->prev; } - if(uel) { - while(stack->elems.first!=uel) { + if (uel) { + while (stack->elems.first!=uel) { UndoElem *first= stack->elems.first; undo_elem_free(stack, first); BLI_freelinkN(&stack->elems, first); @@ -130,20 +130,20 @@ static void undo_stack_push_end(UndoStack *stack) UndoElem *uel; uintptr_t totmem, maxmem; - if(U.undomemory != 0) { + if (U.undomemory != 0) { /* limit to maximum memory (afterwards, we can't know in advance) */ totmem= 0; maxmem= ((uintptr_t)U.undomemory)*1024*1024; uel= stack->elems.last; - while(uel) { + while (uel) { totmem+= uel->undosize; - if(totmem>maxmem) break; + if (totmem>maxmem) break; uel= uel->prev; } - if(uel) { - while(stack->elems.first!=uel) { + if (uel) { + while (stack->elems.first!=uel) { UndoElem *first= stack->elems.first; undo_elem_free(stack, first); BLI_freelinkN(&stack->elems, first); @@ -156,25 +156,25 @@ static int undo_stack_step(bContext *C, UndoStack *stack, int step, const char * { UndoElem *undo; - if(step==1) { - if(stack->current==NULL); + if (step==1) { + if (stack->current==NULL); else { - if(!name || strcmp(stack->current->name, name) == 0) { - if(G.f & G_DEBUG) printf("undo %s\n", stack->current->name); + if (!name || strcmp(stack->current->name, name) == 0) { + if (G.f & G_DEBUG) printf("undo %s\n", stack->current->name); undo_restore(C, stack, stack->current); stack->current= stack->current->prev; return 1; } } } - else if(step==-1) { - if((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL); + else if (step==-1) { + if ((stack->current!=NULL && stack->current->next==NULL) || stack->elems.first==NULL); else { - if(!name || strcmp(stack->current->name, name) == 0) { + if (!name || strcmp(stack->current->name, name) == 0) { undo= (stack->current && stack->current->next)? stack->current->next: stack->elems.first; undo_restore(C, stack, undo); stack->current= undo; - if(G.f & G_DEBUG) printf("redo %s\n", undo->name); + if (G.f & G_DEBUG) printf("redo %s\n", undo->name); return 1; } } @@ -187,7 +187,7 @@ static void undo_stack_free(UndoStack *stack) { UndoElem *uel; - for(uel=stack->elems.first; uel; uel=uel->next) + for (uel=stack->elems.first; uel; uel=uel->next) undo_elem_free(stack, uel); BLI_freelistN(&stack->elems); @@ -198,20 +198,20 @@ static void undo_stack_free(UndoStack *stack) void undo_paint_push_begin(int type, const char *name, UndoRestoreCb restore, UndoFreeCb free) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) undo_stack_push_begin(&ImageUndoStack, name, restore, free); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) undo_stack_push_begin(&MeshUndoStack, name, restore, free); } ListBase *undo_paint_push_get_list(int type) { - if(type == UNDO_PAINT_IMAGE) { - if(ImageUndoStack.current) + if (type == UNDO_PAINT_IMAGE) { + if (ImageUndoStack.current) return &ImageUndoStack.current->elems; } - else if(type == UNDO_PAINT_MESH) { - if(MeshUndoStack.current) + else if (type == UNDO_PAINT_MESH) { + if (MeshUndoStack.current) return &MeshUndoStack.current->elems; } @@ -220,25 +220,25 @@ ListBase *undo_paint_push_get_list(int type) void undo_paint_push_count_alloc(int type, int size) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) ImageUndoStack.current->undosize += size; - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) MeshUndoStack.current->undosize += size; } void undo_paint_push_end(int type) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) undo_stack_push_end(&ImageUndoStack); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) undo_stack_push_end(&MeshUndoStack); } int ED_undo_paint_step(bContext *C, int type, int step, const char *name) { - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) return undo_stack_step(C, &ImageUndoStack, step, name); - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) return undo_stack_step(C, &MeshUndoStack, step, name); return 0; @@ -248,16 +248,16 @@ int ED_undo_paint_valid(int type, const char *name) { UndoStack *stack; - if(type == UNDO_PAINT_IMAGE) + if (type == UNDO_PAINT_IMAGE) stack= &ImageUndoStack; - else if(type == UNDO_PAINT_MESH) + else if (type == UNDO_PAINT_MESH) stack= &MeshUndoStack; else return 0; - if(stack->current==NULL); + if (stack->current==NULL); else { - if(name && strcmp(stack->current->name, name) == 0) + if (name && strcmp(stack->current->name, name) == 0) return 1; else return stack->elems.first != stack->elems.last; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 3cd963c11df..3508f8e7f11 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -84,14 +84,14 @@ int paint_convert_bb_to_rect(rcti *rect, rect->xmax = rect->ymax = INT_MIN; /* return zero if the bounding box has non-positive volume */ - if(bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) + if (bb_min[0] > bb_max[0] || bb_min[1] > bb_max[1] || bb_min[2] > bb_max[2]) return 0; ED_view3d_ob_project_mat_get(rv3d, ob, projection_mat); - for(i = 0; i < 2; ++i) { - for(j = 0; j < 2; ++j) { - for(k = 0; k < 2; ++k) { + for (i = 0; i < 2; ++i) { + for (j = 0; j < 2; ++j) { + for (k = 0; k < 2; ++k) { float vec[3], proj[2]; vec[0] = i ? bb_min[0] : bb_max[0]; vec[1] = j ? bb_min[1] : bb_max[1]; @@ -243,7 +243,7 @@ static void imapaint_tri_weights(Object *ob, /* w is still divided by perspdiv, make it sum to one */ divw= w[0] + w[1] + w[2]; - if(divw != 0.0f) { + if (divw != 0.0f) { mul_v3_fl(w, 1.0f/divw); } } @@ -263,16 +263,16 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in uv[0] = uv[1] = 0.0; /* test all faces in the derivedmesh with the original index of the picked face */ - for(a = 0; a < numfaces; a++) { + for (a = 0; a < numfaces; a++) { findex= index ? index[a]: a; - if(findex == faceindex) { + if (findex == faceindex) { dm->getTessFace(dm, a, &mf); dm->getVert(dm, mf.v1, &mv[0]); dm->getVert(dm, mf.v2, &mv[1]); dm->getVert(dm, mf.v3, &mv[2]); - if(mf.v4) + if (mf.v4) dm->getVert(dm, mf.v4, &mv[3]); tf= &tface[a]; @@ -280,12 +280,12 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in p[0]= xy[0]; p[1]= xy[1]; - if(mf.v4) { + if (mf.v4) { /* the triangle with the largest absolute values is the one * with the most negative weights */ imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[3].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[3][0]*w[2]; uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[3][1]*w[2]; minabsw = absw; @@ -293,7 +293,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in imapaint_tri_weights(ob, mv[1].co, mv[2].co, mv[3].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[1][0]*w[0] + tf->uv[2][0]*w[1] + tf->uv[3][0]*w[2]; uv[1]= tf->uv[1][1]*w[0] + tf->uv[2][1]*w[1] + tf->uv[3][1]*w[2]; minabsw = absw; @@ -302,7 +302,7 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in else { imapaint_tri_weights(ob, mv[0].co, mv[1].co, mv[2].co, p, w); absw= fabs(w[0]) + fabs(w[1]) + fabs(w[2]); - if(absw < minabsw) { + if (absw < minabsw) { uv[0]= tf->uv[0][0]*w[0] + tf->uv[1][0]*w[1] + tf->uv[2][0]*w[2]; uv[1]= tf->uv[0][1]*w[0] + tf->uv[1][1]*w[1] + tf->uv[2][1]*w[2]; minabsw = absw; @@ -317,13 +317,13 @@ void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const in ///* returns 0 if not found, otherwise 1 */ int imapaint_pick_face(ViewContext *vc, Mesh *me, const int mval[2], unsigned int *index) { - if(!me || me->totface==0) + if (!me || me->totface==0) return 0; /* sample only on the exact position */ *index = view3d_sample_backbuf(vc, mval[0], mval[1]); - if((*index)<=0 || (*index)>(unsigned int)me->totface) + if ((*index)<=0 || (*index)>(unsigned int)me->totface) return 0; (*index)--; @@ -347,7 +347,7 @@ void paint_sample_color(Scene *scene, ARegion *ar, int x, int y) /* frontbuf */ cp = (char *)&col; - if(br) { + if (br) { br->rgb[0]= cp[0]/255.0f; br->rgb[1]= cp[1]/255.0f; br->rgb[2]= cp[2]/255.0f; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index cb920e3f048..59c034f1cd1 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -129,12 +129,12 @@ int vertex_paint_mode_poll(bContext *C) int vertex_paint_poll(bContext *C) { - if(vertex_paint_mode_poll(C) && + if (vertex_paint_mode_poll(C) && paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa= CTX_wm_area(C); - if(sa->spacetype==SPACE_VIEW3D) { + if (sa->spacetype==SPACE_VIEW3D) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype==RGN_TYPE_WINDOW) + if (ar->regiontype==RGN_TYPE_WINDOW) return 1; } } @@ -153,14 +153,14 @@ int weight_paint_poll(bContext *C) Object *ob= CTX_data_active_object(C); ScrArea *sa; - if( (ob != NULL) && + if ( (ob != NULL) && (ob->mode & OB_MODE_WEIGHT_PAINT) && (paint_brush(&CTX_data_tool_settings(C)->wpaint->paint) != NULL) && (sa= CTX_wm_area(C)) && (sa->spacetype == SPACE_VIEW3D) ) { ARegion *ar= CTX_wm_region(C); - if(ar->regiontype==RGN_TYPE_WINDOW) { + if (ar->regiontype==RGN_TYPE_WINDOW) { return 1; } } @@ -173,7 +173,7 @@ static VPaint *new_vpaint(int wpaint) vp->flag= VP_AREA+VP_SPRAY; - if(wpaint) + if (wpaint) vp->flag= VP_AREA; return vp; @@ -203,33 +203,33 @@ static void do_shared_vertex_tesscol(Mesh *me) short *scolmain, *scol; char *mcol; - if(me->mcol==NULL || me->totvert==0 || me->totface==0) return; + if (me->mcol==NULL || me->totvert==0 || me->totface==0) return; scolmain= MEM_callocN(4*sizeof(short)*me->totvert, "colmain"); tface= me->mtface; mface= me->mface; mcol= (char *)me->mcol; - for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { + for (a=me->totface; a>0; a--, mface++, mcol+=16) { + if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; scol[0]++; scol[1]+= mcol[1]; scol[2]+= mcol[2]; scol[3]+= mcol[3]; scol= scolmain+4*mface->v2; scol[0]++; scol[1]+= mcol[5]; scol[2]+= mcol[6]; scol[3]+= mcol[7]; scol= scolmain+4*mface->v3; scol[0]++; scol[1]+= mcol[9]; scol[2]+= mcol[10]; scol[3]+= mcol[11]; - if(mface->v4) { + if (mface->v4) { scol= scolmain+4*mface->v4; scol[0]++; scol[1]+= mcol[13]; scol[2]+= mcol[14]; scol[3]+= mcol[15]; } } - if(tface) tface++; + if (tface) tface++; } a= me->totvert; scol= scolmain; - while(a--) { - if(scol[0]>1) { + while (a--) { + if (scol[0]>1) { scol[1]/= scol[0]; scol[2]/= scol[0]; scol[3]/= scol[0]; @@ -240,20 +240,20 @@ static void do_shared_vertex_tesscol(Mesh *me) tface= me->mtface; mface= me->mface; mcol= (char *)me->mcol; - for(a=me->totface; a>0; a--, mface++, mcol+=16) { - if((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { + for (a=me->totface; a>0; a--, mface++, mcol+=16) { + if ((tface && tface->mode & TF_SHAREDCOL) || (me->editflag & ME_EDIT_PAINT_MASK)==0) { scol= scolmain+4*mface->v1; mcol[1]= scol[1]; mcol[2]= scol[2]; mcol[3]= scol[3]; scol= scolmain+4*mface->v2; mcol[5]= scol[1]; mcol[6]= scol[2]; mcol[7]= scol[3]; scol= scolmain+4*mface->v3; mcol[9]= scol[1]; mcol[10]= scol[2]; mcol[11]= scol[3]; - if(mface->v4) { + if (mface->v4) { scol= scolmain+4*mface->v4; mcol[13]= scol[1]; mcol[14]= scol[2]; mcol[15]= scol[3]; } } - if(tface) tface++; + if (tface) tface++; } MEM_freeN(scolmain); @@ -271,7 +271,7 @@ void do_shared_vertexcol(Mesh *me, int do_tessface) /* if no mloopcol: do not do */ /* if mtexpoly: only the involved faces, otherwise all */ - if(me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return; + if (me->mloopcol==0 || me->totvert==0 || me->totpoly==0) return; scol = MEM_callocN(sizeof(float)*me->totvert*5, "scol"); @@ -324,14 +324,14 @@ void do_shared_vertexcol(Mesh *me, int do_tessface) static void make_vertexcol(Object *ob) /* single ob */ { Mesh *me; - if(!ob || ob->id.lib) return; + if (!ob || ob->id.lib) return; me= get_mesh(ob); - if(me==NULL) return; - if(me->edit_btmesh) return; + if (me==NULL) return; + if (me->edit_btmesh) return; /* copies from shadedisplist to mcol */ if (!me->mloopcol) { - if(!me->mcol) { + if (!me->mcol) { CustomData_add_layer(&me->fdata, CD_MCOL, CD_DEFAULT, NULL, me->totface); } if (!me->mloopcol) { @@ -372,21 +372,21 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) { bDeformGroup *defgroup= BLI_findlink(&ob->defbase, vgroup_active); - if(defgroup) { + if (defgroup) { bDeformGroup *curdef; int mirrdef; char name[MAXBONENAME]; flip_side_name(name, defgroup->name, FALSE); - if(strcmp(name, defgroup->name) != 0) { + if (strcmp(name, defgroup->name) != 0) { for (curdef= ob->defbase.first, mirrdef= 0; curdef; curdef=curdef->next, mirrdef++) { if (!strcmp(curdef->name, name)) { break; } } - if(curdef==NULL) { + if (curdef==NULL) { int olddef= ob->actdef; /* tsk, ED_vgroup_add sets the active defgroup */ curdef= ED_vgroup_add_name(ob, name); ob->actdef= olddef; @@ -394,7 +394,7 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) /* curdef should never be NULL unless this is * a lamp and ED_vgroup_add_name fails */ - if(curdef) { + if (curdef) { return mirrdef; } } @@ -405,13 +405,13 @@ static int wpaint_mirror_vgroup_ensure(Object *ob, const int vgroup_active) static void copy_vpaint_prev(VPaint *vp, unsigned int *lcol, int tot) { - if(vp->vpaint_prev) { + if (vp->vpaint_prev) { MEM_freeN(vp->vpaint_prev); vp->vpaint_prev= NULL; } vp->tot= tot; - if(lcol==NULL || tot==0) return; + if (lcol==NULL || tot==0) return; vp->vpaint_prev= MEM_mallocN(sizeof(int)*tot, "vpaint_prev"); memcpy(vp->vpaint_prev, lcol, sizeof(int)*tot); @@ -425,7 +425,7 @@ static void copy_wpaint_prev (VPaint *wp, MDeformVert *dverts, int dcount) wp->wpaint_prev= NULL; } - if(dverts && dcount) { + if (dverts && dcount) { wp->wpaint_prev = MEM_mallocN (sizeof(MDeformVert)*dcount, "wpaint prev"); wp->tot = dcount; @@ -442,10 +442,10 @@ void vpaint_fill(Object *ob, unsigned int paintcol) int i, j, selected; me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return; + if (me==NULL || me->totpoly==0) return; - if(!me->mloopcol) make_vertexcol(ob); - if(!me->mloopcol) return; /* possible we can't make mcol's */ + if (!me->mloopcol) make_vertexcol(ob); + if (!me->mloopcol) return; /* possible we can't make mcol's */ selected= (me->editflag & ME_EDIT_PAINT_MASK); @@ -480,18 +480,18 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) /* mutually exclusive, could be made into a */ const short paint_selmode= ME_EDIT_PAINT_SEL_MODE(me); - if(me->totpoly==0 || me->dvert==NULL || !me->mpoly) return; + if (me->totpoly==0 || me->dvert==NULL || !me->mpoly) return; vgroup_active = ob->actdef - 1; /* if mirror painting, find the other group */ - if(me->editflag & ME_EDIT_MIRROR_X) { + if (me->editflag & ME_EDIT_MIRROR_X) { vgroup_mirror= wpaint_mirror_vgroup_ensure(ob, vgroup_active); } copy_wpaint_prev(wp, me->dvert, me->totvert); - for(index=0, mf= me->mpoly; index < me->totpoly; index++, mf++) { + for (index=0, mf= me->mpoly; index < me->totpoly; index++, mf++) { unsigned int fidx= mf->totloop - 1; if ((paint_selmode == SCE_SELECT_FACE) && !(mf->flag & ME_FACE_SEL)) { @@ -501,25 +501,26 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) do { unsigned int vidx= me->mloop[mf->loopstart + fidx].v; - if(!me->dvert[vidx].flag) { - if((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) { + if (!me->dvert[vidx].flag) { + if ((paint_selmode == SCE_SELECT_VERTEX) && !(me->mvert[vidx].flag & SELECT)) { continue; } dw= defvert_verify_index(&me->dvert[vidx], vgroup_active); - if(dw) { + if (dw) { dw_prev= defvert_verify_index(wp->wpaint_prev+vidx, vgroup_active); dw_prev->weight= dw->weight; /* set the undo weight */ dw->weight= paintweight; - if(me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */ + if (me->editflag & ME_EDIT_MIRROR_X) { /* x mirror painting */ int j= mesh_get_x_mirror_vert(ob, vidx); - if(j>=0) { + if (j>=0) { /* copy, not paint again */ - if(vgroup_mirror != -1) { + if (vgroup_mirror != -1) { dw= defvert_verify_index(me->dvert+j, vgroup_mirror); dw_prev= defvert_verify_index(wp->wpaint_prev+j, vgroup_mirror); - } else { + } + else { dw= defvert_verify_index(me->dvert+j, vgroup_active); dw_prev= defvert_verify_index(wp->wpaint_prev+j, vgroup_active); } @@ -536,7 +537,7 @@ void wpaint_fill(VPaint *wp, Object *ob, float paintweight) { MDeformVert *dv= me->dvert; - for(index= me->totvert; index != 0; index--, dv++) { + for (index= me->totvert; index != 0; index--, dv++) { dv->flag= 0; } } @@ -560,25 +561,25 @@ void vpaint_dogamma(Scene *scene) ob= OBACT; me= get_mesh(ob); - if(!(ob->mode & OB_MODE_VERTEX_PAINT)) return; - if(me==0 || me->mcol==0 || me->totface==0) return; + if (!(ob->mode & OB_MODE_VERTEX_PAINT)) return; + if (me==0 || me->mcol==0 || me->totface==0) return; igam= 1.0/vp->gamma; - for(a=0; a<256; a++) { + for (a=0; a<256; a++) { fac= ((float)a)/255.0; fac= vp->mul*pow( fac, igam); temp= 255.9*fac; - if(temp<=0) gamtab[a]= 0; - else if(temp>=255) gamtab[a]= 255; + if (temp<=0) gamtab[a]= 0; + else if (temp>=255) gamtab[a]= 255; else gamtab[a]= temp; } a= 4*me->totface; cp= (unsigned char *)me->mcol; - while(a--) { + while (a--) { cp[1]= gamtab[ cp[1] ]; cp[2]= gamtab[ cp[2] ]; @@ -787,7 +788,7 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo col = vpaint_blend_tool(tool, col, paintcol, alpha_i); /* if no spray, clip color adding with colorig & orig alpha */ - if((vp->flag & VP_SPRAY)==0) { + if ((vp->flag & VP_SPRAY)==0) { unsigned int testcol, a; char *cp, *ct, *co; @@ -797,14 +798,14 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo ct= (char *)&testcol; co= (char *)&colorig; - for(a=0; a<4; a++) { - if( ct[a]<co[a] ) { - if( cp[a]<ct[a] ) cp[a]= ct[a]; - else if( cp[a]>co[a] ) cp[a]= co[a]; + for (a=0; a<4; a++) { + if ( ct[a]<co[a] ) { + if ( cp[a]<ct[a] ) cp[a]= ct[a]; + else if ( cp[a]>co[a] ) cp[a]= co[a]; } else { - if( cp[a]<co[a] ) cp[a]= co[a]; - else if( cp[a]>ct[a] ) cp[a]= ct[a]; + if ( cp[a]<co[a] ) cp[a]= co[a]; + else if ( cp[a]>ct[a] ) cp[a]= ct[a]; } } } @@ -823,25 +824,25 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totface, int x /*if(size>64.0) size= 64.0;*/ ibuf= view3d_read_backbuf(vc, x-size, y-size, x+size, y+size); - if(ibuf) { + if (ibuf) { unsigned int *rt= ibuf->rect; memset(indexar, 0, sizeof(int)*(totface+1)); size= ibuf->x*ibuf->y; - while(size--) { + while (size--) { - if(*rt) { + if (*rt) { index= WM_framebuffer_to_index(*rt); - if(index>0 && index<=totface) + if (index>0 && index<=totface) indexar[index] = 1; } rt++; } - for(a=1; a<=totface; a++) { - if(indexar[a]) indexar[tot++]= a; + for (a=1; a<=totface; a++) { + if (indexar[a]) indexar[tot++]= a; } IMB_freeImBuf(ibuf); @@ -880,7 +881,7 @@ static float calc_vp_alpha_dl(VPaint *vp, ViewContext *vc, if (strength > 0.0f) { float alpha= brush_alpha_pressure * strength; - if(vp->flag & VP_NORMALS) { + if (vp->flag & VP_NORMALS) { float dvec[3]; const float *no= vert_nor + 3; @@ -978,19 +979,19 @@ static float wpaint_blend(VPaint *wp, float weight, float weight_prev, weight = wpaint_blend_tool(tool, weight, paintval, alpha); /* delay clamping until the end so multi-paint can function when the active group is at the limits */ - if(do_multipaint_totsel == FALSE) { + if (do_multipaint_totsel == FALSE) { CLAMP(weight, 0.0f, 1.0f); } /* if no spray, clip result with orig weight & orig alpha */ if ((wp->flag & VP_SPRAY) == 0) { - if(do_multipaint_totsel == FALSE) { + if (do_multipaint_totsel == FALSE) { float testw = wpaint_blend_tool(tool, weight_prev, paintval, brush_alpha_value); CLAMP(testw, 0.0f, 1.0f); if (testw < weight_prev) { - if(weight < testw) weight = testw; - else if(weight > weight_prev) weight = weight_prev; + if (weight < testw) weight = testw; + else if (weight > weight_prev) weight = weight_prev; } else { if (weight > testw) weight = testw; @@ -1023,10 +1024,10 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) index= view3d_sample_backbuf(&vc, event->mval[0], event->mval[1]); - if(index && index<=me->totpoly) { + if (index && index<=me->totpoly) { DerivedMesh *dm= mesh_get_derived_final(vc.scene, vc.obact, CD_MASK_BAREMESH); - if(dm->getVertCo==NULL) { + if (dm->getVertCo==NULL) { BKE_report(op->reports, RPT_WARNING, "The modifier used does not support deformed locations"); } else { @@ -1048,13 +1049,13 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) dm->getVertCo(dm, v_idx, co); project_float_noclip(vc.ar, co, sco); len= len_squared_v2v2(mval_f, sco); - if(len < len_best) { + if (len < len_best) { len_best= len; v_idx_best= v_idx; } } while (fidx--); - if(v_idx_best != -1) { /* should always be valid */ + if (v_idx_best != -1) { /* should always be valid */ ts->vgroup_weight= defvert_find_weight(&me->dvert[v_idx_best], vgroup_active); change= TRUE; } @@ -1063,7 +1064,7 @@ static int weight_sample_invoke(bContext *C, wmOperator *op, wmEvent *event) } } - if(change) { + if (change) { /* not really correct since the brush didnt change, but redraws the toolbar */ WM_main_add_notifier(NC_BRUSH|NA_EDITED, NULL); /* ts->wpaint->paint.brush */ @@ -1093,7 +1094,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA { if (C) { wmWindow *win= CTX_wm_window(C); - if(win && win->eventstate) { + if (win && win->eventstate) { ViewContext vc; Mesh *me; @@ -1107,9 +1108,9 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA index= view3d_sample_backbuf(&vc, win->eventstate->x - vc.ar->winrct.xmin, win->eventstate->y - vc.ar->winrct.ymin); - if(index && index<=me->totpoly) { + if (index && index<=me->totpoly) { const int defbase_tot= BLI_countlist(&vc.obact->defbase); - if(defbase_tot) { + if (defbase_tot) { MPoly *mf= ((MPoly *)me->mpoly) + index-1; unsigned int fidx= mf->totloop - 1; int *groups= MEM_callocN(defbase_tot*sizeof(int), "groups"); @@ -1119,7 +1120,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA MDeformVert *dvert= me->dvert + me->mloop[mf->loopstart + fidx].v; int i= dvert->totweight; MDeformWeight *dw; - for(dw= dvert->dw; i > 0; dw++, i--) { + for (dw= dvert->dw; i > 0; dw++, i--) { if (dw->def_nr < defbase_tot) { groups[dw->def_nr]= TRUE; found= TRUE; @@ -1127,7 +1128,7 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA } } while (fidx--); - if(found==FALSE) { + if (found==FALSE) { MEM_freeN(groups); } else { @@ -1135,8 +1136,8 @@ static EnumPropertyItem *weight_paint_sample_enum_itemf(bContext *C, PointerRNA int totitem= 0; int i= 0; bDeformGroup *dg; - for(dg= vc.obact->defbase.first; dg && i<defbase_tot; i++, dg= dg->next) { - if(groups[i]) { + for (dg= vc.obact->defbase.first; dg && i<defbase_tot; i++, dg= dg->next) { + if (groups[i]) { item_tmp.identifier= item_tmp.name= dg->name; item_tmp.value= i; RNA_enum_item_add(&item, &totitem, &item_tmp); @@ -1324,7 +1325,7 @@ static char *gen_lock_flags(Object* ob, int defbase_tot) char *lock_flags = MEM_mallocN(defbase_tot*sizeof(char), "defflags"); bDeformGroup *defgroup; - for(i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { + for (i = 0, defgroup = ob->defbase.first; i < defbase_tot && defgroup; defgroup = defgroup->next, i++) { lock_flags[i] = ((defgroup->flag & DG_LOCK_WEIGHT) != 0); is_locked |= lock_flags[i]; } @@ -1339,8 +1340,8 @@ static char *gen_lock_flags(Object* ob, int defbase_tot) static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, const char *lock_flags) { int i; - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i] && lock_flags[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i] && lock_flags[i]) { return TRUE; } } @@ -1352,11 +1353,11 @@ static int has_locked_group_selected(int defbase_tot, const char *defbase_sel, c static int has_unselected_unlocked_bone_group(int defbase_tot, char *defbase_sel, int selected, char *lock_flags, char *vgroup_validmap) { int i; - if(defbase_tot == selected) { + if (defbase_tot == selected) { return FALSE; } - for(i = 0; i < defbase_tot; i++) { - if(vgroup_validmap[i] && !defbase_sel[i] && !lock_flags[i]) { + for (i = 0; i < defbase_tot; i++) { + if (vgroup_validmap[i] && !defbase_sel[i] && !lock_flags[i]) { return TRUE; } } @@ -1371,12 +1372,12 @@ static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, floa MDeformWeight *dw; float val; /* make sure they are all at most 1 after the change */ - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i]) { dw = defvert_find_index(dvert, i); - if(dw && dw->weight) { + if (dw && dw->weight) { val = dw->weight * change; - if(val > 1) { + if (val > 1) { /* TODO: when the change is reduced, you need to recheck * the earlier values to make sure they are not 0 * (precision error) */ @@ -1384,17 +1385,17 @@ static void multipaint_selection(MDeformVert *dvert, const int defbase_tot, floa } /* the value should never reach zero while multi-painting if it * was nonzero beforehand */ - if(val <= 0) { + if (val <= 0) { return; } } } } /* apply the valid change */ - for(i = 0; i < defbase_tot; i++) { - if(defbase_sel[i]) { + for (i = 0; i < defbase_tot; i++) { + if (defbase_sel[i]) { dw = defvert_find_index(dvert, i); - if(dw && dw->weight) { + if (dw && dw->weight) { dw->weight = dw->weight * change; } } @@ -1419,24 +1420,24 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, was_change = FALSE; /* change each group by the same amount each time */ change = totchange/total_valid; - for(i = 0; i < ndv->totweight && total_valid && totchange; i++) { + for (i = 0; i < ndv->totweight && total_valid && totchange; i++) { ndw = (ndv->dw+i); /* ignore anything outside the value range */ if (ndw->def_nr < defbase_tot) { /* change only the groups with a valid status */ - if(change_status[ndw->def_nr] == change_me) { + if (change_status[ndw->def_nr] == change_me) { oldval = ndw->weight; /* if auto normalize is active, don't worry about upper bounds */ - if(do_auto_normalize == FALSE && ndw->weight + change > 1) { + if (do_auto_normalize == FALSE && ndw->weight + change > 1) { totchange -= 1-ndw->weight; ndw->weight = 1; /* stop the changes to this group */ change_status[ndw->def_nr] = changeto; total_valid--; } - else if(ndw->weight + change < 0) { /* check the lower bound */ + else if (ndw->weight + change < 0) { /* check the lower bound */ totchange -= ndw->weight; ndw->weight = 0; change_status[ndw->def_nr] = changeto; @@ -1447,7 +1448,7 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, ndw->weight += change; } /* see if there was a change */ - if(oldval != ndw->weight) { + if (oldval != ndw->weight) { was_change = TRUE; } } @@ -1455,7 +1456,7 @@ static float redistribute_change(MDeformVert *ndv, const int defbase_tot, } /* don't go again if there was no change, if there is no valid group, * or there is no change left */ - } while(was_change && total_valid && totchange); + } while (was_change && total_valid && totchange); /* left overs */ return totchange; } @@ -1482,17 +1483,17 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, char *change_status; - if(!lock_flags || !has_locked_group(ndv, defbase_tot, vgroup_validmap, lock_flags)) { + if (!lock_flags || !has_locked_group(ndv, defbase_tot, vgroup_validmap, lock_flags)) { return; } /* record if a group was changed, unlocked and not changed, or locked */ change_status = MEM_callocN(sizeof(char)*defbase_tot, "unlocked_unchanged"); - for(i = 0; i < defbase_tot; i++) { + for (i = 0; i < defbase_tot; i++) { ndw = defvert_find_index(ndv, i); odw = defvert_find_index(odv, i); /* the weights are zero, so we can assume a lot */ - if(!ndw || !odw) { + if (!ndw || !odw) { if (!lock_flags[i] && vgroup_validmap[i]) { defvert_verify_index(odv, i); defvert_verify_index(ndv, i); @@ -1502,10 +1503,10 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, continue; } /* locked groups should not be changed */ - if(lock_flags[i]) { + if (lock_flags[i]) { ndw->weight = odw->weight; } - else if(ndw->weight != odw->weight) { /* changed groups are handled here */ + else if (ndw->weight != odw->weight) { /* changed groups are handled here */ totchange += ndw->weight - odw->weight; changed_sum += ndw->weight; change_status[i] = 2; /* was altered already */ @@ -1518,26 +1519,26 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, } } /* if there was any change, redistribute it */ - if(total_changed) { + if (total_changed) { /* auto normalize will allow weights to temporarily go above 1 in redistribution */ - if(vgroup_validmap && total_changed < 0 && total_valid) { + if (vgroup_validmap && total_changed < 0 && total_valid) { totchange_allowed = total_valid; } /* the way you modify the unlocked+unchanged groups is different depending * on whether or not you are painting the weight(s) up or down */ - if(totchange < 0) { + if (totchange < 0) { totchange_allowed = total_valid - totchange_allowed; } else { totchange_allowed *= -1; } /* there needs to be change allowed, or you should not bother */ - if(totchange_allowed) { + if (totchange_allowed) { left_over = 0; - if(fabsf(totchange_allowed) < fabsf(totchange)) { + if (fabsf(totchange_allowed) < fabsf(totchange)) { /* this amount goes back onto the changed, unlocked weights */ left_over = fabsf(fabsf(totchange) - fabsf(totchange_allowed)); - if(totchange > 0) { + if (totchange > 0) { left_over *= -1; } } @@ -1548,9 +1549,9 @@ static void enforce_locks(MDeformVert *odv, MDeformVert *ndv, /* move the weight evenly between the allowed groups, move excess back onto the used groups based on the change */ totchange_allowed = redistribute_change(ndv, defbase_tot, change_status, 1, -1, totchange_allowed, total_valid, do_auto_normalize); left_over += totchange_allowed; - if(left_over) { + if (left_over) { /* more than one nonzero weights were changed with the same ratio with multipaint, so keep them changed that way! */ - if(total_changed > 1 && do_multipaint) { + if (total_changed > 1 && do_multipaint) { float undo_change = get_mp_change(ndv, defbase_tot, defbase_sel, left_over); multipaint_selection(ndv, defbase_tot, undo_change, defbase_sel); } @@ -1584,12 +1585,12 @@ static float get_mp_change(MDeformVert *odv, const int defbase_tot, const char * for (i= odv->totweight; i != 0; i--, dw++) { if (dw->def_nr < defbase_tot) { - if(defbase_sel[dw->def_nr]) { + if (defbase_sel[dw->def_nr]) { selwsum += dw->weight; } } } - if(selwsum && selwsum+brush_change > 0) { + if (selwsum && selwsum+brush_change > 0) { return (selwsum+brush_change)/selwsum; } return 0.0f; @@ -1672,8 +1673,8 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, ((wpi->lock_flags[dw->def_nr] == FALSE) && /* def_nr range has to be checked for by caller */ has_locked_group_selected(wpi->defbase_tot, wpi->defbase_sel, wpi->lock_flags) == FALSE)) { - if(wpi->do_multipaint && wpi->defbase_tot_sel > 1) { - if(change && change!=1) { + if (wpi->do_multipaint && wpi->defbase_tot_sel > 1) { + if (change && change!=1) { multipaint_selection(dv, wpi->defbase_tot, change, wpi->defbase_sel); } } @@ -1690,16 +1691,16 @@ static int apply_mp_locks_normalize(Mesh *me, const WeightPaintInfo *wpi, do_weight_paint_normalize_all(dv, wpi->defbase_tot, wpi->vgroup_validmap); } - if(oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) { - if(tdw->weight != oldw) { - if(neww > oldw) { - if(tdw->weight <= oldw) { + if (oldChange && wpi->do_multipaint && wpi->defbase_tot_sel > 1) { + if (tdw->weight != oldw) { + if (neww > oldw) { + if (tdw->weight <= oldw) { MEM_freeN(dv_test.dw); return TRUE; } } else { - if(tdw->weight >= oldw) { + if (tdw->weight >= oldw) { MEM_freeN(dv_test.dw); return TRUE; } @@ -1716,7 +1717,7 @@ static int get_first_selected_nonzero_weight(MDeformVert *dvert, const int defba { int i; MDeformWeight *dw= dvert->dw; - for(i=0; i< dvert->totweight; i++, dw++) { + for (i=0; i< dvert->totweight; i++, dw++) { if (dw->def_nr < defbase_tot) { if (defbase_sel[dw->def_nr] && dw->weight > 0.0f) { return i; @@ -1750,7 +1751,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert const short do_multipaint_totsel = (wpi->do_multipaint && wpi->defbase_tot_sel > 1); - if(wp->flag & VP_ONLYVGROUP) { + if (wp->flag & VP_ONLYVGROUP) { dw= defvert_find_index(dv, wpi->vgroup_active); dw_prev= defvert_find_index(wp->wpaint_prev+index, wpi->vgroup_active); } @@ -1759,7 +1760,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert dw_prev= defvert_verify_index(wp->wpaint_prev+index, wpi->vgroup_active); } - if(dw==NULL || dw_prev==NULL) { + if (dw==NULL || dw_prev==NULL) { return; } @@ -1829,7 +1830,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert * can give wrong results [#26193], least confusing if normalize is done last */ /* apply mirror */ - if(index_mirr != -1) { + if (index_mirr != -1) { /* copy, not paint again */ dw_mirr->weight = dw->weight; } @@ -1899,10 +1900,10 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert tdw = dw; tdw_prev = dw_prev; change = get_mp_change(&wp->wpaint_prev[index], wpi->defbase_tot, wpi->defbase_sel, neww - oldw); - if(change) { - if(!tdw->weight) { + if (change) { + if (!tdw->weight) { i = get_first_selected_nonzero_weight(dv, wpi->defbase_tot, wpi->defbase_sel); - if(i>=0) { + if (i>=0) { tdw = &(dv->dw[i]); tdw_prev = defvert_verify_index(&wp->wpaint_prev[index], tdw->def_nr); } @@ -1910,12 +1911,12 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert change = 0; } } - if(change && tdw_prev->weight && tdw_prev->weight * change) { - if(tdw->weight != tdw_prev->weight) { + if (change && tdw_prev->weight && tdw_prev->weight * change) { + if (tdw->weight != tdw_prev->weight) { oldChange = tdw->weight/tdw_prev->weight; testw = tdw_prev->weight*change; - if( testw > tdw_prev->weight ) { - if(change > oldChange) { + if ( testw > tdw_prev->weight ) { + if (change > oldChange) { /* reset the weights and use the new change */ defvert_reset_to_prev(wp->wpaint_prev+index, dv); } @@ -1926,7 +1927,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert } } else { - if(change < oldChange) { + if (change < oldChange) { defvert_reset_to_prev(wp->wpaint_prev+index, dv); } else { @@ -1941,12 +1942,12 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert } } - if(apply_mp_locks_normalize(me, wpi, index, dw, tdw, change, oldChange, oldw, neww)) { + if (apply_mp_locks_normalize(me, wpi, index, dw, tdw, change, oldChange, oldw, neww)) { defvert_reset_to_prev(&dv_copy, dv); change = 0; oldChange = 0; } - if(dv_copy.dw) { + if (dv_copy.dw) { MEM_freeN(dv_copy.dw); } #if 0 @@ -1959,7 +1960,7 @@ static void do_weight_paint_vertex(/* vars which remain the same for every vert #endif /* x mirror painting */ - if(index_mirr != -1) { + if (index_mirr != -1) { /* copy, not paint again */ /* dw_mirr->weight = dw->weight; */ /* TODO, explain the logic in not assigning weight! - campbell */ @@ -1979,9 +1980,9 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ Mesh *me; me= get_mesh(ob); - if(ob->id.lib || me==NULL) return OPERATOR_PASS_THROUGH; + if (ob->id.lib || me==NULL) return OPERATOR_PASS_THROUGH; - if(ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; + if (ob->mode & OB_MODE_WEIGHT_PAINT) ob->mode &= ~OB_MODE_WEIGHT_PAINT; else ob->mode |= OB_MODE_WEIGHT_PAINT; @@ -1992,10 +1993,10 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ */ DAG_id_tag_update(&me->id, 0); - if(ob->mode & OB_MODE_WEIGHT_PAINT) { + if (ob->mode & OB_MODE_WEIGHT_PAINT) { Object *par; - if(wp==NULL) + if (wp==NULL) wp= scene->toolsettings->wpaint= new_vpaint(1); paint_init(&wp->paint, PAINT_CURSOR_WEIGHT_PAINT); @@ -2005,10 +2006,10 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ /* verify if active weight group is also active bone */ par= modifiers_isDeformedByArmature(ob); - if(par && (par->mode & OB_MODE_POSE)) { + if (par && (par->mode & OB_MODE_POSE)) { bArmature *arm= par->data; - if(arm->act_bone) + if (arm->act_bone) ED_vgroup_select_by_name(ob, arm->act_bone->name); } } @@ -2026,11 +2027,11 @@ static int set_wpaint(bContext *C, wmOperator *UNUSED(op)) /* toggle */ static int paint_poll_test(bContext *C) { Object *ob= CTX_data_active_object(C); - if(CTX_data_edit_object(C)) + if (CTX_data_edit_object(C)) return 0; - if(CTX_data_active_object(C)==NULL) + if (CTX_data_active_object(C)==NULL) return 0; - if(!ob->data || ((ID *)ob->data)->lib) + if (!ob->data || ((ID *)ob->data)->lib) return 0; return 1; } @@ -2075,7 +2076,7 @@ static char *wpaint_make_validmap(Object *ob) GHash *gh; int i, step1=1; - if(ob->defbase.first == NULL) { + if (ob->defbase.first == NULL) { return NULL; } @@ -2094,7 +2095,7 @@ static char *wpaint_make_validmap(Object *ob) if (md->type == eModifierType_Armature) { ArmatureModifierData *amd= (ArmatureModifierData*) md; - if(amd->object && amd->object->pose) { + if (amd->object && amd->object->pose) { bPose *pose= amd->object->pose; bPoseChannel *chan; @@ -2138,12 +2139,12 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED float mat[4][4], imat[4][4]; - if(scene->obedit) { + if (scene->obedit) { return FALSE; } me= get_mesh(ob); - if(me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; + if (me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; /* if nothing was added yet, we make dverts and a vertex deform group */ if (!me->dvert) { @@ -2154,14 +2155,14 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED /* this happens on a Bone select, when no vgroup existed yet */ if (ob->actdef <= 0) { Object *modob; - if((modob = modifiers_isDeformedByArmature(ob))) { + if ((modob = modifiers_isDeformedByArmature(ob))) { Bone *actbone= ((bArmature *)modob->data)->act_bone; - if(actbone) { + if (actbone) { bPoseChannel *pchan= get_pose_channel(modob->pose, actbone->name); - if(pchan) { + if (pchan) { bDeformGroup *dg= defgroup_find_name(ob, pchan->name); - if(dg==NULL) { + if (dg==NULL) { dg= ED_vgroup_add_name(ob, pchan->name); /* sets actdef */ } else { @@ -2173,7 +2174,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED } } } - if(ob->defbase.first==NULL) { + if (ob->defbase.first==NULL) { ED_vgroup_add(ob); } @@ -2219,7 +2220,7 @@ static int wpaint_stroke_test_start(bContext *C, wmOperator *op, wmEvent *UNUSED copy_m3_m4(wpd->wpimat, imat); /* if mirror painting, find the other group */ - if(me->editflag & ME_EDIT_MIRROR_X) { + if (me->editflag & ME_EDIT_MIRROR_X) { wpd->vgroup_mirror = wpaint_mirror_vgroup_ensure(ob, wpd->vgroup_active); } @@ -2283,7 +2284,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P defbase_sel= MEM_mallocN(wpi.defbase_tot*sizeof(char), "wpi.defbase_sel"); wpi.defbase_tot_sel= get_selected_defgroups(ob, defbase_sel, wpi.defbase_tot); wpi.defbase_sel= defbase_sel; /* so we can stay const */ - if(wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; + if (wpi.defbase_tot_sel == 0 && ob->actdef > 0) wpi.defbase_tot_sel = 1; wpi.defbase_tot_unsel= wpi.defbase_tot - wpi.defbase_tot_sel; wpi.vgroup_active= wpd->vgroup_active; @@ -2303,7 +2304,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P use_vert_sel= (me->editflag & ME_EDIT_VERT_SEL) != 0; /* which faces are involved */ - if(wp->flag & VP_AREA) { + if (wp->flag & VP_AREA) { /* Ugly hack, to avoid drawing vertex index when getting the face index buffer - campbell */ me->editflag &= ~ME_EDIT_VERT_SEL; totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); @@ -2311,28 +2312,28 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; + if (indexar[0]) totindex= 1; else totindex= 0; } - if(wp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (wp->flag & VP_COLINDEX) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if(mpoly->mat_nr!=ob->actcol-1) { + if (mpoly->mat_nr!=ob->actcol-1) { indexar[index]= 0; } } } } - if((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if((mpoly->flag & ME_FACE_SEL)==0) { + if ((mpoly->flag & ME_FACE_SEL)==0) { indexar[index]= 0; } } @@ -2347,13 +2348,13 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P else paintweight= ts->vgroup_weight; - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= me->mpoly + (indexar[index]-1); MLoop *ml = me->mloop + mpoly->loopstart; int i; - if(use_vert_sel) { + if (use_vert_sel) { for (i=0; i<mpoly->totloop; i++, ml++) { me->dvert[ml->v].flag = (me->mvert[ml->v].flag & SELECT); } @@ -2367,7 +2368,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { MDeformWeight *dw, *(*dw_func)(MDeformVert *, const int); - if(wp->flag & VP_ONLYVGROUP) + if (wp->flag & VP_ONLYVGROUP) dw_func= (MDeformWeight *(*)(MDeformVert *, const int))defvert_find_index; else dw_func= defvert_verify_index; @@ -2390,9 +2391,9 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P paintweight /= totw; } - for(index=0; index<totindex; index++) { + for (index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= me->mpoly + (indexar[index]-1); MLoop *ml=me->mloop+mpoly->loopstart; int i; @@ -2403,7 +2404,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if (me->dvert[vidx].flag) { alpha= calc_vp_alpha_dl(wp, vc, wpd->wpimat, wpd->vertexcosnos+6*vidx, mval, brush_size_pressure, brush_alpha_pressure); - if(alpha) { + if (alpha) { do_weight_paint_vertex(wp, ob, &wpi, vidx, alpha, paintweight); } me->dvert[vidx].flag= 0; @@ -2430,14 +2431,14 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) Object *ob= CTX_data_active_object(C); struct WPaintData *wpd= paint_stroke_mode_data(stroke); - if(wpd) { - if(wpd->vertexcosnos) + if (wpd) { + if (wpd->vertexcosnos) MEM_freeN(wpd->vertexcosnos); MEM_freeN(wpd->indexar); if (wpd->vgroup_validmap) MEM_freeN((void *)wpd->vgroup_validmap); - if(wpd->lock_flags) + if (wpd->lock_flags) MEM_freeN((void *)wpd->lock_flags); MEM_freeN(wpd); @@ -2447,13 +2448,13 @@ static void wpaint_stroke_done(bContext *C, struct PaintStroke *stroke) copy_wpaint_prev(ts->wpaint, NULL, 0); /* and particles too */ - if(ob->particlesystem.first) { + if (ob->particlesystem.first) { ParticleSystem *psys; int i; - for(psys= ob->particlesystem.first; psys; psys= psys->next) { - for(i=0; i<PSYS_TOT_VG; i++) { - if(psys->vgroup[i]==ob->actdef) { + for (psys= ob->particlesystem.first; psys; psys= psys->next) { + for (i=0; i<PSYS_TOT_VG; i++) { + if (psys->vgroup[i]==ob->actdef) { psys->recalc |= PSYS_RECALC_RESET; break; } @@ -2543,15 +2544,15 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ me= get_mesh(ob); - if(me==NULL || object_data_is_libdata(ob)) { + if (me==NULL || object_data_is_libdata(ob)) { ob->mode &= ~OB_MODE_VERTEX_PAINT; return OPERATOR_PASS_THROUGH; } - if(me && me->mloopcol==NULL) make_vertexcol(ob); + if (me && me->mloopcol==NULL) make_vertexcol(ob); /* toggle: end vpaint */ - if(ob->mode & OB_MODE_VERTEX_PAINT) { + if (ob->mode & OB_MODE_VERTEX_PAINT) { ob->mode &= ~OB_MODE_VERTEX_PAINT; } @@ -2561,7 +2562,7 @@ static int set_vpaint(bContext *C, wmOperator *op) /* toggle */ if (ob->mode & OB_MODE_WEIGHT_PAINT) set_wpaint(C, op); - if(vp==NULL) + if (vp==NULL) vp= scene->toolsettings->vpaint= new_vpaint(0); paint_cursor_start(C, vertex_paint_poll); @@ -2677,12 +2678,12 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, wmEvent /* context checks could be a poll() */ me= get_mesh(ob); - if(me==NULL || me->totpoly==0) + if (me==NULL || me->totpoly==0) return OPERATOR_PASS_THROUGH; - if(me->mloopcol==NULL) + if (me->mloopcol==NULL) make_vertexcol(ob); - if(me->mloopcol==NULL) + if (me->mloopcol==NULL) return OPERATOR_CANCELLED; /* make mode data storage */ @@ -2733,13 +2734,13 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, int brush_alpha_pressure_i; - if((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) || + if ((vp->flag & VP_COLINDEX && mface->mat_nr!=ob->actcol-1) || ((me->editflag & ME_EDIT_PAINT_MASK) && !(mface->flag & ME_FACE_SEL))) return; if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { unsigned int fcol1= mcol_blend( mcol[0], mcol[1], 128); - if(mface->v4) { + if (mface->v4) { unsigned int fcol2= mcol_blend( mcol[2], mcol[3], 128); vpd->paintcol= mcol_blend( fcol1, fcol2, 128); } @@ -2750,7 +2751,7 @@ static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f); - for(i = 0; i < (mface->v4 ? 4 : 3); ++i) { + for (i = 0; i < (mface->v4 ? 4 : 3); ++i) { alpha = calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*(&mface->v1)[i], mval, brush_size_pressure, brush_alpha_pressure); if (alpha) { @@ -2785,7 +2786,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, int brush_alpha_pressure_i = (int)(brush_alpha_pressure*255.0f); - if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) { + if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { unsigned int blend[4] = {0}; unsigned int tcol; char *col; @@ -2816,7 +2817,7 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, alpha= calc_vp_alpha_dl(vp, vc, vpd->vpimat, vpd->vertexcosnos+6*ml->v, mval, brush_size_pressure, brush_alpha_pressure); - if(alpha > 0.0f) { + if (alpha > 0.0f) { const int alpha_i = (int)(alpha*255.0f); lcol[i] = vpaint_blend(vp, lcol[i], lcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i); } @@ -2888,34 +2889,34 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* which faces are involved */ - if(vp->flag & VP_AREA) { + if (vp->flag & VP_AREA) { totindex= sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); } else { indexar[0]= view3d_sample_backbuf(vc, mval[0], mval[1]); - if(indexar[0]) totindex= 1; + if (indexar[0]) totindex= 1; else totindex= 0; } - if(vp->flag & VP_COLINDEX) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (vp->flag & VP_COLINDEX) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if(mpoly->mat_nr!=ob->actcol-1) { + if (mpoly->mat_nr!=ob->actcol-1) { indexar[index]= 0; } } } } - if((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { - for(index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if ((me->editflag & ME_EDIT_PAINT_MASK) && me->mpoly) { + for (index=0; index<totindex; index++) { + if (indexar[index] && indexar[index]<=me->totpoly) { MPoly *mpoly= ((MPoly *)me->mpoly) + (indexar[index]-1); - if((mpoly->flag & ME_FACE_SEL)==0) + if ((mpoly->flag & ME_FACE_SEL)==0) indexar[index]= 0; } } @@ -2924,9 +2925,9 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); - for(index=0; index<totindex; index++) { + for (index=0; index<totindex; index++) { - if(indexar[index] && indexar[index]<=me->totpoly) { + if (indexar[index] && indexar[index]<=me->totpoly) { vpaint_paint_poly(vp, vpd, ob, indexar[index]-1, mval, brush_size_pressure, brush_alpha_pressure, flip); } } @@ -2934,7 +2935,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); /* was disabled because it is slow, but necessary for blur */ - if(brush->vertexpaint_tool == PAINT_BLEND_BLUR) { + if (brush->vertexpaint_tool == PAINT_BLEND_BLUR) { int do_tessface = vpd->use_fast_update; do_shared_vertexcol(me, do_tessface); } @@ -2953,7 +2954,7 @@ static void vpaint_stroke_done(bContext *C, struct PaintStroke *stroke) ToolSettings *ts= CTX_data_tool_settings(C); struct VPaintData *vpd= paint_stroke_mode_data(stroke); - if(vpd->vertexcosnos) + if (vpd->vertexcosnos) MEM_freeN(vpd->vertexcosnos); MEM_freeN(vpd->indexar); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index dcb832ec31f..319570cf65e 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -97,7 +97,7 @@ void ED_sculpt_force_update(bContext *C) { Object *ob= CTX_data_active_object(C); - if(ob && (ob->mode & OB_MODE_SCULPT)) + if (ob && (ob->mode & OB_MODE_SCULPT)) multires_force_update(ob); } @@ -108,19 +108,19 @@ struct MultiresModifierData *sculpt_multires_active(Scene *scene, Object *ob) Mesh *me= (Mesh*)ob->data; ModifierData *md; - if(!CustomData_get_layer(&me->ldata, CD_MDISPS)) { + if (!CustomData_get_layer(&me->ldata, CD_MDISPS)) { /* multires can't work without displacement layer */ return NULL; } - for(md= modifiers_getVirtualModifierList(ob); md; md= md->next) { - if(md->type == eModifierType_Multires) { + for (md= modifiers_getVirtualModifierList(ob); md; md= md->next) { + if (md->type == eModifierType_Multires) { MultiresModifierData *mmd= (MultiresModifierData*)md; - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(mmd->sculptlvl > 0) return mmd; + if (mmd->sculptlvl > 0) return mmd; else return NULL; } } @@ -136,8 +136,8 @@ static int sculpt_has_active_modifiers(Scene *scene, Object *ob) md= modifiers_getVirtualModifierList(ob); /* exception for shape keys because we can edit those */ - for(; md; md= md->next) { - if(modifier_isEnabled(scene, md, eModifierMode_Realtime)) + for (; md; md= md->next) { + if (modifier_isEnabled(scene, md, eModifierMode_Realtime)) return 1; } @@ -151,22 +151,22 @@ static int sculpt_modifiers_active(Scene *scene, Sculpt *sd, Object *ob) Mesh *me= (Mesh*)ob->data; MultiresModifierData *mmd= sculpt_multires_active(scene, ob); - if(mmd) return 0; + if (mmd) return 0; /* non-locked shape keys could be handled in the same way as deformed mesh */ - if((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr) + if ((ob->shapeflag&OB_SHAPE_LOCK)==0 && me->key && ob->shapenr) return 1; md= modifiers_getVirtualModifierList(ob); /* exception for shape keys because we can edit those */ - for(; md; md= md->next) { + for (; md; md= md->next) { ModifierTypeInfo *mti = modifierType_getInfo(md->type); - if(!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; - if(md->type==eModifierType_ShapeKey) continue; + if (!modifier_isEnabled(scene, md, eModifierMode_Realtime)) continue; + if (md->type==eModifierType_ShapeKey) continue; - if(mti->type==eModifierTypeType_OnlyDeform) return 1; - else if((sd->flags & SCULPT_ONLY_DEFORM)==0) return 1; + if (mti->type==eModifierTypeType_OnlyDeform) return 1; + else if ((sd->flags & SCULPT_ONLY_DEFORM)==0) return 1; } return 0; @@ -254,13 +254,13 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, PBVH *pbvh= ob->sculpt->pbvh; float bb_min[3], bb_max[3]; - if(!pbvh) + if (!pbvh) return 0; BLI_pbvh_redraw_BB(pbvh, bb_min, bb_max); /* convert 3D bounding box to screen space */ - if(!paint_convert_bb_to_rect(rect, + if (!paint_convert_bb_to_rect(rect, bb_min, bb_max, ar, @@ -276,8 +276,8 @@ static int sculpt_get_redraw_rect(ARegion *ar, RegionView3D *rv3d, * optimized PBVH draw function and 3d view redraw (if not -- some * mesh parts could disappear from screen (sergey) */ ss = ob->sculpt; - if(ss->cache) { - if(!BLI_rcti_is_empty(&ss->cache->previous_r)) + if (ss->cache) { + if (!BLI_rcti_is_empty(&ss->cache->previous_r)) BLI_union_rcti(rect, &ss->cache->previous_r); } @@ -295,7 +295,7 @@ void sculpt_get_redraw_planes(float planes[4][4], ARegion *ar, paint_calc_redraw_planes(planes, ar, rv3d, ob, &rect); /* clear redraw flag from nodes */ - if(pbvh) + if (pbvh) BLI_pbvh_update(pbvh, PBVH_UpdateRedraw, NULL); } @@ -318,7 +318,7 @@ static int sculpt_brush_test(SculptBrushTest *test, float co[3]) { float distsq = len_squared_v3v3(co, test->location); - if(distsq <= test->radius_squared) { + if (distsq <= test->radius_squared) { test->dist = sqrt(distsq); return 1; } @@ -331,7 +331,7 @@ static int sculpt_brush_test_sq(SculptBrushTest *test, float co[3]) { float distsq = len_squared_v3v3(co, test->location); - if(distsq <= test->radius_squared) { + if (distsq <= test->radius_squared) { test->dist = distsq; return 1; } @@ -451,7 +451,7 @@ static float integrate_overlap(Brush* br) float max; max= 0; - for(i= 0; i < m; i++) { + for (i= 0; i < m; i++) { float overlap= overlapped_curve(br, i*g); if (overlap > max) @@ -464,15 +464,15 @@ static float integrate_overlap(Brush* br) /* Uses symm to selectively flip any axis of a coordinate. */ static void flip_coord(float out[3], float in[3], const char symm) { - if(symm & SCULPT_SYMM_X) + if (symm & SCULPT_SYMM_X) out[0]= -in[0]; else out[0]= in[0]; - if(symm & SCULPT_SYMM_Y) + if (symm & SCULPT_SYMM_Y) out[1]= -in[1]; else out[1]= in[1]; - if(symm & SCULPT_SYMM_Z) + if (symm & SCULPT_SYMM_Z) out[2]= -in[2]; else out[2]= in[2]; @@ -486,7 +486,7 @@ static float calc_overlap(StrokeCache *cache, const char symm, const char axis, /* flip_coord(mirror, cache->traced_location, symm); */ flip_coord(mirror, cache->true_location, symm); - if(axis != 0) { + if (axis != 0) { float mat[4][4]= MAT4_UNITY; rotate_m4(mat, axis, angle); mul_m4_v3(mat, mirror); @@ -507,7 +507,7 @@ static float calc_radial_symmetry_feather(Sculpt *sd, StrokeCache *cache, const float overlap; overlap = 0; - for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + for (i = 1; i < sd->radial_symm[axis-'X']; ++i) { const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; overlap += calc_overlap(cache, symm, axis, angle); } @@ -524,7 +524,7 @@ static float calc_symmetry_feather(Sculpt *sd, StrokeCache* cache) overlap = 0; for (i = 0; i <= symm; i++) { - if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { overlap += calc_overlap(cache, i, 0, 0); @@ -565,7 +565,7 @@ static float brush_strength(Sculpt *sd, StrokeCache *cache, float feather) (brush->spacing < 100)) ? 1.0f/accum : 1; float flip = dir * invert * pen_flip; - switch(brush->sculpt_tool){ + switch(brush->sculpt_tool) { case SCULPT_TOOL_CLAY: case SCULPT_TOOL_CLAY_STRIPS: case SCULPT_TOOL_DRAW: @@ -638,10 +638,10 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], MTex *mtex = &br->mtex; float avg= 1; - if(!mtex->tex) { + if (!mtex->tex) { avg= 1; } - else if(mtex->brush_map_mode == MTEX_MAP_MODE_3D) { + else if (mtex->brush_map_mode == MTEX_MAP_MODE_3D) { float jnk; /* Get strength by feeding the vertex @@ -649,7 +649,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], externtex(mtex, point, &avg, &jnk, &jnk, &jnk, &jnk, 0); } - else if(ss->texcache) { + else if (ss->texcache) { float rotation = -mtex->rot; float symm_point[3], point_2d[2]; float x, y; @@ -668,7 +668,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); /* if fixed mode, keep coordinates relative to mouse */ - if(mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { + if (mtex->brush_map_mode == MTEX_MAP_MODE_FIXED) { rotation += ss->cache->special_rotation; point_2d[0] -= ss->cache->tex_mouse[0]; @@ -746,15 +746,15 @@ static int sculpt_search_sphere_cb(PBVHNode *node, void *data_v) float t[3], bb_min[3], bb_max[3]; int i; - if(data->original) + if (data->original) BLI_pbvh_node_get_original_BB(node, bb_min, bb_max); else BLI_pbvh_node_get_BB(node, bb_min, bb_max); - for(i = 0; i < 3; ++i) { - if(bb_min[i] > center[i]) + for (i = 0; i < 3; ++i) { + if (bb_min[i] > center[i]) nearest[i] = bb_min[i]; - else if(bb_max[i] < center[i]) + else if (bb_max[i] < center[i]) nearest[i] = bb_max[i]; else nearest[i] = center[i]; @@ -770,11 +770,11 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va { int i; - for(i=0; i<3; ++i) { - if(sd->flags & (SCULPT_LOCK_X << i)) + for (i=0; i<3; ++i) { + if (sd->flags & (SCULPT_LOCK_X << i)) continue; - if((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) + if ((ss->cache->flag & (CLIP_X << i)) && (fabsf(co[i]) <= ss->cache->clip_tolerance[i])) co[i]= 0.0f; else co[i]= val[i]; @@ -783,9 +783,10 @@ static void sculpt_clip(Sculpt *sd, SculptSession *ss, float *co, const float va static void add_norm_if(float view_vec[3], float out[3], float out_flip[3], float fno[3]) { - if((dot_v3v3(view_vec, fno)) > 0) { + if ((dot_v3v3(view_vec, fno)) > 0) { add_v3_v3(out, fno); - } else { + } + else { add_v3_v3(out_flip, fno); /* out_flip is used when out is {0,0,0} */ } } @@ -802,7 +803,7 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod zero_v3(an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -812,9 +813,9 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { float fno[3]; normal_short_to_float_v3(fno, unode->no[vd.i]); @@ -825,8 +826,8 @@ static void calc_area_normal(Sculpt *sd, Object *ob, float an[3], PBVHNode **nod } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { - if(vd.no) { + if (sculpt_brush_test_fast(&test, vd.co)) { + if (vd.no) { float fno[3]; normal_short_to_float_v3(fno, vd.no); @@ -915,14 +916,14 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) zero_v3(avg); /* Don't modify corner vertices */ - if(vert_map->count > 1) { + if (vert_map->count > 1) { int i, total = 0; - for(i = 0; i < vert_map->count; i++) { + for (i = 0; i < vert_map->count; i++) { const MPoly *p= &ss->mpoly[vert_map->indices[i]]; unsigned f_adj_v[3]; - if(poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { + if (poly_get_adj_loops_from_vert(f_adj_v, p, ss->mloop, vert) != -1) { int j; for (j = 0; j < 3; j++) { @@ -936,7 +937,7 @@ static void neighbor_average(SculptSession *ss, float avg[3], unsigned vert) } } - if(total > 0) { + if (total > 0) { mul_v3_fl(avg, 1.0f / total); return; } @@ -956,7 +957,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float avg[3], val[3]; @@ -969,7 +970,7 @@ static void do_mesh_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *node, sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -999,7 +1000,7 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no tmprow= MEM_mallocN(sizeof(float)*3*gridsize, "tmprow"); } - for(i = 0; i < totgrid; ++i) { + for (i = 0; i < totgrid; ++i) { data = griddata[grid_indices[i]]; adj = &gridadj[grid_indices[i]]; @@ -1028,29 +1029,29 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no } /* blend with existing coordinates */ - for(y = 0; y < gridsize; ++y) { - for(x = 0; x < gridsize; ++x) { + for (y = 0; y < gridsize; ++y) { + for (x = 0; x < gridsize; ++x) { float *co; float *fno; int index; - if(x == 0 && adj->index[0] == -1) + if (x == 0 && adj->index[0] == -1) continue; - if(x == gridsize - 1 && adj->index[2] == -1) + if (x == gridsize - 1 && adj->index[2] == -1) continue; - if(y == 0 && adj->index[3] == -1) + if (y == 0 && adj->index[3] == -1) continue; - if(y == gridsize - 1 && adj->index[1] == -1) + if (y == gridsize - 1 && adj->index[1] == -1) continue; index = x + y*gridsize; co= data[index].co; fno= data[index].no; - if(sculpt_brush_test(&test, co)) { + if (sculpt_brush_test(&test, co)) { const float fade = bstrength*tex_strength(ss, brush, co, test.dist, ss->cache->view_normal, NULL, fno); float *avg, val[3]; @@ -1060,10 +1061,10 @@ static void do_multires_smooth_brush(Sculpt *sd, SculptSession *ss, PBVHNode *no n = 1/16.0f; - if(x == 0 || x == gridsize - 1) + if (x == 0 || x == gridsize - 1) n *= 2; - if(y == 0 || y == gridsize - 1) + if (y == 0 || y == gridsize - 1) n *= 2; mul_v3_fl(avg, n); @@ -1099,17 +1100,17 @@ static void smooth(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float count = (int)(bstrength*max_iterations); last = max_iterations*(bstrength - count*fract); - for(iteration = 0; iteration <= count; ++iteration) { + for (iteration = 0; iteration <= count; ++iteration) { #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { - if(ss->multires) { + for (n=0; n<totnode; n++) { + if (ss->multires) { do_multires_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } - else if(ss->pmap) + else if (ss->pmap) do_mesh_smooth_brush(sd, ss, nodes[n], iteration != count ? 1.0f : last); } - if(ss->multires) + if (ss->multires) multires_stitch_grids(ob); } } @@ -1137,7 +1138,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) /* threaded loop over nodes */ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1154,7 +1155,7 @@ static void do_draw_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], offset, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1181,7 +1182,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* we divide out the squared alpha and multiply by the squared crease to give us the pinch strength */ - if(brush_alpha(scene, brush) > 0.0f) + if (brush_alpha(scene, brush) > 0.0f) crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor/(brush_alpha(scene, brush)*brush_alpha(scene, brush)); else crease_correction = brush->crease_pinch_factor*brush->crease_pinch_factor; @@ -1189,11 +1190,11 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod /* we always want crease to pinch or blob to relax even when draw is negative */ flippedbstrength = (bstrength < 0) ? -crease_correction*bstrength : crease_correction*bstrength; - if(brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f; + if (brush->sculpt_tool == SCULPT_TOOL_BLOB) flippedbstrength *= -1.0f; /* threaded loop over nodes */ #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1203,7 +1204,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { /* offset vertex */ const float fade = tex_strength(ss, brush, vd.co, test.dist, area_normal, vd.no, vd.fno); @@ -1219,7 +1220,7 @@ static void do_crease_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod add_v3_v3v3(proxy[vd.i], val1, val2); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1235,7 +1236,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode int n; #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1245,7 +1246,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float val[3]; @@ -1253,7 +1254,7 @@ static void do_pinch_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sub_v3_v3v3(val, test.location, vd.co); mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1289,7 +1290,7 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) } #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1306,13 +1307,13 @@ static void do_grab_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1338,7 +1339,7 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode cross_v3_v3v3(cono, tmp, an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1348,13 +1349,13 @@ static void do_nudge_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], cono, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1388,7 +1389,7 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to } #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1398,13 +1399,13 @@ static void do_snake_hook_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int to sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, an, vd.no, vd.fno); mul_v3_v3fl(proxy[vd.i], grab_delta, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1430,7 +1431,7 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode cross_v3_v3v3(cono, tmp, an); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1447,13 +1448,13 @@ static void do_thumb_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); mul_v3_v3fl(proxy[vd.i], cono, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1484,7 +1485,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_serie_m4(m, lmat, rot, ilmat, NULL, NULL, NULL, NULL, NULL); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptUndoNode* unode; SculptBrushTest test; @@ -1501,7 +1502,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, origco[vd.i], test.dist, an, origno[vd.i], NULL); @@ -1509,7 +1510,7 @@ static void do_rotate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod sub_v3_v3(proxy[vd.i], origco[vd.i]); mul_v3_fl(proxy[vd.i], fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1526,7 +1527,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode float lim= brush->height; int n; - if(bstrength < 0) + if (bstrength < 0) lim = -lim; calc_sculpt_normal(sd, ob, area_normal, nodes, totnode); @@ -1534,7 +1535,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode mul_v3_v3v3(offset, ss->cache->scale, area_normal); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1554,7 +1555,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, origco[vd.i])) { + if (sculpt_brush_test(&test, origco[vd.i])) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, area_normal, vd.no, vd.fno); float *disp= &layer_disp[vd.i]; @@ -1563,12 +1564,12 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode *disp+= fade; /* Don't let the displacement go past the limit */ - if((lim < 0 && *disp < lim) || (lim >= 0 && *disp > lim)) + if ((lim < 0 && *disp < lim) || (lim >= 0 && *disp > lim)) *disp = lim; mul_v3_v3fl(val, offset, *disp); - if(ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { int index= vd.vert_indices[vd.i]; /* persistent base */ @@ -1580,7 +1581,7 @@ static void do_layer_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode sculpt_clip(sd, ss, vd.co, val); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1596,7 +1597,7 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno int n; #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1606,18 +1607,18 @@ static void do_inflate_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno sculpt_brush_test_init(ss, &test); BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test(&test, vd.co)) { + if (sculpt_brush_test(&test, vd.co)) { const float fade = bstrength*tex_strength(ss, brush, vd.co, test.dist, ss->cache->view_normal, vd.no, vd.fno); float val[3]; - if(vd.fno) copy_v3_v3(val, vd.fno); + if (vd.fno) copy_v3_v3(val, vd.fno); else normal_short_to_float_v3(val, vd.no); mul_v3_fl(val, fade * ss->cache->radius); mul_v3_v3v3(proxy[vd.i], val, ss->cache->scale); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -1637,7 +1638,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to zero_v3(fc); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1647,9 +1648,9 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { add_v3_v3(private_fc, unode->co[vd.i]); private_count++; } @@ -1658,7 +1659,7 @@ static void calc_flatten_center(Sculpt *sd, Object *ob, PBVHNode **nodes, int to } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { + if (sculpt_brush_test_fast(&test, vd.co)) { add_v3_v3(private_fc, vd.co); private_count++; } @@ -1700,7 +1701,7 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, zero_v3(fc); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; SculptUndoNode *unode; @@ -1712,9 +1713,9 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, unode = sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS); sculpt_brush_test_init(ss, &test); - if(ss->cache->original) { + if (ss->cache->original) { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, unode->co[vd.i])) { + if (sculpt_brush_test_fast(&test, unode->co[vd.i])) { /* for area normal */ float fno[3]; @@ -1730,9 +1731,9 @@ static void calc_area_normal_and_flatten_center(Sculpt *sd, Object *ob, } else { BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { - if(sculpt_brush_test_fast(&test, vd.co)) { + if (sculpt_brush_test_fast(&test, vd.co)) { /* for area normal */ - if(vd.no) { + if (vd.no) { float fno[3]; normal_short_to_float_v3(fno, vd.no); @@ -1923,7 +1924,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno add_v3_v3(fc, temp); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n = 0; n < totnode; n++) { + for (n = 0; n < totnode; n++) { PBVHVertexIter vd; SculptBrushTest test; float (*proxy)[3]; @@ -1947,7 +1948,7 @@ static void do_flatten_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2020,7 +2021,7 @@ static void do_clay_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2121,7 +2122,7 @@ static void do_clay_strips_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int t mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2184,7 +2185,7 @@ static void do_fill_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode) mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2247,7 +2248,7 @@ static void do_scrape_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnod mul_v3_v3fl(proxy[vd.i], val, fade); - if(vd.mvert) + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } } @@ -2267,7 +2268,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) /* for relative keys editing of base should update other keys */ if (me->key->type == KEY_RELATIVE) for (currkey = me->key->block.first; currkey; currkey= currkey->next) - if(ob->shapenr-1 == currkey->relative) { + if (ob->shapenr-1 == currkey->relative) { is_basis= 1; break; } @@ -2331,7 +2332,7 @@ static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) } /* Apply one type of brush action */ - switch(brush->sculpt_tool){ + switch(brush->sculpt_tool) { case SCULPT_TOOL_DRAW: do_draw_brush(sd, ob, nodes, totnode); break; @@ -2413,7 +2414,7 @@ static void sculpt_flush_pbvhvert_deform(Object *ob, PBVHVertexIter *vd) copy_v3_v3(ss->deform_cos[index], vd->co); copy_v3_v3(ss->orig_cos[index], newco); - if(!ss->kb) + if (!ss->kb) copy_v3_v3(me->mvert[index].co, newco); } @@ -2426,7 +2427,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) BLI_pbvh_gather_proxies(ss->pbvh, &nodes, &totnode); - if(!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { + if (!ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { /* these brushes start from original coordinates */ const int use_orco = (ELEM3(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_ROTATE, SCULPT_TOOL_THUMB)); @@ -2438,7 +2439,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) int proxy_count; float (*orco)[3]; - if(use_orco) + if (use_orco) orco= sculpt_undo_push_node(ob, nodes[n], SCULPT_UNDO_COORDS)->co; BLI_pbvh_node_get_proxies(nodes[n], &proxies, &proxy_count); @@ -2447,7 +2448,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) float val[3]; int p; - if(use_orco) + if (use_orco) copy_v3_v3(val, orco[vd.i]); else copy_v3_v3(val, vd.co); @@ -2457,7 +2458,7 @@ static void sculpt_combine_proxies(Sculpt *sd, Object *ob) sculpt_clip(sd, ss, vd.co, val); - if(ss->modifiers_active) + if (ss->modifiers_active) sculpt_flush_pbvhvert_deform(ob, &vd); } BLI_pbvh_vertex_iter_end; @@ -2478,13 +2479,13 @@ static void sculpt_update_keyblock(Object *ob) /* Keyblock update happens after hadning deformation caused by modifiers, * so ss->orig_cos would be updated with new stroke */ - if(ss->orig_cos) vertCos = ss->orig_cos; + if (ss->orig_cos) vertCos = ss->orig_cos; else vertCos = BLI_pbvh_get_vertCos(ss->pbvh); if (vertCos) { sculpt_vertcos_to_key(ob, ss->kb, vertCos); - if(vertCos != ss->orig_cos) + if (vertCos != ss->orig_cos) MEM_freeN(vertCos); } } @@ -2495,7 +2496,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) SculptSession *ss = ob->sculpt; Brush *brush= paint_brush(&sd->paint); - if(ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { + if (ELEM(brush->sculpt_tool, SCULPT_TOOL_SMOOTH, SCULPT_TOOL_LAYER)) { /* this brushes aren't using proxies, so sculpt_combine_proxies() wouldn't * propagate needed deformation to original base */ @@ -2504,7 +2505,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) PBVHNode** nodes; float (*vertCos)[3]= NULL; - if(ss->kb) + if (ss->kb) vertCos= MEM_callocN(sizeof(*vertCos)*me->totvert, "flushStrokeDeofrm keyVerts"); BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); @@ -2516,7 +2517,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { sculpt_flush_pbvhvert_deform(ob, &vd); - if(vertCos) { + if (vertCos) { int index= vd.vert_indices[vd.i]; copy_v3_v3(vertCos[index], ss->orig_cos[index]); } @@ -2524,7 +2525,7 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) BLI_pbvh_vertex_iter_end; } - if(vertCos) { + if (vertCos) { sculpt_vertcos_to_key(ob, ss->kb, vertCos); MEM_freeN(vertCos); } @@ -2535,8 +2536,10 @@ static void sculpt_flush_stroke_deform(Sculpt *sd, Object *ob) * Note, then if sculpting happens on locked key, normals should be re-calculated * after applying coords from keyblock on base mesh */ mesh_calc_normals(me->mvert, me->totvert, me->mloop, me->mpoly, me->totloop, me->totpoly, NULL); - } else if (ss->kb) + } + else if (ss->kb) { sculpt_update_keyblock(ob); + } } /* Flip all the editdata across the axis/axes specified by symm. Used to @@ -2566,7 +2569,7 @@ static void calc_brushdata_symm(Sculpt *sd, StrokeCache *cache, const char symm, unit_m4(cache->symm_rot_mat); unit_m4(cache->symm_rot_mat_inv); - if(axis) { /* expects XYZ */ + if (axis) { /* expects XYZ */ rotate_m4(cache->symm_rot_mat, axis, angle); rotate_m4(cache->symm_rot_mat_inv, axis, -angle); } @@ -2582,7 +2585,7 @@ static void do_radial_symmetry(Sculpt *sd, Object *ob, Brush *brush, SculptSession *ss = ob->sculpt; int i; - for(i = 1; i < sd->radial_symm[axis-'X']; ++i) { + for (i = 1; i < sd->radial_symm[axis-'X']; ++i) { const float angle = 2*M_PI*i/sd->radial_symm[axis-'X']; ss->cache->radial_symmetry_pass= i; calc_brushdata_symm(sd, ss->cache, symm, axis, angle, feather); @@ -2599,7 +2602,7 @@ static void sculpt_fix_noise_tear(Sculpt *sd, Object *ob) Brush *brush = paint_brush(&sd->paint); MTex *mtex = &brush->mtex; - if(ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) + if (ss->multires && mtex->tex && mtex->tex->type == TEX_NOISE) multires_stitch_grids(ob); } @@ -2618,8 +2621,8 @@ static void do_symmetrical_brush_actions(Sculpt *sd, Object *ob) cache->symmetry= symm; /* symm is a bit combination of XYZ - 1 is mirror X; 2 is Y; 3 is XY; 4 is Z; 5 is XZ; 6 is YZ; 7 is XYZ */ - for(i = 0; i <= symm; ++i) { - if(i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { + for (i = 0; i <= symm; ++i) { + if (i == 0 || (symm & i && (symm != 5 || i != 3) && (symm != 6 || (i != 3 && i != 5)))) { cache->mirror_symmetry_pass= i; cache->radial_symmetry_pass= 0; @@ -2648,14 +2651,14 @@ static void sculpt_update_tex(const Scene *scene, Sculpt *sd, SculptSession *ss) Brush *brush = paint_brush(&sd->paint); const int radius= brush_size(scene, brush); - if(ss->texcache) { + if (ss->texcache) { MEM_freeN(ss->texcache); ss->texcache= NULL; } /* Need to allocate a bigger buffer for bigger brush size */ ss->texcache_side = 2*radius; - if(!ss->texcache || ss->texcache_side > ss->texcache_actual) { + if (!ss->texcache || ss->texcache_side > ss->texcache_actual) { ss->texcache = brush_gen_texture_cache(brush, radius); ss->texcache_actual = ss->texcache_side; } @@ -2669,10 +2672,10 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->modifiers_active= sculpt_modifiers_active(scene, sd, ob); - if(!mmd) ss->kb= ob_get_keyblock(ob); + if (!mmd) ss->kb= ob_get_keyblock(ob); else ss->kb= NULL; - if(mmd) { + if (mmd) { ss->multires = mmd; ss->totvert = dm->getNumVerts(dm); ss->totpoly = dm->getNumPolys(dm); @@ -2698,22 +2701,23 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ ss->pbvh = dm->getPBVH(ob, dm); ss->pmap = (need_pmap && dm->getPolyMap)? dm->getPolyMap(ob, dm): NULL; - if(ss->modifiers_active) { - if(!ss->orig_cos) { + if (ss->modifiers_active) { + if (!ss->orig_cos) { int a; free_sculptsession_deformMats(ss); - if(ss->kb) ss->orig_cos = key_to_vertcos(ob, ss->kb); + if (ss->kb) ss->orig_cos = key_to_vertcos(ob, ss->kb); else ss->orig_cos = mesh_getVertexCos(ob->data, NULL); crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos); BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos); - for(a = 0; a < ((Mesh*)ob->data)->totvert; ++a) + for (a = 0; a < ((Mesh*)ob->data)->totvert; ++a) invert_m3(ss->deform_imats[a]); } - } else free_sculptsession_deformMats(ss); + } + else free_sculptsession_deformMats(ss); /* if pbvh is deformed, key block is already applied to it */ if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) { @@ -2784,7 +2788,7 @@ static const char *sculpt_tool_name(Sculpt *sd) static void sculpt_cache_free(StrokeCache *cache) { - if(cache->face_norms) + if (cache->face_norms) MEM_freeN(cache->face_norms); MEM_freeN(cache); } @@ -2795,20 +2799,20 @@ static void sculpt_init_mirror_clipping(Object *ob, SculptSession *ss) ModifierData *md; int i; - for(md= ob->modifiers.first; md; md= md->next) { - if(md->type==eModifierType_Mirror && + for (md= ob->modifiers.first; md; md= md->next) { + if (md->type==eModifierType_Mirror && (md->mode & eModifierMode_Realtime)) { MirrorModifierData *mmd = (MirrorModifierData*)md; - if(mmd->flag & MOD_MIR_CLIPPING) { + if (mmd->flag & MOD_MIR_CLIPPING) { /* check each axis for mirroring */ - for(i = 0; i < 3; ++i) { - if(mmd->flag & (MOD_MIR_AXIS_X << i)) { + for (i = 0; i < 3; ++i) { + if (mmd->flag & (MOD_MIR_AXIS_X << i)) { /* enable sculpt clipping */ ss->cache->flag |= CLIP_X << i; /* update the clip tolerance */ - if(mmd->tolerance > + if (mmd->tolerance > ss->cache->clip_tolerance[i]) ss->cache->clip_tolerance[i] = mmd->tolerance; @@ -2858,7 +2862,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio /* not very nice, but with current events system implementation * we can't handle brush appearance inversion hotkey separately (sergey) */ - if(cache->invert) brush->flag |= BRUSH_INVERTED; + if (cache->invert) brush->flag |= BRUSH_INVERTED; else brush->flag &= ~BRUSH_INVERTED; /* Alt-Smooth */ @@ -2869,7 +2873,7 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio BLI_strncpy(cache->saved_active_brush_name, brush->id.name+2, sizeof(cache->saved_active_brush_name)); br= (Brush *)find_id("BR", "Smooth"); - if(br) { + if (br) { paint_brush_set(p, br); brush = br; } @@ -2889,16 +2893,16 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio ED_view3d_global_to_vector(cache->vc->rv3d, cache->vc->rv3d->twmat[3], cache->true_view_normal); /* Initialize layer brush displacements and persistent coords */ - if(brush->sculpt_tool == SCULPT_TOOL_LAYER) { + if (brush->sculpt_tool == SCULPT_TOOL_LAYER) { /* not supported yet for multires */ - if(!ss->multires && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { - if(!ss->layer_co) + if (!ss->multires && !ss->layer_co && (brush->flag & BRUSH_PERSISTENT)) { + if (!ss->layer_co) ss->layer_co= MEM_mallocN(sizeof(float) * 3 * ss->totvert, "sculpt mesh vertices copy"); - if(ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert); + if (ss->deform_cos) memcpy(ss->layer_co, ss->deform_cos, ss->totvert); else { - for(i = 0; i < ss->totvert; ++i) { + for (i = 0; i < ss->totvert; ++i) { copy_v3_v3(ss->layer_co[i], ss->mvert[i].co); } } @@ -2906,22 +2910,22 @@ static void sculpt_update_cache_invariants(bContext* C, Sculpt *sd, SculptSessio } /* Make copies of the mesh vertex locations and normals for some tools */ - if(brush->flag & BRUSH_ANCHORED) { - if(ss->face_normals) { + if (brush->flag & BRUSH_ANCHORED) { + if (ss->face_normals) { float *fn = ss->face_normals; cache->face_norms= MEM_mallocN(sizeof(float) * 3 * ss->totpoly, "Sculpt face norms"); - for(i = 0; i < ss->totpoly; ++i, fn += 3) + for (i = 0; i < ss->totpoly; ++i, fn += 3) copy_v3_v3(cache->face_norms[i], fn); } cache->original = 1; } - if(ELEM8(brush->sculpt_tool, + if (ELEM8(brush->sculpt_tool, SCULPT_TOOL_DRAW, SCULPT_TOOL_CREASE, SCULPT_TOOL_BLOB, SCULPT_TOOL_LAYER, SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_ROTATE)) - if(!(brush->flag & BRUSH_ACCUMULATE)) + if (!(brush->flag & BRUSH_ACCUMULATE)) cache->original = 1; cache->special_rotation = (brush->flag & BRUSH_RAKE) ? sd->last_angle : 0; @@ -2941,17 +2945,17 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) }; int tool = brush->sculpt_tool; - if(ELEM5(tool, + if (ELEM5(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_NUDGE, SCULPT_TOOL_CLAY_STRIPS, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB)) { float grab_location[3], imat[4][4], delta[3], loc[3]; - if(cache->first_time) { + if (cache->first_time) { copy_v3_v3(cache->orig_grab_location, cache->true_location); } - else if(tool == SCULPT_TOOL_SNAKE_HOOK) + else if (tool == SCULPT_TOOL_SNAKE_HOOK) add_v3_v3(cache->true_location, cache->grab_delta); /* compute 3d coordinate at same z from original location + mouse */ @@ -2961,7 +2965,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) ED_view3d_win_to_3d(cache->vc->ar, loc, mouse, grab_location); /* compute delta to move verts by */ - if(!cache->first_time) { + if (!cache->first_time) { switch(tool) { case SCULPT_TOOL_GRAB: case SCULPT_TOOL_THUMB: @@ -2973,7 +2977,7 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) case SCULPT_TOOL_CLAY_STRIPS: case SCULPT_TOOL_NUDGE: case SCULPT_TOOL_SNAKE_HOOK: - if(brush->flag & BRUSH_ANCHORED) { + if (brush->flag & BRUSH_ANCHORED) { float orig[3]; mul_v3_m4v3(orig, ob->obmat, cache->orig_grab_location); sub_v3_v3v3(cache->grab_delta, grab_location, orig); @@ -2994,12 +2998,12 @@ static void sculpt_update_brush_delta(Sculpt *sd, Object *ob, Brush *brush) copy_v3_v3(cache->old_grab_location, grab_location); - if(tool == SCULPT_TOOL_GRAB) + if (tool == SCULPT_TOOL_GRAB) copy_v3_v3(sd->anchored_location, cache->true_location); - else if(tool == SCULPT_TOOL_THUMB) + else if (tool == SCULPT_TOOL_THUMB) copy_v3_v3(sd->anchored_location, cache->orig_grab_location); - if(ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { + if (ELEM(tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_THUMB)) { /* location stays the same for finding vertices in brush radius */ copy_v3_v3(cache->true_location, cache->orig_grab_location); @@ -3041,7 +3045,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, * brush coord/pressure/etc. * It's more an events design issue, which doesn't split coordinate/pressure/angle * changing events. We should avoid this after events system re-design */ - if(paint_space_stroke_enabled(brush) || cache->first_time) + if (paint_space_stroke_enabled(brush) || cache->first_time) cache->pressure = RNA_float_get(ptr, "pressure"); /* Truly temporary data that isn't stored in properties */ @@ -3052,7 +3056,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, cache->previous_pixel_radius = cache->pixel_radius; cache->pixel_radius = brush_size(scene, brush); - if(cache->first_time) { + if (cache->first_time) { if (!brush_use_locked_size(scene, brush)) { cache->initial_radius= paint_calc_object_space_radius(cache->vc, cache->true_location, brush_size(scene, brush)); brush_set_unprojected_radius(scene, brush, cache->initial_radius); @@ -3062,7 +3066,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } } - if(brush_use_size_pressure(scene, brush)) { + if (brush_use_size_pressure(scene, brush)) { cache->pixel_radius *= cache->pressure; cache->radius= cache->initial_radius * cache->pressure; } @@ -3071,7 +3075,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, cache->radius_squared = cache->radius*cache->radius; - if(!(brush->flag & BRUSH_ANCHORED || + if (!(brush->flag & BRUSH_ANCHORED || ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK, SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE))) { copy_v2_v2(cache->tex_mouse, cache->mouse); @@ -3084,7 +3088,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, } } - if(brush->flag & BRUSH_ANCHORED) { + if (brush->flag & BRUSH_ANCHORED) { int hit = 0; dx = cache->mouse[0] - cache->initial_mouse[0]; @@ -3124,7 +3128,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sd->draw_anchored = 1; } - else if(brush->flag & BRUSH_RAKE) { + else if (brush->flag & BRUSH_RAKE) { const float u = 0.5f; const float v = 1 - u; const float r = 20; @@ -3145,7 +3149,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, sculpt_update_brush_delta(sd, ob, brush); - if(brush->sculpt_tool == SCULPT_TOOL_ROTATE) { + if (brush->sculpt_tool == SCULPT_TOOL_ROTATE) { dx = cache->mouse[0] - cache->initial_mouse[0]; dy = cache->mouse[1] - cache->initial_mouse[1]; @@ -3164,7 +3168,7 @@ static void sculpt_stroke_modifiers_check(bContext *C, Object *ob) { SculptSession *ss = ob->sculpt; - if(ss->modifiers_active) { + if (ss->modifiers_active) { Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = paint_brush(&sd->paint); @@ -3186,7 +3190,7 @@ static void sculpt_raycast_cb(PBVHNode *node, void *data_v, float* tmin) SculptRaycastData *srd = data_v; float (*origco)[3]= NULL; - if(srd->original && srd->ss->cache) { + if (srd->original && srd->ss->cache) { /* intersect with coordinates from before we started stroke */ SculptUndoNode *unode= sculpt_undo_get_node(node); origco= (unode)? unode->co: NULL; @@ -3256,7 +3260,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession MTex *mtex= &brush->mtex; /* init mtex nodes */ - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexBeginExecTree(mtex->tex->nodetree, 1); /* has internal flag to detect it only does it once */ /* TODO: Shouldn't really have to do this at the start of every @@ -3291,7 +3295,7 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) Brush *brush = paint_brush(&sd->paint); /* Restore the mesh before continuing with anchored stroke */ - if((brush->flag & BRUSH_ANCHORED) || + if ((brush->flag & BRUSH_ANCHORED) || (brush->sculpt_tool == SCULPT_TOOL_GRAB && brush_use_size_pressure(ss->cache->vc->scene, brush)) || (brush->flag & BRUSH_RESTORE_MESH)) @@ -3305,19 +3309,19 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) BLI_pbvh_search_gather(ss->pbvh, NULL, NULL, &nodes, &totnode); #pragma omp parallel for schedule(guided) if (sd->flags & SCULPT_USE_OPENMP) - for(n=0; n<totnode; n++) { + for (n=0; n<totnode; n++) { SculptUndoNode *unode; unode= sculpt_undo_get_node(nodes[n]); - if(unode) { + if (unode) { PBVHVertexIter vd; BLI_pbvh_vertex_iter_begin(ss->pbvh, nodes[n], vd, PBVH_ITER_UNIQUE) { copy_v3_v3(vd.co, unode->co[vd.i]); - if(vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); + if (vd.no) copy_v3_v3_short(vd.no, unode->no[vd.i]); else normal_short_to_float_v3(vd.fno, unode->no[vd.i]); - if(vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; + if (vd.mvert) vd.mvert->flag |= ME_VERT_PBVH_UPDATE; } BLI_pbvh_vertex_iter_end; @@ -3325,13 +3329,13 @@ static void sculpt_restore_mesh(Sculpt *sd, SculptSession *ss) } } - if(ss->face_normals) { + if (ss->face_normals) { float *fn = ss->face_normals; - for(i = 0; i < ss->totpoly; ++i, fn += 3) + for (i = 0; i < ss->totpoly; ++i, fn += 3) copy_v3_v3(fn, cache->face_norms[i]); } - if(nodes) + if (nodes) MEM_freeN(nodes); } } @@ -3343,12 +3347,12 @@ static void sculpt_flush_update(bContext *C) ARegion *ar = CTX_wm_region(C); MultiresModifierData *mmd = ss->multires; - if(mmd) + if (mmd) multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); - if(ob->derivedFinal) /* VBO no longer valid */ + if (ob->derivedFinal) /* VBO no longer valid */ GPU_drawobject_free(ob->derivedFinal); - if(ss->modifiers_active) { + if (ss->modifiers_active) { DAG_id_tag_update(&ob->id, OB_RECALC_DATA); ED_region_tag_redraw(ar); } @@ -3388,7 +3392,7 @@ static int sculpt_stroke_test_start(bContext *C, struct wmOperator *op, { /* Don't start the stroke until mouse goes over the mesh. * note: event will only be null when re-executing the saved stroke. */ - if(event==NULL || over_mesh(C, op, event->x, event->y)) { + if (event==NULL || over_mesh(C, op, event->x, event->y)) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -3438,7 +3442,7 @@ static void sculpt_brush_exit_tex(Sculpt *sd) Brush *brush= paint_brush(&sd->paint); MTex *mtex= &brush->mtex; - if(mtex->tex && mtex->tex->nodetree) + if (mtex->tex && mtex->tex->nodetree) ntreeTexEndExecTree(mtex->tex->nodetree->execdata, 1); } @@ -3454,7 +3458,7 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) sd->special_rotation= 0; /* Finished */ - if(ss->cache) { + if (ss->cache) { Brush *brush= paint_brush(&sd->paint); brush->flag &= ~BRUSH_INVERTED; @@ -3464,7 +3468,7 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) if (ss->cache->alt_smooth) { Paint *p= &sd->paint; brush= (Brush *)find_id("BR", ss->cache->saved_active_brush_name); - if(brush) { + if (brush) { paint_brush_set(p, brush); } } @@ -3479,12 +3483,12 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *UNUSED(stroke)) /* optimization: if there is locked key and active modifiers present in */ /* the stack, keyblock is updating at each step. otherwise we could update */ /* keyblock only when stroke is finished */ - if(ss->kb && !ss->modifiers_active) sculpt_update_keyblock(ob); + if (ss->kb && !ss->modifiers_active) sculpt_update_keyblock(ob); ss->partial_redraw = 0; /* try to avoid calling this, only for e.g. linked duplicates now */ - if(((Mesh*)ob->data)->id.us > 1) + if (((Mesh*)ob->data)->id.us > 1) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); @@ -3498,7 +3502,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even struct PaintStroke *stroke; int ignore_background_click; - if(!sculpt_brush_stroke_init(C, op)) + if (!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; stroke = paint_stroke_new(C, sculpt_stroke_get_location, @@ -3512,7 +3516,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even ignore_background_click = RNA_boolean_get(op->ptr, "ignore_background_click"); - if(ignore_background_click && !over_mesh(C, op, event->x, event->y)) { + if (ignore_background_click && !over_mesh(C, op, event->x, event->y)) { paint_stroke_free(stroke); return OPERATOR_PASS_THROUGH; } @@ -3527,7 +3531,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) { - if(!sculpt_brush_stroke_init(C, op)) + if (!sculpt_brush_stroke_init(C, op)) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, @@ -3547,7 +3551,7 @@ static int sculpt_brush_stroke_cancel(bContext *C, wmOperator *op) paint_stroke_cancel(C, op); - if(ss->cache) { + if (ss->cache) { sculpt_cache_free(ss->cache); ss->cache = NULL; } @@ -3600,8 +3604,8 @@ static int sculpt_set_persistent_base(bContext *C, wmOperator *UNUSED(op)) { SculptSession *ss = CTX_data_active_object(C)->sculpt; - if(ss) { - if(ss->layer_co) + if (ss) { + if (ss->layer_co) MEM_freeN(ss->layer_co); ss->layer_co = NULL; } @@ -3644,11 +3648,11 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) /* if object has got active modifiers, it's dm could be different in sculpt mode */ flush_recalc |= sculpt_has_active_modifiers(scene, ob); - if(ob->mode & OB_MODE_SCULPT) { - if(mmd) + if (ob->mode & OB_MODE_SCULPT) { + if (mmd) multires_force_update(ob); - if(flush_recalc) + if (flush_recalc) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* Leave sculptmode */ @@ -3660,11 +3664,11 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) /* Enter sculptmode */ ob->mode |= OB_MODE_SCULPT; - if(flush_recalc) + if (flush_recalc) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* Create persistent sculpt mode data */ - if(!ts->sculpt) { + if (!ts->sculpt) { ts->sculpt = MEM_callocN(sizeof(Sculpt), "sculpt mode data"); /* Turn on X plane mirror symmetry by default */ @@ -3672,7 +3676,7 @@ static int sculpt_toggle_mode(bContext *C, wmOperator *UNUSED(op)) } /* Create sculpt mode session data */ - if(ob->sculpt) + if (ob->sculpt) free_sculptsession(ob); sculpt_init_session(scene, ob); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index a130245d6d7..73fa546b357 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -71,17 +71,20 @@ static void update_cb(PBVHNode *node, void *rebuild) { BLI_pbvh_node_mark_update(node); - if(*((int*)rebuild)) + if (*((int*)rebuild)) BLI_pbvh_node_mark_rebuild_draw(node); BLI_pbvh_node_fully_hidden_set(node, 0); } static void sculpt_undo_restore_deformed(SculptSession *ss, SculptUndoNode *unode, int uindex, int oindex, float coord[3]) { - if(unode->orig_co) { + if (unode->orig_co) { swap_v3_v3(coord, unode->orig_co[uindex]); copy_v3_v3(unode->co[uindex], ss->deform_cos[oindex]); - } else swap_v3_v3(coord, unode->co[uindex]); + } + else { + swap_v3_v3(coord, unode->co[uindex]); + } } static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNode *unode) @@ -93,7 +96,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo MVert *mvert; int *index, i, j; - if(unode->maxvert) { + if (unode->maxvert) { /* regular mesh restore */ if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { @@ -107,7 +110,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo sculpt_update_mesh_elements(scene, sd, ob, 0); WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob); - } else { + } + else { /* key has been removed -- skip this undo node */ return 0; } @@ -120,10 +124,10 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo float (*vertCos)[3]; vertCos= key_to_vertcos(ob, ss->kb); - for(i=0; i<unode->totvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); + for (i=0; i<unode->totvert; i++) { + if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], vertCos[index[i]]); else { - if(unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); + if (unode->orig_co) swap_v3_v3(vertCos[index[i]], unode->orig_co[i]); else swap_v3_v3(vertCos[index[i]], unode->co[i]); } } @@ -136,18 +140,19 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo BLI_pbvh_apply_vertCos(ss->pbvh, vertCos); MEM_freeN(vertCos); - } else { - for(i=0; i<unode->totvert; i++) { - if(ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); + } + else { + for (i=0; i<unode->totvert; i++) { + if (ss->modifiers_active) sculpt_undo_restore_deformed(ss, unode, i, index[i], mvert[index[i]].co); else { - if(unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); + if (unode->orig_co) swap_v3_v3(mvert[index[i]].co, unode->orig_co[i]); else swap_v3_v3(mvert[index[i]].co, unode->co[i]); } mvert[index[i]].flag |= ME_VERT_PBVH_UPDATE; } } } - else if(unode->maxgrid && dm->getGridData) { + else if (unode->maxgrid && dm->getGridData) { /* multires restore */ DMGridData **grids, *grid; float (*co)[3]; @@ -157,10 +162,10 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo gridsize= dm->getGridSize(dm); co = unode->co; - for(j=0; j<unode->totgrid; j++) { + for (j=0; j<unode->totgrid; j++) { grid= grids[unode->grids[j]]; - for(i=0; i<gridsize*gridsize; i++, co++) + for (i=0; i<gridsize*gridsize; i++, co++) swap_v3_v3(grid[i].co, co[0]); } } @@ -175,16 +180,16 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, SculptSession *ss = ob->sculpt; int i; - if(unode->maxvert) { + if (unode->maxvert) { MVert *mvert= ss->mvert; - for(i=0; i<unode->totvert; i++) { + for (i=0; i<unode->totvert; i++) { MVert *v = &mvert[unode->index[i]]; int uval= BLI_BITMAP_GET(unode->vert_hidden, i); BLI_BITMAP_MODIFY(unode->vert_hidden, i, v->flag & ME_HIDE); - if(uval) + if (uval) v->flag |= ME_HIDE; else v->flag &= ~ME_HIDE; @@ -192,10 +197,10 @@ static int sculpt_undo_restore_hidden(bContext *C, DerivedMesh *dm, v->flag |= ME_VERT_PBVH_UPDATE; } } - else if(unode->maxgrid && dm->getGridData) { + else if (unode->maxgrid && dm->getGridData) { BLI_bitmap *grid_hidden = dm->getGridHidden(dm); - for(i=0; i<unode->totgrid; i++) { + for (i=0; i<unode->totgrid; i++) { SWAP(BLI_bitmap, unode->grid_hidden[i], grid_hidden[unode->grids[i]]); @@ -219,18 +224,18 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) sculpt_update_mesh_elements(scene, sd, ob, 0); - for(unode=lb->first; unode; unode=unode->next) { - if(!(strcmp(unode->idname, ob->id.name)==0)) + for (unode=lb->first; unode; unode=unode->next) { + if (!(strcmp(unode->idname, ob->id.name)==0)) continue; /* check if undo data matches current data well enough to * continue */ - if(unode->maxvert) { - if(ss->totvert != unode->maxvert) + if (unode->maxvert) { + if (ss->totvert != unode->maxvert) continue; } - else if(unode->maxgrid && dm->getGridData) { - if((dm->getNumGrids(dm) != unode->maxgrid) || + else if (unode->maxgrid && dm->getGridData) { + if ((dm->getNumGrids(dm) != unode->maxgrid) || (dm->getGridSize(dm) != unode->gridsize)) continue; } @@ -240,17 +245,17 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) switch(unode->type) { case SCULPT_UNDO_COORDS: - if(sculpt_undo_restore_coords(C, dm, unode)) + if (sculpt_undo_restore_coords(C, dm, unode)) update= 1; break; case SCULPT_UNDO_HIDDEN: - if(sculpt_undo_restore_hidden(C, dm, unode)) + if (sculpt_undo_restore_hidden(C, dm, unode)) rebuild= 1; break; } } - if(update || rebuild) { + if (update || rebuild) { int tag_update= 0; /* we update all nodes still, should be more clever, but also * needs to work correct when exiting/entering sculpt mode and @@ -258,8 +263,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) BLI_pbvh_search_callback(ss->pbvh, NULL, NULL, update_cb, &rebuild); BLI_pbvh_update(ss->pbvh, PBVH_UpdateBB|PBVH_UpdateOriginalBB|PBVH_UpdateRedraw, NULL); - if((mmd=sculpt_multires_active(scene, ob))) { - if(rebuild) + if ((mmd=sculpt_multires_active(scene, ob))) { + if (rebuild) multires_mark_as_modified(ob, MULTIRES_HIDDEN_MODIFIED); else multires_mark_as_modified(ob, MULTIRES_COORDS_MODIFIED); @@ -267,7 +272,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) tag_update= ((Mesh*)ob->data)->id.us > 1; - if(ss->modifiers_active) { + if (ss->modifiers_active) { Mesh *mesh= ob->data; mesh_calc_normals_mapping(mesh->mvert, mesh->totvert, mesh->mloop, mesh->mpoly, mesh->totloop, mesh->totpoly, NULL, NULL, 0, NULL, NULL); @@ -275,7 +280,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) tag_update|= 1; } - if(tag_update) + if (tag_update) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); /* for non-PBVH drawing, need to recreate VBOs */ @@ -288,24 +293,24 @@ static void sculpt_undo_free(ListBase *lb) SculptUndoNode *unode; int i; - for(unode=lb->first; unode; unode=unode->next) { - if(unode->co) + for (unode=lb->first; unode; unode=unode->next) { + if (unode->co) MEM_freeN(unode->co); - if(unode->no) + if (unode->no) MEM_freeN(unode->no); - if(unode->index) + if (unode->index) MEM_freeN(unode->index); - if(unode->grids) + if (unode->grids) MEM_freeN(unode->grids); - if(unode->layer_disp) + if (unode->layer_disp) MEM_freeN(unode->layer_disp); - if(unode->orig_co) + if (unode->orig_co) MEM_freeN(unode->orig_co); - if(unode->vert_hidden) + if (unode->vert_hidden) MEM_freeN(unode->vert_hidden); - if(unode->grid_hidden) { - for(i=0; i<unode->totgrid; i++) { - if(unode->grid_hidden[i]) + if (unode->grid_hidden) { + for (i=0; i<unode->totgrid; i++) { + if (unode->grid_hidden[i]) MEM_freeN(unode->grid_hidden[i]); } MEM_freeN(unode->grid_hidden); @@ -318,11 +323,11 @@ SculptUndoNode *sculpt_undo_get_node(PBVHNode *node) ListBase *lb= undo_paint_push_get_list(UNDO_PAINT_MESH); SculptUndoNode *unode; - if(!lb) + if (!lb) return NULL; - for(unode=lb->first; unode; unode=unode->next) - if(unode->node == node) + for (unode=lb->first; unode; unode=unode->next) + if (unode->node == node) return unode; return NULL; @@ -343,8 +348,8 @@ static void sculpt_undo_alloc_and_store_hidden(PBVH *pbvh, unode->grid_hidden= MEM_mapallocN(sizeof(BLI_bitmap) * totgrid, "unode->grid_hidden"); - for(i = 0; i < totgrid; i++) { - if(grid_hidden[grid_indices[i]]) + for (i = 0; i < totgrid; i++) { + if (grid_hidden[grid_indices[i]]) unode->grid_hidden[i] = MEM_dupallocN(grid_hidden[grid_indices[i]]); else unode->grid_hidden[i] = NULL; @@ -380,7 +385,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, undo_paint_push_count_alloc(UNDO_PAINT_MESH, (sizeof(float)*3 + sizeof(short)*3 + sizeof(int))*allvert); break; case SCULPT_UNDO_HIDDEN: - if(maxgrid) + if (maxgrid) sculpt_undo_alloc_and_store_hidden(ss->pbvh, unode); else unode->vert_hidden= BLI_BITMAP_NEW(allvert, "SculptUndoNode.vert_hidden"); @@ -390,7 +395,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, BLI_addtail(lb, unode); - if(maxgrid) { + if (maxgrid) { /* multires */ unode->maxgrid= maxgrid; unode->totgrid= totgrid; @@ -403,7 +408,7 @@ static SculptUndoNode *sculpt_undo_alloc_node(Object *ob, PBVHNode *node, unode->index= MEM_mapallocN(sizeof(int)*allvert, "SculptUndoNode.index"); } - if(ss->modifiers_active) + if (ss->modifiers_active) unode->orig_co= MEM_callocN(allvert*sizeof(*unode->orig_co), "undoSculpt orig_cos"); return unode; @@ -416,10 +421,10 @@ static void sculpt_undo_store_coords(Object *ob, SculptUndoNode *unode) BLI_pbvh_vertex_iter_begin(ss->pbvh, unode->node, vd, PBVH_ITER_ALL) { copy_v3_v3(unode->co[vd.i], vd.co); - if(vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); + if (vd.no) copy_v3_v3_short(unode->no[vd.i], vd.no); else normal_float_to_short_v3(unode->no[vd.i], vd.fno); - if(ss->modifiers_active) + if (ss->modifiers_active) copy_v3_v3(unode->orig_co[vd.i], ss->orig_cos[unode->index[vd.i]]); } BLI_pbvh_vertex_iter_end; @@ -430,7 +435,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) PBVH *pbvh= ob->sculpt->pbvh; PBVHNode *node= unode->node; - if(unode->grids) { + if (unode->grids) { /* already stored during allocation */ } else { @@ -440,7 +445,7 @@ static void sculpt_undo_store_hidden(Object *ob, SculptUndoNode *unode) BLI_pbvh_node_num_verts(pbvh, node, NULL, &allvert); BLI_pbvh_node_get_verts(pbvh, node, &vert_indices, &mvert); - for(i = 0; i < allvert; i++) { + for (i = 0; i < allvert; i++) { BLI_BITMAP_MODIFY(unode->vert_hidden, i, mvert[vert_indices[i]].flag & ME_HIDE); } @@ -456,7 +461,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, /* list is manipulated by multiple threads, so we lock */ BLI_lock_thread(LOCK_CUSTOM1); - if((unode= sculpt_undo_get_node(node))) { + if ((unode= sculpt_undo_get_node(node))) { BLI_unlock_thread(LOCK_CUSTOM1); return unode; } @@ -475,7 +480,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, break; } - if(unode->grids) { + if (unode->grids) { int totgrid, *grids; BLI_pbvh_node_get_grids(ss->pbvh, node, &grids, &totgrid, NULL, NULL, NULL, NULL); @@ -489,7 +494,7 @@ SculptUndoNode *sculpt_undo_push_node(Object *ob, PBVHNode *node, } /* store active shape key */ - if(ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); + if (ss->kb) BLI_strncpy(unode->shapeName, ss->kb->name, sizeof(ss->kb->name)); else unode->shapeName[0]= '\0'; return unode; @@ -507,13 +512,13 @@ void sculpt_undo_push_end(void) SculptUndoNode *unode; /* we don't need normals in the undo stack */ - for(unode=lb->first; unode; unode=unode->next) { - if(unode->no) { + for (unode=lb->first; unode; unode=unode->next) { + if (unode->no) { MEM_freeN(unode->no); unode->no= NULL; } - if(unode->layer_disp) { + if (unode->layer_disp) { MEM_freeN(unode->layer_disp); unode->layer_disp= NULL; } diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index 72e9f861aa9..240a8feeb88 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -372,7 +372,8 @@ static void uv_sculpt_stroke_apply(bContext *C, wmOperator *op, wmEvent *event, unsigned int method = toolsettings->uv_relax_method; if (method == UV_SCULPT_TOOL_RELAX_HC) { HC_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio); - }else{ + } + else { laplacian_relaxation_iteration_uv(em, sculptdata, co, alpha, radius, aspectRatio); } } @@ -501,13 +502,16 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent /* We will need island information */ if (ts->uv_flag & UV_SYNC_SELECTION) { data->elementMap = EDBM_make_uv_element_map(em, 0, 1); - }else{ + } + else { data->elementMap = EDBM_make_uv_element_map(em, 1, 1); } - }else { + } + else { if (ts->uv_flag & UV_SYNC_SELECTION) { data->elementMap = EDBM_make_uv_element_map(em, 0, 0); - }else{ + } + else { data->elementMap = EDBM_make_uv_element_map(em, 1, 0); } } @@ -610,7 +614,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent edges[counter].uv1 = offset1; edges[counter].uv2 = offset2; } - else{ + else { edges[counter].uv1 = offset2; edges[counter].uv2 = offset1; } @@ -619,7 +623,7 @@ static UvSculptData *uv_sculpt_stroke_init(bContext *C, wmOperator *op, wmEvent char *flag = BLI_ghash_lookup(edgeHash, &edges[counter]); *flag = 1; } - else{ + else { /* Hack mentioned */ BLI_ghash_insert(edgeHash, &edges[counter], &edges[counter].flag); } |