diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_cursor.c | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_hide.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 58 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_stroke.c | 11 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 111 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 19 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_uv.c | 4 |
11 files changed, 82 insertions, 146 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c index 8616d4e66eb..e14266c83a7 100644 --- a/source/blender/editors/sculpt_paint/paint_cursor.c +++ b/source/blender/editors/sculpt_paint/paint_cursor.c @@ -322,8 +322,8 @@ static int project_brush_radius(ViewContext *vc, add_v3_v3v3(offset, location, ortho); /* project the center of the brush, and the tangent point to the view onto the screen */ - project_float(vc->ar, location, p1); - project_float(vc->ar, offset, p2); + ED_view3d_project_float(vc->ar, location, p1); + ED_view3d_project_float(vc->ar, offset, p2); /* the distance between these points is the size of the projected brush in pixels */ return len_v2v2(p1, p2); @@ -441,8 +441,8 @@ static void paint_draw_alpha_overlay(Sculpt *sd, Brush *brush, else { quad.xmin = 0; quad.ymin = 0; - quad.xmax = BLI_RCT_SIZE_X(&vc->ar->winrct); - quad.ymax = BLI_RCT_SIZE_Y(&vc->ar->winrct); + quad.xmax = BLI_rcti_size_x(&vc->ar->winrct); + quad.ymax = BLI_rcti_size_y(&vc->ar->winrct); } /* set quad color */ diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index e809267d076..2970bdfb5a4 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -251,7 +251,7 @@ static void clip_planes_from_rect(bContext *C, view3d_operator_needs_opengl(C); view3d_set_viewcontext(C, &vc); view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats); - ED_view3d_calc_clipping(&bb, clip_planes, &mats, rect); + ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect); mul_m4_fl(clip_planes, -1.0f); } @@ -388,7 +388,7 @@ void PAINT_OT_hide_show(struct wmOperatorType *ot) ot->modal = WM_border_select_modal; ot->exec = hide_show_exec; /* sculpt-only for now */ - ot->poll = sculpt_mode_poll; + ot->poll = sculpt_mode_poll_view3d; ot->flag = OPTYPE_REGISTER; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 7c3f376df91..b8e365c4c8e 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -104,6 +104,8 @@ #include "GPU_draw.h" #include "GPU_extensions.h" +#include "IMB_colormanagement.h" + #include "paint_intern.h" /* Defines and Structs */ @@ -139,7 +141,7 @@ #define IMAPAINT_TILE_SIZE (1 << IMAPAINT_TILE_BITS) #define IMAPAINT_TILE_NUMBER(size) (((size) + IMAPAINT_TILE_SIZE - 1) >> IMAPAINT_TILE_BITS) -static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); +static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint); typedef struct ImagePaintState { @@ -153,7 +155,6 @@ typedef struct ImagePaintState { Image *image; ImBuf *canvas; ImBuf *clonecanvas; - short clonefreefloat; char *warnpackedfile; char *warnmultifile; @@ -239,8 +240,6 @@ typedef struct ImagePaintRegion { /* vert flags */ #define PROJ_VERT_CULL 1 -#define PI_80_DEG ((M_PI_2 / 9) * 8) - /* This is mainly a convenience struct used so we can keep an array of images we use * Thir imbufs, etc, in 1 array, When using threads this array is copied for each thread * because 'partRedrawRect' and 'touch' values would not be thread safe */ @@ -510,7 +509,7 @@ static void image_undo_restore(bContext *C, ListBase *lb) ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; /* force mipmap recreatiom */ - + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; } IMB_freeImBuf(tmpibuf); @@ -3137,7 +3136,7 @@ static void project_paint_begin(ProjPaintState *ps) ps->is_ortho = params.is_ortho; } - /* same as view3d_get_object_project_mat */ + /* same as #ED_view3d_ob_project_mat_get */ mult_m4_m4m4(vmat, viewmat, ps->ob->obmat); mult_m4_m4m4(ps->projectMat, winmat, vmat); } @@ -3615,7 +3614,7 @@ static int project_image_refresh_tagged(ProjPaintState *ps) pr = &(projIma->partRedrawRect[i]); if (pr->x2 != -1) { /* TODO - use 'enabled' ? */ imapaintpartial = *pr; - imapaint_image_update(NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ + imapaint_image_update(NULL, NULL, projIma->ima, projIma->ibuf, 1); /*last 1 is for texpaint*/ redraw = 1; } } @@ -3945,7 +3944,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma->touch = 1; is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; - use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0; + use_color_correction = TRUE; } /* end copy */ @@ -4028,7 +4027,7 @@ static void *do_projectpaint_thread(void *ph_v) last_projIma->touch = 1; is_floatbuf = last_projIma->ibuf->rect_float ? 1 : 0; - use_color_correction = (last_projIma->ibuf->profile == IB_PROFILE_LINEAR_RGB) ? 1 : 0; + use_color_correction = TRUE; } /* end copy */ @@ -4244,10 +4243,17 @@ static void imapaint_dirty_region(Image *ima, ImBuf *ibuf, int x, int y, int w, IMB_freeImBuf(tmpibuf); } -static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) +static void imapaint_image_update(Scene *scene, SpaceImage *sima, Image *image, ImBuf *ibuf, short texpaint) { - if (ibuf->rect_float) - ibuf->userflags |= IB_RECT_INVALID; /* force recreate of char rect */ + if (scene) { + IMB_partial_display_buffer_update(ibuf, ibuf->rect_float, (unsigned char *) ibuf->rect, ibuf->x, 0, 0, + &scene->view_settings, &scene->display_settings, + imapaintpartial.x1, imapaintpartial.y1, + imapaintpartial.x2, imapaintpartial.y2); + } + else { + ibuf->userflags |= IB_DISPLAY_BUFFER_INVALID; + } if (ibuf->mipmap[0]) ibuf->userflags |= IB_MIPMAP_INVALID; @@ -4257,7 +4263,7 @@ static void imapaint_image_update(SpaceImage *sima, Image *image, ImBuf *ibuf, s int w = imapaintpartial.x2 - imapaintpartial.x1; int h = imapaintpartial.y2 - imapaintpartial.y1; /* Testing with partial update in uv editor too */ - GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h, 0); //!texpaint); + GPU_paint_update_image(image, imapaintpartial.x1, imapaintpartial.y1, w, h); //!texpaint); } } @@ -4571,15 +4577,7 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) /* temporarily add float rect for cloning */ if (s->canvas->rect_float && !s->clonecanvas->rect_float) { - short profile = IB_PROFILE_NONE; - - /* Don't want to color manage, but don't disturb existing profiles */ - SWAP(short, s->clonecanvas->profile, profile); - IMB_float_from_rect(s->clonecanvas); - s->clonefreefloat = 1; - - SWAP(short, s->clonecanvas->profile, profile); } else if (!s->canvas->rect_float && !s->clonecanvas->rect) IMB_rect_from_float(s->clonecanvas); @@ -4588,28 +4586,32 @@ static int imapaint_canvas_set(ImagePaintState *s, Image *ima) return 1; } -static void imapaint_canvas_free(ImagePaintState *s) +static void imapaint_canvas_free(ImagePaintState *UNUSED(s)) { - if (s->clonefreefloat) - imb_freerectfloatImBuf(s->clonecanvas); } static int imapaint_paint_sub_stroke(ImagePaintState *s, BrushPainter *painter, Image *image, short texpaint, float *uv, double time, int update, float pressure) { ImBuf *ibuf = BKE_image_get_ibuf(image, s->sima ? &s->sima->iuser : NULL); float pos[2]; + int is_data; if (!ibuf) return 0; + is_data = ibuf->colormanage_flag & IMB_COLORMANAGE_IS_DATA; + pos[0] = uv[0] * ibuf->x; pos[1] = uv[1] * ibuf->y; BKE_brush_painter_require_imbuf(painter, ((ibuf->rect_float) ? 1 : 0), 0, 0); - if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, ibuf->profile == IB_PROFILE_LINEAR_RGB)) { + /* OCIO_TODO: float buffers are now always linear, so always use color correction + * this should probably be changed when texture painting color space is supported + */ + if (BKE_brush_painter_paint(painter, imapaint_paint_op, pos, time, pressure, s, is_data == FALSE)) { if (update) - imapaint_image_update(s->sima, image, ibuf, texpaint); + imapaint_image_update(s->scene, s->sima, image, ibuf, texpaint); return 1; } else return 0; @@ -5257,7 +5259,7 @@ void PAINT_OT_image_paint(wmOperatorType *ot) RNA_def_collection_runtime(ot->srna, "stroke", &RNA_OperatorStrokeElement, "Stroke", ""); } -int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) +static int get_imapaint_zoom(bContext *C, float *zoomx, float *zoomy) { RegionView3D *rv3d = CTX_wm_region_view3d(C); @@ -5884,7 +5886,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) 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); + ibuf = ED_view3d_draw_offscreen_imbuf(CTX_data_scene(C), CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, FALSE, FALSE, err_out); if (!ibuf) { /* Mostly happens when OpenGL offscreen buffer was failed to create, */ /* but could be other reasons. Should be handled in the future. nazgul */ diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index cc71be4938e..39a95300d5d 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -602,7 +602,7 @@ static void ed_keymap_paint_brush_radial_control(wmKeyMap *keymap, const char *p } } -void paint_partial_visibility_keys(wmKeyMap *keymap) +static void paint_partial_visibility_keys(wmKeyMap *keymap) { wmKeyMapItem *kmi; diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index b53edeadb51..7fabaf7f23d 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -254,7 +254,10 @@ static int paint_space_stroke(bContext *C, wmOperator *op, wmEvent *event, const pressure = event_tablet_data(event, NULL); if (pressure > FLT_EPSILON) { - scale = (BKE_brush_size_get(scene, stroke->brush) * pressure * stroke->brush->spacing / 50.0f) / length; + /* brushes can have a minimum size of 1.0 but with pressure it can be smaller then a pixel + * causing very high step sizes, hanging blender [#32381] */ + const float size_clamp = maxf(1.0f, BKE_brush_size_get(scene, stroke->brush) * pressure); + scale = (size_clamp * stroke->brush->spacing / 50.0f) / length; if (scale > FLT_EPSILON) { mul_v2_fl(vec, scale); @@ -521,8 +524,10 @@ int paint_poll(bContext *C) { Paint *p = paint_get_active_from_context(C); Object *ob = CTX_data_active_object(C); + ScrArea *sa = CTX_wm_area(C); + ARegion *ar = CTX_wm_region(C); return p && ob && paint_brush(p) && - CTX_wm_area(C)->spacetype == SPACE_VIEW3D && - CTX_wm_region(C)->regiontype == RGN_TYPE_WINDOW; + (sa && sa->spacetype == SPACE_VIEW3D) && + (ar && ar->regiontype == RGN_TYPE_WINDOW); } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index df64e1c9d90..29a59651cf7 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -98,7 +98,7 @@ int paint_convert_bb_to_rect(rcti *rect, vec[1] = j ? bb_min[1] : bb_max[1]; vec[2] = k ? bb_min[2] : bb_max[2]; /* convert corner to screen space */ - ED_view3d_project_float_v2(ar, vec, proj, projection_mat); + ED_view3d_project_float_v2_m4(ar, vec, proj, projection_mat); /* expand 2D rectangle */ /* we could project directly to int? */ @@ -137,7 +137,7 @@ void paint_calc_redraw_planes(float planes[4][4], rect.ymin -= 2; rect.ymax += 2; - ED_view3d_calc_clipping(&bb, planes, &mats, &rect); + ED_view3d_clipping_calc(&bb, planes, &mats, &rect); mul_m4_fl(planes, -1.0f); } diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index ba440e98290..8aed92df3af 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -134,7 +134,7 @@ int vertex_paint_poll(bContext *C) paint_brush(&CTX_data_tool_settings(C)->vpaint->paint)) { ScrArea *sa = CTX_wm_area(C); - if (sa->spacetype == SPACE_VIEW3D) { + if (sa && sa->spacetype == SPACE_VIEW3D) { ARegion *ar = CTX_wm_region(C); if (ar->regiontype == RGN_TYPE_WINDOW) return 1; @@ -257,7 +257,7 @@ static void do_shared_vertex_tesscol(Mesh *me) MEM_freeN(scolmain); } -void do_shared_vertexcol(Mesh *me, int do_tessface) +static void do_shared_vertexcol(Mesh *me, int do_tessface) { const int use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK); MPoly *mp; @@ -850,7 +850,7 @@ static float calc_vp_strength_dl(VPaint *vp, ViewContext *vc, const float vert_n float dist_squared; float vertco[2], delta[2]; - project_float_noclip(vc->ar, vert_nor, vertco); + ED_view3d_project_float_noclip(vc->ar, vert_nor, vertco); sub_v2_v2v2(delta, mval, vertco); dist_squared = dot_v2v2(delta, delta); /* len squared */ if (dist_squared > brush_size_pressure * brush_size_pressure) { @@ -2227,19 +2227,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P 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) { - MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 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) { @@ -2639,52 +2627,13 @@ static int vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const fl return 1; } -#if 0 -static void vpaint_paint_face(VPaint *vp, VPaintData *vpd, Object *ob, - const unsigned int index, const float mval[2], - const float brush_size_pressure, const float brush_alpha_pressure, - int UNUSED(flip)) +static void copy_lcol_to_mcol(MCol *mcol, const MLoopCol *lcol) { - ViewContext *vc = &vpd->vc; - Brush *brush = paint_brush(&vp->paint); - Mesh *me = BKE_mesh_from_object(ob); - MFace *mface = &me->mface[index]; - unsigned int *mcol = ((unsigned int *)me->mcol) + 4 * index; - unsigned int *mcolorig = ((unsigned int *)vp->vpaint_prev) + 4 * index; - float alpha; - int i; - - int brush_alpha_pressure_i; - - 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) { - unsigned int fcol2 = mcol_blend(mcol[2], mcol[3], 128); - vpd->paintcol = mcol_blend(fcol1, fcol2, 128); - } - else { - vpd->paintcol = mcol_blend(mcol[2], fcol1, 170); - } - } - - brush_alpha_pressure_i = (int)(brush_alpha_pressure * 255.0f); - - 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) { - const int alpha_i = (int)(alpha * 255.0f); - mcol[i] = vpaint_blend(vp, mcol[i], mcolorig[i], vpd->paintcol, alpha_i, brush_alpha_pressure_i); - } - } + mcol->a = lcol->a; + mcol->r = lcol->r; + mcol->g = lcol->g; + mcol->b = lcol->b; } -#endif - -/* BMESH version of vpaint_paint_face (commented above) */ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, const unsigned int index, const float mval[2], @@ -2744,33 +2693,22 @@ static void vpaint_paint_poly(VPaint *vp, VPaintData *vpd, Object *ob, } if (vpd->use_fast_update) { - -#ifdef CPYCOL -# undef CPYCOL -#endif -#define CPYCOL(c, l) (c)->a = (l)->a, (c)->r = (l)->r, (c)->g = (l)->g, (c)->b = (l)->b - /* update vertex colors for tessellations incrementally, * rather then regenerating the tessellation altogether */ for (e = vpd->polyfacemap[index].first; e; e = e->next) { - mf = me->mface + e->facenr; - mc = me->mcol + e->facenr * 4; + mf = &me->mface[e->facenr]; + mc = &me->mcol[e->facenr * 4]; ml = me->mloop + mpoly->loopstart; mlc = me->mloopcol + mpoly->loopstart; for (j = 0; j < mpoly->totloop; j++, ml++, mlc++) { - if (ml->v == mf->v1) - CPYCOL(mc, mlc); - else if (ml->v == mf->v2) - CPYCOL(mc + 1, mlc); - else if (ml->v == mf->v3) - CPYCOL(mc + 2, mlc); - else if (mf->v4 && ml->v == mf->v4) - CPYCOL(mc + 3, mlc); + if (ml->v == mf->v1) copy_lcol_to_mcol(mc + 0, mlc); + else if (ml->v == mf->v2) copy_lcol_to_mcol(mc + 1, mlc); + else if (ml->v == mf->v3) copy_lcol_to_mcol(mc + 2, mlc); + else if (mf->v4 && ml->v == mf->v4) copy_lcol_to_mcol(mc + 3, mlc); } } -#undef CPYCOL } } @@ -2804,7 +2742,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P mval[0] -= vc->ar->winrct.xmin; mval[1] -= vc->ar->winrct.ymin; - + /* which faces are involved */ if (vp->flag & VP_AREA) { totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); @@ -2814,19 +2752,6 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P 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) { - MPoly *mpoly = ((MPoly *)me->mpoly) + (indexar[index] - 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++) { @@ -2835,15 +2760,13 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P if ((mpoly->flag & ME_FACE_SEL) == 0) indexar[index] = 0; - } + } } } swap_m4m4(vc->rv3d->persmat, mat); - for (index = 0; index < totindex; index++) { - if (indexar[index] && indexar[index] <= me->totpoly) { vpaint_paint_poly(vp, vpd, ob, indexar[index] - 1, mval, brush_size_pressure, brush_alpha_pressure); } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 210477e3e5a..05b5b90344c 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -771,7 +771,7 @@ static float tex_strength(SculptSession *ss, Brush *br, float point[3], if (ss->cache->radial_symmetry_pass) mul_m4_v3(ss->cache->symm_rot_mat_inv, symm_point); - ED_view3d_project_float_v2(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); + ED_view3d_project_float_v2_m4(ss->cache->vc->ar, symm_point, point_2d, ss->cache->projection_mat); if (mtex->brush_map_mode == MTEX_MAP_MODE_VIEW) { /* keep coordinates relative to mouse */ @@ -2649,7 +2649,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } if (is_basis) { - ofs = key_to_vertcos(ob, kb); + ofs = BKE_key_convert_to_vertcos(ob, kb); /* calculate key coord offsets (from previous location) */ for (a = 0; a < me->totvert; a++) { @@ -2662,7 +2662,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) int apply_offset = ((currkey != kb) && (ob->shapenr - 1 == currkey->relative)); if (apply_offset) - offset_to_key(ob, currkey, ofs); + BKE_key_convert_from_offset(ob, currkey, ofs); currkey = currkey->next; } @@ -2683,7 +2683,7 @@ void sculpt_vertcos_to_key(Object *ob, KeyBlock *kb, float (*vertCos)[3]) } /* apply new coords on active key block */ - vertcos_to_key(ob, kb, vertCos); + BKE_key_convert_from_vertcos(ob, kb, vertCos); } static void do_brush_action(Sculpt *sd, Object *ob, Brush *brush) @@ -3074,7 +3074,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ /* BMESH ONLY --- at some point we should move sculpt code to use polygons only - but for now it needs tessfaces */ BKE_mesh_tessface_ensure(me); - if (!mmd) ss->kb = ob_get_keyblock(ob); + if (!mmd) ss->kb = BKE_keyblock_from_object(ob); else ss->kb = NULL; /* needs to be called after we ensure tessface */ @@ -3109,7 +3109,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ free_sculptsession_deformMats(ss); - ss->orig_cos = (ss->kb) ? key_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL); + ss->orig_cos = (ss->kb) ? BKE_key_convert_to_vertcos(ob, ss->kb) : mesh_getVertexCos(me, NULL); crazyspace_build_sculpt(scene, ob, &ss->deform_imats, &ss->deform_cos); BLI_pbvh_apply_vertCos(ss->pbvh, ss->deform_cos); @@ -3123,7 +3123,7 @@ void sculpt_update_mesh_elements(Scene *scene, Sculpt *sd, Object *ob, int need_ /* if pbvh is deformed, key block is already applied to it */ if (ss->kb && !BLI_pbvh_isDeformed(ss->pbvh)) { - float (*vertCos)[3] = key_to_vertcos(ob, ss->kb); + float (*vertCos)[3] = BKE_key_convert_to_vertcos(ob, ss->kb); if (vertCos) { /* apply shape keys coordinates to PBVH */ @@ -3139,6 +3139,11 @@ int sculpt_mode_poll(bContext *C) return ob && ob->mode & OB_MODE_SCULPT; } +int sculpt_mode_poll_view3d(bContext *C) +{ + return (sculpt_mode_poll(C) && CTX_wm_region_view3d(C)); +} + int sculpt_poll(bContext *C) { return sculpt_mode_poll(C) && paint_poll(C); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index f4467dc22fc..5e79616b0b0 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -56,6 +56,7 @@ struct MultiresModifierData *sculpt_multires_active(struct Scene *scene, struct void sculpt(struct Sculpt *sd); int sculpt_mode_poll(struct bContext *C); +int sculpt_mode_poll_view3d(struct bContext *C); int sculpt_poll(struct bContext *C); void sculpt_update_mesh_elements(struct Scene *scene, struct Sculpt *sd, struct Object *ob, int need_pmap); diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index c62dc687c73..bb2b4b8c743 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -107,8 +107,8 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo if (ss->kb && strcmp(ss->kb->name, unode->shapeName)) { /* shape key has been changed before calling undo operator */ - Key *key = ob_get_key(ob); - KeyBlock *kb = key_get_named_keyblock(key, unode->shapeName); + Key *key = BKE_key_from_object(ob); + KeyBlock *kb = BKE_keyblock_find_name(key, unode->shapeName); if (kb) { ob->shapenr = BLI_findindex(&key->block, kb) + 1; @@ -127,7 +127,7 @@ static int sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoNo if (ss->kb) { float (*vertCos)[3]; - vertCos = key_to_vertcos(ob, ss->kb); + vertCos = BKE_key_convert_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]]); diff --git a/source/blender/editors/sculpt_paint/sculpt_uv.c b/source/blender/editors/sculpt_paint/sculpt_uv.c index fdce8ec04a4..0bcccd9479c 100644 --- a/source/blender/editors/sculpt_paint/sculpt_uv.c +++ b/source/blender/editors/sculpt_paint/sculpt_uv.c @@ -156,8 +156,8 @@ typedef struct Temp_UvData { -void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2], - float alpha, float radius, float aspectRatio) +static void HC_relaxation_iteration_uv(BMEditMesh *em, UvSculptData *sculptdata, float mouse_coord[2], + float alpha, float radius, float aspectRatio) { Temp_UVData *tmp_uvdata; float diff[2]; |