diff options
author | Luca Rood <dev@lucarood.com> | 2017-07-21 12:53:13 +0300 |
---|---|---|
committer | Luca Rood <dev@lucarood.com> | 2017-07-21 15:47:26 +0300 |
commit | 1c4c288727214fa0588d66556a1cdf71755d70b4 (patch) | |
tree | 1433952be7e88cc7d09e8563831995290e3013ce /source/blender/editors/sculpt_paint | |
parent | 9edb7e49d7e5e69385f3a0434c568c79fad88cd8 (diff) |
Pass EvaluationContext argument everywhere
Note that some little parts of code have been dissabled because eval_ctx
was not available there. This should be resolved once DerivedMesh is
replaced.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_hide.c | 7 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image_proj.c | 24 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 17 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 19 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex.c | 25 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_vertex_proj.c | 24 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 25 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_undo.c | 12 |
9 files changed, 108 insertions, 49 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index d7c3b7377da..d2e2df01238 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -52,6 +52,8 @@ #include "BKE_paint.h" #include "BKE_subsurf.h" +#include "DEG_depsgraph.h" + #include "WM_api.h" #include "WM_types.h" @@ -360,6 +362,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; Mesh *me = ob->data; PartialVisAction action; PartialVisArea area; @@ -371,6 +374,8 @@ static int hide_show_exec(bContext *C, wmOperator *op) rcti rect; int totnode, i; + CTX_data_eval_ctx(C, &eval_ctx); + /* read operator properties */ action = RNA_enum_get(op->ptr, "action"); area = RNA_enum_get(op->ptr, "area"); @@ -378,7 +383,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) clip_planes_from_rect(C, clip_planes, &rect); - dm = mesh_get_derived_final(CTX_data_scene(C), ob, CD_MASK_BAREMESH); + dm = mesh_get_derived_final(&eval_ctx, CTX_data_scene(C), ob, CD_MASK_BAREMESH); pbvh = dm->getPBVH(ob, dm); ob->sculpt->pbvh = pbvh; diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index 5d3ceb3f7df..f3d26b043d3 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -3421,12 +3421,15 @@ static void project_paint_bleed_add_face_user( #endif /* Return true if DM can be painted on, false otherwise */ -static bool proj_paint_state_dm_init(ProjPaintState *ps) +static bool proj_paint_state_dm_init(const bContext *C, ProjPaintState *ps) { + EvaluationContext eval_ctx; + CTX_data_eval_ctx(C, &eval_ctx); + /* Workaround for subsurf selection, try the display mesh first */ if (ps->source == PROJ_SRC_IMAGE_CAM) { /* using render mesh, assume only camera was rendered from */ - ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE); + ps->dm = mesh_create_derived_render(&eval_ctx, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE); ps->dm_release = true; } else if (ps->ob->derivedFinal && @@ -3438,7 +3441,7 @@ static bool proj_paint_state_dm_init(ProjPaintState *ps) } else { ps->dm = mesh_get_derived_final( - ps->scene, ps->ob, + &eval_ctx, ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE | (ps->do_face_sel ? CD_ORIGINDEX : 0)); ps->dm_release = true; } @@ -3818,7 +3821,7 @@ static void project_paint_prepare_all_faces( /* run once per stroke before projection painting */ static void project_paint_begin( - ProjPaintState *ps, + const bContext *C, ProjPaintState *ps, const bool is_multi_view, const char symmetry_flag) { ProjPaintLayerClone layer_clone; @@ -3841,7 +3844,7 @@ static void project_paint_begin( /* paint onto the derived mesh */ if (ps->is_shared_user == false) { - if (!proj_paint_state_dm_init(ps)) { + if (!proj_paint_state_dm_init(C, ps)) { return; } } @@ -5033,7 +5036,7 @@ void paint_proj_stroke( view3d_operator_needs_opengl(C); - if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) { + if (!ED_view3d_autodist(C, graph, ar, v3d, mval_i, cursor, false, NULL)) { return; } @@ -5237,7 +5240,7 @@ void *paint_proj_new_stroke(bContext *C, Object *ob, const float mouse[2], int m PROJ_PAINT_STATE_SHARED_MEMCPY(ps, ps_handle->ps_views[0]); } - project_paint_begin(ps, is_multi_view, symmetry_flag_views[i]); + project_paint_begin(C, ps, is_multi_view, symmetry_flag_views[i]); paint_proj_begin_clone(ps, mouse); @@ -5391,7 +5394,7 @@ static int texture_paint_camera_project_exec(bContext *C, wmOperator *op) ED_image_undo_restore, ED_image_undo_free, NULL); /* allocate and initialize spatial data structures */ - project_paint_begin(&ps, false, 0); + project_paint_begin(C, &ps, false, 0); if (ps.dm == NULL) { BKE_brush_size_set(scene, ps.brush, orig_brush_size); @@ -5450,12 +5453,15 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); SceneLayer *sl = CTX_data_scene_layer(C); + EvaluationContext eval_ctx; ToolSettings *settings = scene->toolsettings; int w = settings->imapaint.screen_grab_size[0]; int h = settings->imapaint.screen_grab_size[1]; int maxsize; char err_out[256] = "unknown"; + CTX_data_eval_ctx(C, &eval_ctx); + RNA_string_get(op->ptr, "filepath", filename); maxsize = GPU_max_texture_size(); @@ -5464,7 +5470,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) if (h > maxsize) h = maxsize; ibuf = ED_view3d_draw_offscreen_imbuf( - scene, sl, CTX_wm_view3d(C), CTX_wm_region(C), + &eval_ctx, scene, sl, CTX_wm_view3d(C), CTX_wm_region(C), w, h, IB_rect, false, R_ALPHAPREMUL, 0, false, NULL, NULL, NULL, err_out); if (!ibuf) { diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h index 69c4621945b..2915f17d9fc 100644 --- a/source/blender/editors/sculpt_paint/paint_intern.h +++ b/source/blender/editors/sculpt_paint/paint_intern.h @@ -127,10 +127,10 @@ unsigned int vpaint_get_current_col(struct Scene *scene, struct VPaint *vp); /* paint_vertex_proj.c */ struct VertProjHandle; struct VertProjHandle *ED_vpaint_proj_handle_create( - struct Scene *scene, struct Object *ob, + const struct bContext *C, struct Scene *scene, struct Object *ob, struct DMCoNo **r_vcosnos); void ED_vpaint_proj_handle_update( - struct VertProjHandle *vp_handle, + const struct bContext *C, struct VertProjHandle *vp_handle, /* runtime vars */ struct ARegion *ar, const float mval_fl[2]); void ED_vpaint_proj_handle_free( diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index 1ac40b0354e..b7159c375cd 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -50,6 +50,8 @@ #include "BKE_paint.h" #include "BKE_subsurf.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -129,6 +131,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) ARegion *ar = CTX_wm_region(C); struct Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; PaintMaskFloodMode mode; float value; PBVH *pbvh; @@ -137,10 +140,12 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) bool multires; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + CTX_data_eval_ctx(C, &eval_ctx); + mode = RNA_enum_get(op->ptr, "mode"); value = RNA_float_get(op->ptr, "value"); - BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); @@ -247,6 +252,7 @@ static void mask_box_select_task_cb(void *userdata, const int i) int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select, bool UNUSED(extend)) { + EvaluationContext eval_ctx; Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; float clip_planes[4][4]; @@ -262,6 +268,8 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r int totnode, symmpass; int symm = sd->paint.symmetry_flags & PAINT_SYMM_AXIS_ALL; + CTX_data_eval_ctx(C, &eval_ctx); + mode = PAINT_MASK_FLOOD_VALUE; value = select ? 1.0 : 0.0; @@ -269,7 +277,7 @@ int ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *r ED_view3d_clipping_calc(&bb, clip_planes, vc->ar, vc->obact, rect); negate_m4(clip_planes); - BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); @@ -405,6 +413,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) const int (*mcords)[2] = WM_gesture_lasso_path_to_array(C, op, &mcords_tot); if (mcords) { + EvaluationContext eval_ctx; float clip_planes[4][4], clip_planes_final[4][4]; BoundBox bb; Object *ob; @@ -420,6 +429,8 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) PaintMaskFloodMode mode = RNA_enum_get(op->ptr, "mode"); float value = RNA_float_get(op->ptr, "value"); + CTX_data_eval_ctx(C, &eval_ctx); + /* Calculations of individual vertices are done in 2D screen space to diminish the amount of * calculations done. Bounding box PBVH collision is not computed against enclosing rectangle * of lasso */ @@ -442,7 +453,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op) ED_view3d_clipping_calc(&bb, clip_planes, vc.ar, vc.obact, &data.rect); negate_m4(clip_planes); - BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, true); pbvh = ob->sculpt->pbvh; multires = (BKE_pbvh_type(pbvh) == PBVH_GRIDS); diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index 21756fc435d..f8c8d8fb41e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -56,6 +56,8 @@ #include "BKE_paint.h" #include "BKE_report.h" +#include "DEG_depsgraph.h" + #include "RNA_access.h" #include "RNA_define.h" @@ -268,9 +270,9 @@ static void imapaint_tri_weights(float matrix[4][4], GLint view[4], } /* compute uv coordinates of mouse in face */ -static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2]) +static void imapaint_pick_uv(EvaluationContext *eval_ctx, Scene *scene, Object *ob, unsigned int faceindex, const int xy[2], float uv[2]) { - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); + DerivedMesh *dm = mesh_get_derived_final(eval_ctx, scene, ob, CD_MASK_BAREMESH); const int tottri = dm->getNumLoopTri(dm); int i, findex; float p[2], w[3], absw, minabsw; @@ -346,13 +348,13 @@ static void imapaint_pick_uv(Scene *scene, Object *ob, unsigned int faceindex, c } /* returns 0 if not found, otherwise 1 */ -static int imapaint_pick_face(ViewContext *vc, const int mval[2], unsigned int *r_index, unsigned int totpoly) +static int imapaint_pick_face(const bContext *C, ViewContext *vc, const int mval[2], unsigned int *r_index, unsigned int totpoly) { if (totpoly == 0) return 0; /* sample only on the exact position */ - *r_index = ED_view3d_backbuf_sample(vc, mval[0], mval[1]); + *r_index = ED_view3d_backbuf_sample(C, vc, mval[0], mval[1]); if ((*r_index) == 0 || (*r_index) > (unsigned int)totpoly) { return 0; @@ -418,6 +420,7 @@ void flip_qt_qt(float out[4], const float in[4], const char symm) void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette) { Scene *scene = CTX_data_scene(C); + EvaluationContext eval_ctx; Paint *paint = BKE_paint_get_active_from_context(C); Palette *palette = BKE_paint_palette(paint); PaletteColor *color = NULL; @@ -425,6 +428,8 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr unsigned int col; const unsigned char *cp; + CTX_data_eval_ctx(C, &eval_ctx); + CLAMP(x, 0, ar->winx); CLAMP(y, 0, ar->winy); @@ -449,7 +454,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr if (ob) { Mesh *me = (Mesh *)ob->data; - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH); + DerivedMesh *dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH); ViewContext vc; const int mval[2] = {x, y}; @@ -461,7 +466,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr view3d_operator_needs_opengl(C); - if (imapaint_pick_face(&vc, mval, &faceindex, totpoly)) { + if (imapaint_pick_face(C, &vc, mval, &faceindex, totpoly)) { Image *image; if (use_material) @@ -474,7 +479,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr if (ibuf && ibuf->rect) { float uv[2]; float u, v; - imapaint_pick_uv(scene, ob, faceindex, mval, uv); + imapaint_pick_uv(&eval_ctx, scene, ob, faceindex, mval, uv); sample_success = true; u = fmodf(uv[0], 1.0f); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index 46d71ad0c45..b395ac5c49d 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -814,7 +814,7 @@ static unsigned int vpaint_blend(VPaint *vp, unsigned int col, unsigned int colo } -static int sample_backbuf_area(ViewContext *vc, int *indexar, int totpoly, int x, int y, float size) +static int sample_backbuf_area(const bContext *C, ViewContext *vc, int *indexar, int totpoly, int x, int y, float size) { struct ImBuf *ibuf; int a, tot = 0, index; @@ -823,7 +823,7 @@ static int sample_backbuf_area(ViewContext *vc, int *indexar, int totpoly, int x * brushes with size > 64, why is this here? */ /*if (size > 64.0) size = 64.0;*/ - ibuf = ED_view3d_backbuf_read(vc, x - size, y - size, x + size, y + size); + ibuf = ED_view3d_backbuf_read(C, vc, x - size, y - size, x + size, y + size); if (ibuf) { unsigned int *rt = ibuf->rect; @@ -2097,7 +2097,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UN } /* painting on subsurfs should give correct points too, this returns me->totvert amount */ - wpd->vp_handle = ED_vpaint_proj_handle_create(scene, ob, &wpd->vertexcosnos); + wpd->vp_handle = ED_vpaint_proj_handle_create(C, scene, ob, &wpd->vertexcosnos); wpd->indexar = get_indexarray(me); copy_wpaint_prev(wp, me->dvert, me->totvert); @@ -2243,7 +2243,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P /* Ugly x2, we need this so hidden faces don't draw */ me->editflag |= ME_EDIT_PAINT_FACE_SEL; } - totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); + totindex = sample_backbuf_area(C, vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); me->editflag = editflag_prev; if (use_face_sel && me->totpoly) { @@ -2264,7 +2264,7 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P } /* incase we have modifiers */ - ED_vpaint_proj_handle_update(wpd->vp_handle, vc->ar, mval); + ED_vpaint_proj_handle_update(C, wpd->vp_handle, vc->ar, mval); /* make sure each vertex gets treated only once */ /* and calculate filter weight */ @@ -2693,7 +2693,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f paint_stroke_set_mode_data(stroke, vpd); view3d_set_viewcontext(C, &vpd->vc); - vpd->vp_handle = ED_vpaint_proj_handle_create(vpd->vc.scene, ob, &vpd->vertexcosnos); + vpd->vp_handle = ED_vpaint_proj_handle_create(C, vpd->vc.scene, ob, &vpd->vertexcosnos); vpd->indexar = get_indexarray(me); vpd->paintcol = vpaint_get_current_col(scene, vp); @@ -2827,7 +2827,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P mul_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat); /* which faces are involved */ - totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); + totindex = sample_backbuf_area(C, vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure); if ((me->editflag & ME_EDIT_PAINT_FACE_SEL) && me->mpoly) { for (index = 0; index < totindex; index++) { @@ -2843,7 +2843,7 @@ static void vpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P swap_m4m4(vc->rv3d->persmat, mat); /* incase we have modifiers */ - ED_vpaint_proj_handle_update(vpd->vp_handle, vc->ar, mval); + ED_vpaint_proj_handle_update(C, vpd->vp_handle, vc->ar, mval); /* clear modified tag for blur tool */ if (vpd->mlooptag) @@ -2980,7 +2980,7 @@ static int weight_from_bones_exec(bContext *C, wmOperator *op) Mesh *me = ob->data; int type = RNA_enum_get(op->ptr, "type"); - create_vgroups_from_armature(op->reports, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); + create_vgroups_from_armature(op->reports, C, scene, ob, armob, type, (me->editflag & ME_EDIT_MIRROR_X)); DEG_id_tag_update(&me->id, 0); WM_event_add_notifier(C, NC_GEOM | ND_DATA, me); @@ -3190,6 +3190,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) struct ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; Mesh *me = ob->data; int x_start = RNA_int_get(op->ptr, "xstart"); int y_start = RNA_int_get(op->ptr, "ystart"); @@ -3198,7 +3199,11 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) float sco_start[2] = {x_start, y_start}; float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); - DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask); + DerivedMesh *dm; + + CTX_data_eval_ctx(C, &eval_ctx); + + dm = mesh_get_derived_final(&eval_ctx, scene, ob, scene->customdata_mask); DMGradient_userData data = {NULL}; diff --git a/source/blender/editors/sculpt_paint/paint_vertex_proj.c b/source/blender/editors/sculpt_paint/paint_vertex_proj.c index c939eb6df35..c9915a294ad 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_proj.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_proj.c @@ -42,6 +42,8 @@ #include "BKE_DerivedMesh.h" #include "BKE_context.h" +#include "DEG_depsgraph.h" + #include "ED_screen.h" #include "ED_view3d.h" @@ -98,13 +100,16 @@ static void vpaint_proj_dm_map_cosnos_init__map_cb(void *userData, int index, co } } -static void vpaint_proj_dm_map_cosnos_init(Scene *scene, Object *ob, +static void vpaint_proj_dm_map_cosnos_init(const bContext *C, Scene *scene, Object *ob, struct VertProjHandle *vp_handle) { + EvaluationContext eval_ctx; Mesh *me = ob->data; DerivedMesh *dm; - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + CTX_data_eval_ctx(C, &eval_ctx); + + dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); if (dm->foreachMappedVert) { memset(vp_handle->vcosnos, 0, sizeof(DMCoNo) * me->totvert); @@ -169,11 +174,14 @@ static void vpaint_proj_dm_map_cosnos_update__map_cb(void *userData, int index, } } -static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle, +static void vpaint_proj_dm_map_cosnos_update(const bContext *C, struct VertProjHandle *vp_handle, ARegion *ar, const float mval_fl[2]) { + EvaluationContext eval_ctx; struct VertProjUpdate vp_update = {vp_handle, ar, mval_fl}; + CTX_data_eval_ctx(C, &eval_ctx); + Scene *scene = vp_handle->scene; Object *ob = vp_handle->ob; Mesh *me = ob->data; @@ -182,7 +190,7 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle, /* quick sanity check - we shouldn't have to run this if there are no modifiers */ BLI_assert(BLI_listbase_is_empty(&ob->modifiers) == false); - dm = mesh_get_derived_final(scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); + dm = mesh_get_derived_final(&eval_ctx, scene, ob, CD_MASK_BAREMESH | CD_MASK_ORIGINDEX); /* highly unlikely this will become unavailable once painting starts (perhaps with animated modifiers) */ if (LIKELY(dm->foreachMappedVert)) { @@ -198,7 +206,7 @@ static void vpaint_proj_dm_map_cosnos_update(struct VertProjHandle *vp_handle, /* -------------------------------------------------------------------- */ /* Public Functions */ -struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob, +struct VertProjHandle *ED_vpaint_proj_handle_create(const bContext *C, Scene *scene, Object *ob, DMCoNo **r_vcosnos) { struct VertProjHandle *vp_handle = MEM_mallocN(sizeof(struct VertProjHandle), __func__); @@ -209,7 +217,7 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob, vp_handle->use_update = false; /* sets 'use_update' if needed */ - vpaint_proj_dm_map_cosnos_init(scene, ob, vp_handle); + vpaint_proj_dm_map_cosnos_init(C, scene, ob, vp_handle); if (vp_handle->use_update) { vp_handle->dists_sq = MEM_mallocN(sizeof(float) * me->totvert, __func__); @@ -228,11 +236,11 @@ struct VertProjHandle *ED_vpaint_proj_handle_create(Scene *scene, Object *ob, return vp_handle; } -void ED_vpaint_proj_handle_update(struct VertProjHandle *vp_handle, +void ED_vpaint_proj_handle_update(const bContext *C, struct VertProjHandle *vp_handle, ARegion *ar, const float mval_fl[2]) { if (vp_handle->use_update) { - vpaint_proj_dm_map_cosnos_update(vp_handle, ar, mval_fl); + vpaint_proj_dm_map_cosnos_update(C, vp_handle, ar, mval_fl); } } diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 9be196d1561..922e72467f2 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4394,10 +4394,13 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob) SculptSession *ss = ob->sculpt; if (ss->kb || ss->modifiers_active) { + EvaluationContext eval_ctx; Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); - BKE_sculpt_update_mesh_elements(CTX_data_scene(C), sd, ob, + CTX_data_eval_ctx(C, &eval_ctx); + + BKE_sculpt_update_mesh_elements(&eval_ctx, CTX_data_scene(C), sd, ob, sculpt_any_smooth_mode(brush, ss->cache, 0), false); } } @@ -4554,12 +4557,15 @@ static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; + EvaluationContext eval_ctx; SculptSession *ss = CTX_data_active_object(C)->sculpt; Brush *brush = BKE_paint_brush(&sd->paint); int mode = RNA_enum_get(op->ptr, "mode"); bool is_smooth; bool need_mask = false; + CTX_data_eval_ctx(C, &eval_ctx); + if (brush->sculpt_tool == SCULPT_TOOL_MASK) { need_mask = true; } @@ -4568,7 +4574,7 @@ static bool sculpt_brush_stroke_init(bContext *C, wmOperator *op) sculpt_brush_init_tex(scene, sd, ss); is_smooth = sculpt_any_smooth_mode(brush, NULL, mode); - BKE_sculpt_update_mesh_elements(scene, sd, ob, is_smooth, need_mask); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, is_smooth, need_mask); return 1; } @@ -4995,10 +5001,13 @@ void sculpt_update_after_dynamic_topology_toggle(bContext *C) { Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; Sculpt *sd = scene->toolsettings->sculpt; + CTX_data_eval_ctx(C, &eval_ctx); + /* Create the PBVH */ - BKE_sculpt_update_mesh_elements(scene, sd, ob, false, false); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, false, false); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); } @@ -5332,11 +5341,15 @@ static void SCULPT_OT_symmetrize(wmOperatorType *ot) /**** Toggle operator for turning sculpt mode on or off ****/ -static void sculpt_init_session(Scene *scene, Object *ob) +static void sculpt_init_session(const bContext *C, Scene *scene, Object *ob) { + EvaluationContext eval_ctx; + + CTX_data_eval_ctx(C, &eval_ctx); + ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session"); - BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 0, false); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, scene->toolsettings->sculpt, ob, 0, false); } @@ -5428,7 +5441,7 @@ static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) if (ob->sculpt) BKE_sculptsession_free(ob); - sculpt_init_session(scene, ob); + sculpt_init_session(C, scene, ob); /* Mask layer is required */ if (mmd) { diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index 9d55cc1369e..a10c7477dc6 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -127,9 +127,12 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN Scene *scene = CTX_data_scene(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; SculptSession *ss = ob->sculpt; MVert *mvert; int *index; + + CTX_data_eval_ctx(C, &eval_ctx); if (unode->maxvert) { /* regular mesh restore */ @@ -143,7 +146,7 @@ static bool sculpt_undo_restore_coords(bContext *C, DerivedMesh *dm, SculptUndoN if (kb) { ob->shapenr = BLI_findindex(&key->block, kb) + 1; - BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, false); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, false); WM_event_add_notifier(C, NC_OBJECT | ND_DATA, ob); } else { @@ -451,6 +454,7 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) Scene *scene = CTX_data_scene(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; Object *ob = CTX_data_active_object(C); + EvaluationContext eval_ctx; DerivedMesh *dm; SculptSession *ss = ob->sculpt; SculptUndoNode *unode; @@ -458,6 +462,8 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) bool need_mask = false; bool partial_update = true; + CTX_data_eval_ctx(C, &eval_ctx); + for (unode = lb->first; unode; unode = unode->next) { if (STREQ(unode->idname, ob->id.name)) { if (unode->type == SCULPT_UNDO_MASK) { @@ -469,10 +475,10 @@ static void sculpt_undo_restore(bContext *C, ListBase *lb) } } - BKE_sculpt_update_mesh_elements(scene, sd, ob, 0, need_mask); + BKE_sculpt_update_mesh_elements(&eval_ctx, scene, sd, ob, 0, need_mask); /* call _after_ sculpt_update_mesh_elements() which may update 'ob->derivedFinal' */ - dm = mesh_get_derived_final(scene, ob, 0); + dm = mesh_get_derived_final(&eval_ctx, scene, ob, 0); if (lb->first && sculpt_undo_bmesh_restore(C, lb->first, ob, ss)) return; |