diff options
Diffstat (limited to 'source/blender/editors')
90 files changed, 350 insertions, 302 deletions
diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 5daf6b584e5..3fd74cc3ca7 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -195,7 +195,9 @@ void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob, bool curre } Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some + * nested pointers, like animation data. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ListBase targets = {NULL, NULL}; bool free_depsgraph = false; diff --git a/source/blender/editors/armature/pose_lib.c b/source/blender/editors/armature/pose_lib.c index 3407b3e6b7f..4cda7f264aa 100644 --- a/source/blender/editors/armature/pose_lib.c +++ b/source/blender/editors/armature/pose_lib.c @@ -1731,9 +1731,6 @@ static void poselib_preview_cleanup(bContext *C, wmOperator *op) if (IS_AUTOKEY_MODE(scene, NORMAL)) { // remake_action_ipos(ob->action); } - else { - BKE_pose_where_is(CTX_data_depsgraph(C), scene, ob); - } } /* Request final redraw of the view. */ diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index 4c5a42cade6..ae9401fb430 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1373,7 +1373,7 @@ void POSE_OT_push(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1435,7 +1435,7 @@ void POSE_OT_relax(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1496,7 +1496,7 @@ void POSE_OT_push_rest(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1558,7 +1558,7 @@ void POSE_OT_relax_rest(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -1620,7 +1620,7 @@ void POSE_OT_breakdown(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* Properties */ pose_slide_opdef_properties(ot); @@ -2025,7 +2025,7 @@ void POSE_OT_propagate(wmOperatorType *ot) ot->poll = ED_operator_posemode; /* XXX: needs selected bones! */ /* flag */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ /* TODO: add "fade out" control for tapering off amount of propagation as time goes by? */ diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 224bbb1d79f..854fb237929 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -71,7 +71,15 @@ * that are bone-parented to armature */ static void applyarmature_fix_boneparents(const bContext *C, Scene *scene, Object *armob) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Depsgraph has been ensured to be evaluated at the beginning of the operator. + * + * Must not evaluate depsgraph here yet, since this will ruin object matrix which we want to + * preserve after other changes has been done in the operator. + * + * TODO(sergey): This seems very similar to `ignore_parent_tx()`, which was now ensured to work + * quite reliably. Can we de-duplicate the code? Or at least verify we don't need an extra logic + * in this function. */ + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Main *bmain = CTX_data_main(C); Object workob, *ob; @@ -318,7 +326,7 @@ static void applyarmature_process_selected_rec(bArmature *arm, static int apply_armature_pose2bones_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); // must be active object, not edit-object Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); @@ -422,7 +430,7 @@ void POSE_OT_armature_apply(wmOperatorType *ot) ot->ui = apply_armature_pose2bones_ui; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "selected", @@ -436,7 +444,7 @@ static int pose_visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob) { /* loop over all selected pchans @@ -1026,6 +1034,7 @@ static int pose_clear_transform_generic_exec(bContext *C, void (*clear_func)(bPoseChannel *), const char default_ksName[]) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); bool changed_multi = false; @@ -1041,8 +1050,8 @@ static int pose_clear_transform_generic_exec(bContext *C, ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); FOREACH_OBJECT_IN_MODE_BEGIN (view_layer, v3d, OB_ARMATURE, OB_MODE_POSE, ob_iter) { - Object *ob_eval = DEG_get_evaluated_object( - CTX_data_depsgraph(C), ob_iter); // XXX: UGLY HACK (for autokey + clear transforms) + // XXX: UGLY HACK (for autokey + clear transforms) + Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob_iter); ListBase dsources = {NULL, NULL}; bool changed = false; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index d1d43a49826..047b78af7b1 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -7094,16 +7094,17 @@ static bool match_texture_space_poll(bContext *C) static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); + /* Need to ensure the dependency graph is fully evaluated, so the display list is at a correct + * state. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + (void)depsgraph; + Object *object = CTX_data_active_object(C); Curve *curve = (Curve *)object->data; float min[3], max[3], size[3], loc[3]; int a; - if (object->runtime.curve_cache == NULL) { - BKE_displist_make_curveTypes(depsgraph, scene, object, false, false); - } + BLI_assert(object->runtime.curve_cache != NULL); INIT_MINMAX(min, max); BKE_displist_minmax(&object->runtime.curve_cache->disp, min, max); diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c index 9debea7bf88..5e0053782d4 100644 --- a/source/blender/editors/curve/editcurve_paint.c +++ b/source/blender/editors/curve/editcurve_paint.c @@ -586,7 +586,7 @@ static bool curve_draw_init(bContext *C, wmOperator *op, bool is_invoke) } else { cdd->vc.bmain = CTX_data_main(C); - cdd->vc.depsgraph = CTX_data_depsgraph(C); + cdd->vc.depsgraph = CTX_data_ensure_evaluated_depsgraph(C); cdd->vc.scene = CTX_data_scene(C); cdd->vc.view_layer = CTX_data_view_layer(C); cdd->vc.obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index db3d5ad401d..c912cea5937 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -407,7 +407,6 @@ static int insert_into_textbuf(Object *obedit, uintptr_t c) static void text_update_edited(bContext *C, Object *obedit, int mode) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Curve *cu = obedit->data; EditFont *ef = cu->editfont; @@ -421,6 +420,7 @@ static void text_update_edited(bContext *C, Object *obedit, int mode) else { /* depsgraph runs above, but since we're not tagging for update, call direct */ /* We need evaluated data here. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); BKE_vfont_to_curve(DEG_get_evaluated_object(depsgraph, obedit), mode); } @@ -590,7 +590,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) static void txt_add_object(bContext *C, TextLine *firstline, int totline, const float offset[3]) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Curve *cu; @@ -1084,7 +1084,7 @@ static const EnumPropertyItem move_type_items[] = { static int move_cursor(bContext *C, int type, const bool select) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obedit = CTX_data_edit_object(C); Curve *cu = obedit->data; EditFont *ef = cu->editfont; diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index ce62171ccb0..ae43894b7b6 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -125,6 +125,8 @@ void ED_gizmo_draw_preset_circle(const struct wmGizmo *gz, void ED_gizmo_draw_preset_facemap( const bContext *C, const struct wmGizmo *gz, Object *ob, const int facemap, int select_id) { + /* Dependency graph is supposed to be evaluated prior to draw. */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); const bool is_select = (select_id != -1); const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; @@ -137,7 +139,7 @@ void ED_gizmo_draw_preset_facemap( GPU_matrix_push(); GPU_matrix_mul(ob->obmat); - ED_draw_object_facemap(CTX_data_depsgraph(C), ob, color, facemap); + ED_draw_object_facemap(depsgraph, ob, color, facemap); GPU_matrix_pop(); if (is_select) { diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c index f9ad836b054..21f779b72b1 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c @@ -363,7 +363,7 @@ static int gizmo_move_invoke(bContext *C, wmGizmo *gz, const wmEvent *event) inter->snap_context_v3d = ED_transform_snap_object_context_create_view3d( CTX_data_main(C), CTX_data_scene(C), - CTX_data_depsgraph(C), + CTX_data_ensure_evaluated_depsgraph(C), 0, CTX_wm_region(C), CTX_wm_view3d(C)); diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 5793b407bdc..e59e5d6a878 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1073,7 +1073,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p) /* pass on current scene and window */ p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); - p->depsgraph = CTX_data_depsgraph(C); + p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); unit_m4(p->imat); @@ -1630,7 +1630,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) } /* init painting data */ - gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C)); if (p->status == GP_STATUS_ERROR) { gpencil_draw_exit(C, op); return 0; @@ -1903,7 +1903,7 @@ static void annotation_draw_apply_event( static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* printf("GPencil - Starting Re-Drawing\n"); */ @@ -2057,7 +2057,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { @@ -2098,7 +2098,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) * it'd be nice to allow changing paint-mode when in sketching-sessions */ if (gp_session_initdata(C, p)) { - gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, p->paintmode, CTX_data_ensure_evaluated_depsgraph(C)); } if (p->status != GP_STATUS_ERROR) { @@ -2133,6 +2133,7 @@ static void annotation_add_missing_events(bContext *C, const wmEvent *event, tGPsdata *p) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float pt[2], a[2], b[2]; float factor = 10.0f; @@ -2148,7 +2149,7 @@ static void annotation_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, 0.5f); sub_v2_v2v2(pt, b, pt); /* create fake event */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]); } else if (dist >= factor) { int slices = 2 + (int)((dist - 1.0) / factor); @@ -2157,7 +2158,7 @@ static void annotation_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, n * i); sub_v2_v2v2(pt, b, pt); /* create fake event */ - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + annotation_draw_apply_event(op, event, depsgraph, pt[0], pt[1]); } } } @@ -2387,7 +2388,8 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) annotation_add_missing_events(C, op, event, p); } - annotation_draw_apply_event(op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + /* TODO(sergey): Possibly evaluating dependency graph from modal operator? */ + annotation_draw_apply_event(op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 809acc3b322..0c2af982279 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -1117,7 +1117,8 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in RegionView3D *rv3d = ar->regiondata; tGPDinterpolate_layer *tgpil; Object *obact = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Drawing code is expected to run with fully evaluated depsgraph. */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); float color[4]; diff --git a/source/blender/editors/gpencil/gpencil_armature.c b/source/blender/editors/gpencil/gpencil_armature.c index 08f752bb72e..9e70be323eb 100644 --- a/source/blender/editors/gpencil/gpencil_armature.c +++ b/source/blender/editors/gpencil/gpencil_armature.c @@ -554,7 +554,7 @@ static bool gpencil_generate_weights_poll(bContext *C) static int gpencil_generate_weights_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = CTX_data_active_object(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c index d97207baed8..1a7422cd174 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1650,7 +1650,7 @@ static bool gpsculpt_brush_do_frame( static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso) { ToolSettings *ts = CTX_data_tool_settings(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = gso->object; bGPdata *gpd = gso->gpd; bool changed = false; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 3543a370bd0..4a91a90c075 100644 --- a/source/blender/editors/gpencil/gpencil_convert.c +++ b/source/blender/editors/gpencil/gpencil_convert.c @@ -162,7 +162,10 @@ static void gp_strokepoint_convertcoords(bContext *C, Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): This function might be called from a loop, but no tagging is happening in it, + * so it's not that expensive to ensure evaluated depsgraph here. However, ideally all the + * parameters are to wrapped into a context style struct and queried from Context once.*/ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); bGPDspoint mypt, *pt; @@ -1241,7 +1244,7 @@ static int gp_camera_view_subrect(bContext *C, rctf *subrect) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, subrect, true); return 1; } diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 0ee4fd20f0f..696c98c6646 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -2200,7 +2200,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_active = CTX_data_active_object(C); bGPdata *gpd_dst = NULL; bool ok = false; diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 0fc051e4756..5833e8b84b9 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -139,7 +139,6 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) const int back = RNA_boolean_get(op->ptr, "back"); struct wmMsgBus *mbus = CTX_wm_message_bus(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); bGPdata *gpd = ED_gpencil_data_get_active(C); bool is_object = false; short mode; @@ -159,6 +158,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op) gpd->flag ^= GP_DATA_STROKE_EDITMODE; /* recalculate parent matrix */ if (gpd->flag & GP_DATA_STROKE_EDITMODE) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_gpencil_reset_layers_parent(depsgraph, ob, gpd); } /* set mode */ @@ -1381,7 +1381,7 @@ void GPENCIL_OT_paste(wmOperatorType *ot) ot->poll = gp_strokes_paste_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum(ot->srna, "type", copy_type, 0, "Type", ""); @@ -2495,7 +2495,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op)) RegionView3D *rv3d = CTX_wm_region_data(C); View3D *v3d = CTX_wm_view3d(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); const float gridf = ED_view3d_grid_view_scale(scene, v3d, rv3d, NULL); @@ -2570,7 +2570,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); const bool use_offset = RNA_boolean_get(op->ptr, "use_offset"); @@ -2663,7 +2663,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op)) Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = CTX_data_active_object(C); float *cursor = scene->cursor.location; @@ -3374,7 +3374,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op) bGPdata *gpd = ED_gpencil_data_get_active(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = CTX_data_tool_settings(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; @@ -3537,7 +3537,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot) ot->poll = gp_strokes_edit3d_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum( @@ -4527,7 +4527,7 @@ void GPENCIL_OT_stroke_cutter(wmOperatorType *ot) ot->cancel = WM_gesture_lasso_cancel; /* flag */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_lasso(ot); diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c index 1ac4471547e..5637e755198 100644 --- a/source/blender/editors/gpencil/gpencil_fill.c +++ b/source/blender/editors/gpencil/gpencil_fill.c @@ -1213,7 +1213,7 @@ static tGPDfill *gp_session_init_fill(bContext *C, wmOperator *UNUSED(op)) tgpf->ar = CTX_wm_region(C); tgpf->rv3d = tgpf->ar->regiondata; tgpf->v3d = tgpf->sa->spacedata.first; - tgpf->depsgraph = CTX_data_depsgraph(C); + tgpf->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpf->win = CTX_wm_window(C); /* set GP datablock */ diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index e28e83b23b0..a8a3c2f9306 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -599,7 +599,7 @@ struct GP_EditableStrokes_Iter { #define GP_EDITABLE_STROKES_BEGIN(gpstroke_iter, C, gpl, gps) \ { \ struct GP_EditableStrokes_Iter gpstroke_iter = {{{0}}}; \ - Depsgraph *depsgraph_ = CTX_data_depsgraph(C); \ + Depsgraph *depsgraph_ = CTX_data_ensure_evaluated_depsgraph(C); \ Object *obact_ = CTX_data_active_object(C); \ bGPdata *gpd_ = CTX_data_gpencil_data(C); \ const bool is_multiedit_ = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd_); \ diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 5af355b908d..a271274fa71 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1894,7 +1894,7 @@ static bool gp_session_initdata(bContext *C, wmOperator *op, tGPsdata *p) p->C = C; p->bmain = CTX_data_main(C); p->scene = CTX_data_scene(C); - p->depsgraph = CTX_data_depsgraph(C); + p->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); p->win = CTX_wm_window(C); p->disable_fill = RNA_boolean_get(op->ptr, "disable_fill"); @@ -2431,7 +2431,7 @@ static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event) } /* init painting data */ - gp_paint_initstroke(p, paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, paintmode, CTX_data_ensure_evaluated_depsgraph(C)); if (p->status == GP_STATUS_ERROR) { gpencil_draw_exit(C, op); return 0; @@ -2825,10 +2825,10 @@ static void gpencil_draw_apply_event( float pt[2]; copy_v2_v2(tmp, p->mval); sub_v2_v2v2(pt, p->mval, p->mvali); - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); if (len_v2v2(p->mval, p->mvalo)) { sub_v2_v2v2(pt, p->mval, p->mvalo); - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } copy_v2_v2(p->mval, tmp); } @@ -2948,7 +2948,7 @@ static void gpencil_draw_apply_event( static int gpencil_draw_exec(bContext *C, wmOperator *op) { tGPsdata *p = NULL; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* printf("GPencil - Starting Re-Drawing\n"); */ @@ -3196,7 +3196,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event p->status = GP_STATUS_PAINTING; /* handle the initial drawing - i.e. for just doing a simple dot */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + gpencil_draw_apply_event(C, op, event, CTX_data_ensure_evaluated_depsgraph(C), 0.0f, 0.0f); op->flag |= OP_IS_MODAL_CURSOR_REGION; } else { @@ -3260,7 +3260,7 @@ static tGPsdata *gpencil_stroke_begin(bContext *C, wmOperator *op) * it'd be nice to allow changing paint-mode when in sketching-sessions */ if (gp_session_initdata(C, op, p)) { - gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph(C)); + gp_paint_initstroke(p, p->paintmode, CTX_data_depsgraph_pointer(C)); } if (p->status != GP_STATUS_ERROR) { @@ -3321,6 +3321,7 @@ static void gpencil_add_missing_events(bContext *C, { Brush *brush = p->brush; GP_Sculpt_Guide *guide = &p->scene->toolsettings->gp_sculpt.guide; + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); int input_samples = brush->gpencil_settings->input_samples; /* ensure sampling when using circular guide */ @@ -3379,7 +3380,7 @@ static void gpencil_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, 0.5f); sub_v2_v2v2(pt, b, pt); /* create fake event */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } else if (dist >= factor) { int slices = 2 + (int)((dist - 1.0) / factor); @@ -3388,7 +3389,7 @@ static void gpencil_add_missing_events(bContext *C, interp_v2_v2v2(pt, a, b, n * i); sub_v2_v2v2(pt, b, pt); /* create fake event */ - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), pt[0], pt[1]); + gpencil_draw_apply_event(C, op, event, depsgraph, pt[0], pt[1]); } } } @@ -3695,7 +3696,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event) gpencil_add_missing_events(C, op, event, p); } - gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph(C), 0.0f, 0.0f); + gpencil_draw_apply_event(C, op, event, CTX_data_depsgraph_pointer(C), 0.0f, 0.0f); /* finish painting operation if anything went wrong just now */ if (p->status == GP_STATUS_ERROR) { diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index c79366e6a2b..bdc65e7172a 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1109,7 +1109,7 @@ static void gpencil_primitive_init(bContext *C, wmOperator *op) tgpi->ar = CTX_wm_region(C); tgpi->rv3d = tgpi->ar->regiondata; tgpi->v3d = tgpi->sa->spacedata.first; - tgpi->depsgraph = CTX_data_depsgraph(C); + tgpi->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); tgpi->win = CTX_wm_window(C); /* save original type */ diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index b1d9bcfbe16..5a962809954 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -989,7 +989,7 @@ void GPENCIL_OT_select_circle(wmOperatorType *ot) ot->cancel = WM_gesture_circle_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_circle(ot); @@ -1180,7 +1180,7 @@ void GPENCIL_OT_select_box(wmOperatorType *ot) ot->poll = gpencil_select_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ WM_operator_properties_gesture_box(ot); @@ -1248,7 +1248,7 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) ot->cancel = WM_gesture_lasso_cancel; /* flags */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_select_operation(ot); @@ -1468,7 +1468,7 @@ void GPENCIL_OT_select(wmOperatorType *ot) ot->poll = gpencil_select_poll; /* flag */ - ot->flag = OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_UNDO; /* properties */ WM_operator_properties_mouse_select(ot); diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index ac8196f5ed0..ab9c3bb17da 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -259,7 +259,7 @@ bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C) ID *screen_id = (ID *)CTX_wm_screen(C); ScrArea *sa = CTX_wm_area(C); - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob = CTX_data_active_object(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); @@ -548,7 +548,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) if (sa->spacetype == SPACE_VIEW3D) { wmWindow *win = CTX_wm_window(C); Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = (View3D *)CTX_wm_space_data(C); RegionView3D *rv3d = ar->regiondata; @@ -560,8 +560,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc) /* for camera view set the subrect */ if (rv3d->persp == RV3D_CAMOB) { - ED_view3d_calc_camera_border( - scene, CTX_data_depsgraph(C), ar, v3d, rv3d, &r_gsc->subrect_data, true); + ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &r_gsc->subrect_data, true); r_gsc->subrect = &r_gsc->subrect_data; } } @@ -929,7 +928,7 @@ void ED_gp_get_drawing_reference( void ED_gpencil_project_stroke_to_view(bContext *C, bGPDlayer *gpl, bGPDstroke *gps) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); bGPdata *gpd = (bGPdata *)ob->data; GP_SpaceConversion gsc = {NULL}; diff --git a/source/blender/editors/include/ED_mesh.h b/source/blender/editors/include/ED_mesh.h index d2613facd83..5ebba4e5d25 100644 --- a/source/blender/editors/include/ED_mesh.h +++ b/source/blender/editors/include/ED_mesh.h @@ -254,7 +254,10 @@ void ED_operatormacros_mesh(void); void ED_keymap_mesh(struct wmKeyConfig *keyconf); /* editmesh_tools.c (could be moved) */ -void EDBM_project_snap_verts(struct bContext *C, struct ARegion *ar, struct BMEditMesh *em); +void EDBM_project_snap_verts(struct bContext *C, + struct Depsgraph *depsgraph, + struct ARegion *ar, + struct BMEditMesh *em); /* editface.c */ void paintface_flush_flags(struct bContext *C, struct Object *ob, short flag); diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 751f71cc53b..14e18c8bec5 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -76,6 +76,10 @@ enum eGPUFXFlags; typedef struct ViewContext { struct bContext *C; struct Main *bmain; + /* Dependency graph is uses for depth drawing, viewport camera matrix access, and also some areas + * are re-using this to access evaluated entities. + * + * Moral of the story: assign to a fully evaluated state. */ struct Depsgraph *depsgraph; struct Scene *scene; struct ViewLayer *view_layer; diff --git a/source/blender/editors/interface/interface_eyedropper_depth.c b/source/blender/editors/interface/interface_eyedropper_depth.c index fc60fc06ac0..2e51701e01d 100644 --- a/source/blender/editors/interface/interface_eyedropper_depth.c +++ b/source/blender/editors/interface/interface_eyedropper_depth.c @@ -168,7 +168,7 @@ static void depthdropper_depth_sample_pt( if (sa->spacetype == SPACE_VIEW3D) { ARegion *ar = BKE_area_find_region_xy(sa, RGN_TYPE_WINDOW, mx, my); if (ar) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); View3D *v3d = sa->spacedata.first; RegionView3D *rv3d = ar->regiondata; /* weak, we could pass in some reference point */ diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 9fdcec71cfd..ff2bc72c2f7 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -147,7 +147,7 @@ static int cachefile_reload_exec(bContext *C, wmOperator *UNUSED(op)) return OPERATOR_CANCELLED; } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); BKE_cachefile_reload(depsgraph, cache_file); return OPERATOR_FINISHED; diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c index 883dfe9ad7c..683e6d8a2b0 100644 --- a/source/blender/editors/mask/mask_add.c +++ b/source/blender/editors/mask/mask_add.c @@ -72,7 +72,7 @@ bool ED_mask_find_nearest_diff_point(const bContext *C, float u = 0.0f; float scalex, scaley; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); diff --git a/source/blender/editors/mask/mask_ops.c b/source/blender/editors/mask/mask_ops.c index 8e4efddd8a7..c91f431ad20 100644 --- a/source/blender/editors/mask/mask_ops.c +++ b/source/blender/editors/mask/mask_ops.c @@ -86,7 +86,7 @@ MaskSplinePoint *ED_mask_point_find_nearest(const bContext *C, eMaskWhichHandle which_handle = MASK_WHICH_HANDLE_NONE; int width, height; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); @@ -241,7 +241,7 @@ bool ED_mask_feather_find_nearest(const bContext *C, float scalex, scaley; int width, height; - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mask *mask_eval = (Mask *)DEG_get_evaluated_id(depsgraph, &mask_orig->id); ED_mask_get_size(sa, &width, &height); diff --git a/source/blender/editors/mesh/editface.c b/source/blender/editors/mesh/editface.c index d61c340f7a2..9a70b0a8d36 100644 --- a/source/blender/editors/mesh/editface.c +++ b/source/blender/editors/mesh/editface.c @@ -77,7 +77,7 @@ void paintface_flush_flags(struct bContext *C, Object *ob, short flag) BKE_mesh_flush_select_from_polys(me); } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); if (ob_eval == NULL) { diff --git a/source/blender/editors/mesh/editmesh_extrude.c b/source/blender/editors/mesh/editmesh_extrude.c index 0da4d20c6b5..5b16cfd00f5 100644 --- a/source/blender/editors/mesh/editmesh_extrude.c +++ b/source/blender/editors/mesh/editmesh_extrude.c @@ -658,6 +658,7 @@ void MESH_OT_extrude_faces_indiv(wmOperatorType *ot) static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const wmEvent *event) { + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewContext vc; BMVert *v1; BMIter iter; @@ -819,7 +820,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w /* also project the source, for retopo workflow */ if (use_proj) { - EDBM_project_snap_verts(C, vc.ar, vc.em); + EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em); } } @@ -852,7 +853,7 @@ static int edbm_dupli_extrude_cursor_invoke(bContext *C, wmOperator *op, const w } if (use_proj) { - EDBM_project_snap_verts(C, vc.ar, vc.em); + EDBM_project_snap_verts(C, depsgraph, vc.ar, vc.em); } /* This normally happens when pushing undo but modal operators diff --git a/source/blender/editors/mesh/editmesh_knife_project.c b/source/blender/editors/mesh/editmesh_knife_project.c index 13bcb1334a9..3d34a4ad3b5 100644 --- a/source/blender/editors/mesh/editmesh_knife_project.c +++ b/source/blender/editors/mesh/editmesh_knife_project.c @@ -57,7 +57,7 @@ static LinkNode *knifeproject_poly_from_object(const bContext *C, Object *ob, LinkNode *polys) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ARegion *ar = CTX_wm_region(C); struct Mesh *me_eval; bool me_eval_needs_free; @@ -173,7 +173,7 @@ void MESH_OT_knife_project(wmOperatorType *ot) ot->poll = ED_operator_editmesh_region_view3d; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING; /* parameters */ RNA_def_boolean(ot->srna, diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index c7606758b63..2ddd654f824 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -272,7 +272,7 @@ static int ringsel_init(bContext *C, wmOperator *op, bool do_cut) em_setup_viewcontext(C, &lcd->vc); - lcd->depsgraph = CTX_data_depsgraph(C); + lcd->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* assign the drawing handle for drawing preview line... */ lcd->ar = CTX_wm_region(C); diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index 3b5c8e9f101..ecdf103e6eb 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -411,7 +411,7 @@ void MESH_OT_unsubdivide(wmOperatorType *ot) ot->srna, "iterations", 2, 1, 1000, "Iterations", "Number of times to unsubdivide", 1, 100); } -void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) +void EDBM_project_snap_verts(bContext *C, Depsgraph *depsgraph, ARegion *ar, BMEditMesh *em) { Main *bmain = CTX_data_main(C); Object *obedit = em->ob; @@ -421,7 +421,7 @@ void EDBM_project_snap_verts(bContext *C, ARegion *ar, BMEditMesh *em) ED_view3d_init_mats_rv3d(obedit, ar->regiondata); struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ar, CTX_wm_view3d(C)); + bmain, CTX_data_scene(C), depsgraph, 0, ar, CTX_wm_view3d(C)); BM_ITER_MESH (eve, &iter, em->bm, BM_VERTS_OF_MESH) { if (BM_elem_flag_test(eve, BM_ELEM_SELECT)) { diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index 41736fb9a14..b082af352b2 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -311,7 +311,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* count & check */ CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) { @@ -674,7 +674,7 @@ int join_mesh_shapes_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); Object *ob_active = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = (Mesh *)ob_active->data; Mesh *selme = NULL; Mesh *me_deformed = NULL; @@ -1165,7 +1165,7 @@ static void ed_mesh_pick_face_vert__mpoly_find( bool ED_mesh_pick_face_vert( bContext *C, Object *ob, const int mval[2], uint dist_px, uint *r_index) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); unsigned int poly_index; Mesh *me = ob->data; diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index f8cf55933aa..137af917f9a 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -236,7 +236,7 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], { Object *ob = base->object; Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (!scene) { return; @@ -250,7 +250,11 @@ void ED_object_base_init_transform(bContext *C, Base *base, const float loc[3], copy_v3_v3(ob->rot, rot); } - BKE_object_where_is_calc(depsgraph, scene, ob); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + BKE_object_transform_copy(object_eval, ob); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); + BKE_object_transform_copy(ob, object_eval); } /* Uses context to figure out transform for primitive. @@ -1758,12 +1762,15 @@ static bool dupliobject_instancer_cmp(const void *a_, const void *b_) return false; } -static void make_object_duplilist_real( - bContext *C, Scene *scene, Base *base, const bool use_base_parent, const bool use_hierarchy) +static void make_object_duplilist_real(bContext *C, + Depsgraph *depsgraph, + Scene *scene, + Base *base, + const bool use_base_parent, + const bool use_hierarchy) { Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); ListBase *lb_duplis; DupliObject *dob; GHash *dupli_gh, *parent_gh = NULL, *instancer_gh = NULL; @@ -1955,6 +1962,7 @@ static void make_object_duplilist_real( static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); const bool use_base_parent = RNA_boolean_get(op->ptr, "use_base_parent"); @@ -1963,7 +1971,7 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) BKE_main_id_clear_newpoins(bmain); CTX_DATA_BEGIN (C, Base *, base, selected_editable_bases) { - make_object_duplilist_real(C, scene, base, use_base_parent, use_hierarchy); + make_object_duplilist_real(C, depsgraph, scene, base, use_base_parent, use_hierarchy); /* dependencies were changed */ WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, base->object); @@ -1990,7 +1998,7 @@ void OBJECT_OT_duplicates_make_real(wmOperatorType *ot) ot->poll = ED_operator_objectmode; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; RNA_def_boolean(ot->srna, "use_base_parent", @@ -2131,7 +2139,7 @@ static Base *duplibase_for_convert( static int convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Base *basen = NULL, *basact = NULL; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 5ef133e87de..7343dba420f 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -864,13 +864,12 @@ void CONSTRAINT_OT_limitdistance_reset(wmOperatorType *ot) /* ------------- Child-Of Constraint ------------------ */ static void child_get_inverse_matrix_owner_bone( - const bContext *C, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4]) + Depsgraph *depsgraph, wmOperator *op, Scene *scene, Object *ob, float invmat[4][4]) { /* For bone owner we want to do this in evaluated domain. * BKE_pose_where_is / BKE_pose_where_is_bone relies on (re)evaluating parts of the scene * and copying new evaluated stuff back to original. */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); bConstraint *con_eval = edit_constraint_property_get(op, ob_eval, CONSTRAINT_TYPE_CHILDOF); @@ -947,9 +946,8 @@ static void child_get_inverse_matrix_owner_bone( } static void child_get_inverse_matrix_owner_object( - const bContext *C, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) + Depsgraph *depsgraph, Scene *scene, Object *ob, bConstraint *con, float invmat[4][4]) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); /* nullify inverse matrix first */ unit_m4(invmat); @@ -971,6 +969,7 @@ static void child_get_inverse_matrix_owner_object( static int childof_set_inverse_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_CHILDOF); @@ -985,10 +984,10 @@ static int childof_set_inverse_exec(bContext *C, wmOperator *op) } if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { - child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat); + child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat); } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat); + child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat); } ED_object_constraint_update(bmain, ob); @@ -1224,6 +1223,7 @@ void CONSTRAINT_OT_followpath_path_animate(wmOperatorType *ot) static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); bConstraint *con = edit_constraint_property_get(op, ob, CONSTRAINT_TYPE_OBJECTSOLVER); @@ -1238,10 +1238,10 @@ static int objectsolver_set_inverse_exec(bContext *C, wmOperator *op) } if (owner == EDIT_CONSTRAINT_OWNER_OBJECT) { - child_get_inverse_matrix_owner_object(C, scene, ob, con, data->invmat); + child_get_inverse_matrix_owner_object(depsgraph, scene, ob, con, data->invmat); } else if (owner == EDIT_CONSTRAINT_OWNER_BONE) { - child_get_inverse_matrix_owner_bone(C, op, scene, ob, data->invmat); + child_get_inverse_matrix_owner_bone(depsgraph, op, scene, ob, data->invmat); } ED_object_constraint_update(bmain, ob); diff --git a/source/blender/editors/object/object_data_transfer.c b/source/blender/editors/object/object_data_transfer.c index 465a60ba75c..79aafc6978f 100644 --- a/source/blender/editors/object/object_data_transfer.c +++ b/source/blender/editors/object/object_data_transfer.c @@ -111,8 +111,6 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, int totitem = 0; const int data_type = RNA_enum_get(ptr, "data_type"); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - PropertyRNA *prop = RNA_struct_find_property(ptr, "use_reverse_transfer"); const bool reverse_transfer = prop != NULL && RNA_property_boolean_get(ptr, prop); const int layers_select_dst = reverse_transfer ? RNA_enum_get(ptr, "layers_select_src") : @@ -158,6 +156,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -183,6 +182,7 @@ static const EnumPropertyItem *dt_layers_select_src_itemf(bContext *C, Mesh *me_eval; int num_data, i; + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *ob_src_eval = DEG_get_evaluated_object(depsgraph, ob_src); @@ -397,7 +397,7 @@ static bool data_transfer_exec_is_object_valid(wmOperator *op, static int data_transfer_exec(bContext *C, wmOperator *op) { Object *ob_src = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); ListBase ctx_objects; @@ -613,7 +613,7 @@ void OBJECT_OT_data_transfer(wmOperatorType *ot) ot->check = data_transfer_check; /* Flags.*/ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties.*/ prop = RNA_def_boolean(ot->srna, @@ -767,7 +767,7 @@ static bool datalayout_transfer_poll(bContext *C) static int datalayout_transfer_exec(bContext *C, wmOperator *op) { Object *ob_act = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); DataTransferModifierData *dtmd; @@ -873,7 +873,7 @@ void OBJECT_OT_datalayout_transfer(wmOperatorType *ot) ot->check = data_transfer_check; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* Properties.*/ edit_modifier_properties(ot); diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a390cf67cf5..36a08d15913 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -906,7 +906,9 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, bool current_frame_ } Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some + * nested pointers, like animation data. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ListBase targets = {NULL, NULL}; /* loop over objects in scene */ diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index 5c4fa5aeee6..075cd5acad6 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -596,7 +596,7 @@ void OBJECT_OT_gpencil_modifier_move_down(wmOperatorType *ot) static int gpencil_modifier_apply_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C); GpencilModifierData *md = gpencil_edit_modifier_property_get(op, ob, 0); int apply_as = RNA_enum_get(op->ptr, "apply_as"); diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 707489d588a..15c5ea40991 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -528,7 +528,7 @@ static int add_hook_object(const bContext *C, int mode, ReportList *reports) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ModifierData *md = NULL; HookModifierData *hmd = NULL; float cent[3]; @@ -603,13 +603,14 @@ static int add_hook_object(const bContext *C, /* matrix calculus */ /* vert x (obmat x hook->imat) x hook->obmat x ob->imat */ /* (parentinv ) */ - Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - BKE_object_transform_copy(ob_eval, ob); - BKE_object_where_is_calc(depsgraph, scene, ob_eval); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + BKE_object_transform_copy(object_eval, ob); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); - invert_m4_m4(ob_eval->imat, ob_eval->obmat); + invert_m4_m4(object_eval->imat, object_eval->obmat); /* apparently this call goes from right to left... */ - mul_m4_series(hmd->parentinv, pose_mat, ob_eval->imat, obedit->obmat); + mul_m4_series(hmd->parentinv, pose_mat, object_eval->imat, obedit->obmat); DEG_relations_tag_update(bmain); diff --git a/source/blender/editors/object/object_modes.c b/source/blender/editors/object/object_modes.c index 23d1a293850..271d8effd30 100644 --- a/source/blender/editors/object/object_modes.c +++ b/source/blender/editors/object/object_modes.c @@ -171,14 +171,6 @@ void ED_object_mode_toggle(bContext *C, eObjectMode mode) if (opstring) { wmOperatorType *ot = WM_operatortype_find(opstring, false); - if (ot->flag & OPTYPE_USE_EVAL_DATA) { - /* We need to force refresh of depsgraph after undo step, - * redoing the operator *may* rely on some valid evaluated data. */ - struct Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); - } WM_operator_name_call_ptr(C, ot, WM_OP_EXEC_REGION_WIN, NULL); } } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 8bc68ea753c..8818fd71190 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1130,7 +1130,7 @@ void OBJECT_OT_modifier_move_down(wmOperatorType *ot) static int modifier_apply_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); ModifierData *md = edit_modifier_property_get(op, ob, 0); @@ -1194,7 +1194,7 @@ void OBJECT_OT_modifier_apply(wmOperatorType *ot) static int modifier_convert_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = ED_object_active_context(C); @@ -1391,7 +1391,7 @@ void OBJECT_OT_multires_subdivide(wmOperatorType *ot) static int multires_reshape_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C), *secondob = NULL; MultiresModifierData *mmd = (MultiresModifierData *)edit_modifier_property_get( op, ob, eModifierType_Multires); @@ -1934,7 +1934,7 @@ static Object *modifier_skin_armature_create(Depsgraph *depsgraph, static int skin_armature_create_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C), *arm_ob; Mesh *me = ob->data; @@ -1999,7 +1999,7 @@ static bool correctivesmooth_poll(bContext *C) static int correctivesmooth_bind_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_active_context(C); CorrectiveSmoothModifierData *csmd = (CorrectiveSmoothModifierData *)edit_modifier_property_get( @@ -2077,7 +2077,7 @@ static bool meshdeform_poll(bContext *C) static int meshdeform_bind_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ED_object_active_context(C); MeshDeformModifierData *mmd = (MeshDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_MeshDeform); @@ -2403,7 +2403,7 @@ static bool laplaciandeform_poll(bContext *C) static int laplaciandeform_bind_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); LaplacianDeformModifierData *lmd = (LaplacianDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_LaplacianDeform); @@ -2478,7 +2478,7 @@ static bool surfacedeform_bind_poll(bContext *C) static int surfacedeform_bind_exec(bContext *C, wmOperator *op) { Object *ob = ED_object_active_context(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)edit_modifier_property_get( op, ob, eModifierType_SurfaceDeform); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ff31cbc4590..d486321b68a 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -124,7 +124,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); Object *obedit = CTX_data_edit_object(C); BMVert *eve; @@ -677,7 +677,7 @@ bool ED_object_parent_set(ReportList *reports, const int vert_par[3]) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bPoseChannel *pchan = NULL; bPoseChannel *pchan_eval = NULL; const bool pararm = ELEM( diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 3f7d5dba149..5934eab62bb 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -547,7 +547,7 @@ static int apply_objects_internal(bContext *C, { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float rsmat[3][3], obmat[3][3], iobmat[3][3], mat[4][4], scale; bool changed = true; @@ -881,7 +881,7 @@ static int apply_objects_internal(bContext *C, static int visual_transform_apply_exec(bContext *C, wmOperator *UNUSED(op)) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bool changed = false; CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { @@ -976,7 +976,7 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) Scene *scene = CTX_data_scene(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); - Depsgraph *depsgraph = CTX_data_evaluated_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *tob; float cent[3], cent_neg[3], centn[3]; const float *cursor = scene->cursor.location; diff --git a/source/blender/editors/object/object_vgroup.c b/source/blender/editors/object/object_vgroup.c index 4f61443ac54..a43ac59c9b8 100644 --- a/source/blender/editors/object/object_vgroup.c +++ b/source/blender/editors/object/object_vgroup.c @@ -1514,7 +1514,7 @@ static void moveCloserToDistanceFromPlane(Depsgraph *depsgraph, static void vgroup_fix( const bContext *C, Scene *UNUSED(scene), Object *ob, float distToBe, float strength, float cp) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); int i; diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 40b7a245f69..c06c21b9057 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -473,7 +473,7 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update */ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_ = ED_object_context(C); Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -505,7 +505,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"); job->bmain = CTX_data_main(C); job->scene = scene_eval; - job->depsgraph = CTX_data_depsgraph(C); + job->depsgraph = depsgraph; job->ob = object_eval; job->canvas = canvas; job->surface = surface; diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index ebf62f282c2..e6870cda19d 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -465,7 +465,7 @@ static void PE_set_data(bContext *C, PEData *data) data->scene = CTX_data_scene(C); data->view_layer = CTX_data_view_layer(C); data->ob = CTX_data_active_object(C); - data->depsgraph = CTX_data_depsgraph(C); + data->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); data->edit = PE_get_current(data->scene, data->ob); } @@ -1778,7 +1778,7 @@ static bool select_action_apply(PTCacheEditPoint *point, PTCacheEditKey *key, in static int pe_select_all_exec(bContext *C, wmOperator *op) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = CTX_data_active_object(C); PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; @@ -2348,7 +2348,7 @@ static int hide_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PTCacheEdit *edit = PE_get_current(scene, ob); POINT_P; @@ -2409,7 +2409,7 @@ static int reveal_exec(bContext *C, wmOperator *op) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PTCacheEdit *edit = PE_get_current(scene, ob); const bool select = RNA_boolean_get(op->ptr, "select"); POINT_P; @@ -2709,7 +2709,7 @@ static void rekey_particle_to_time( psys = edit->psys; - sim.depsgraph = CTX_data_depsgraph(C); + sim.depsgraph = CTX_data_depsgraph_pointer(C); sim.scene = scene; sim.ob = ob; sim.psys = psys; @@ -4211,7 +4211,7 @@ static void brush_add_count_iter_finalize(void *__restrict userdata_v, static int brush_add(const bContext *C, PEData *data, short number) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = data->scene; Object *ob = data->ob; Mesh *mesh; @@ -4542,7 +4542,7 @@ static int brush_edit_init(bContext *C, wmOperator *op) static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) { BrushEdit *bedit = op->customdata; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = bedit->scene; Object *ob = bedit->ob; PTCacheEdit *edit = bedit->edit; @@ -5294,7 +5294,7 @@ static void free_all_psys_edit(Object *object) static int particle_edit_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); const int mode_flag = OB_MODE_PARTICLE_EDIT; @@ -5495,7 +5495,7 @@ static int unify_length_exec(bContext *C, wmOperator *UNUSED(op)) { Object *ob = CTX_data_active_object(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); PTCacheEdit *edit = PE_get_current(scene, ob); float average_length = calculate_average_length(edit); diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 71877fc6b39..0999d1f3588 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -652,7 +652,7 @@ static void disconnect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Part static int disconnect_hair_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); ParticleSystem *psys = NULL; @@ -934,7 +934,7 @@ static bool connect_hair(Depsgraph *depsgraph, Scene *scene, Object *ob, Particl static int connect_hair_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = ED_object_context(C); ParticleSystem *psys = NULL; @@ -1086,7 +1086,7 @@ static bool copy_particle_systems_to_object(const bContext *C, bool duplicate_settings) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ModifierData *md; ParticleSystem *psys_start = NULL, *psys, *psys_from; ParticleSystem **tmp_psys; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index dc3673c972f..da0fb873075 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -334,6 +334,7 @@ static void free_all_fluidobject_channels(ListBase *fobjects) } static void fluid_init_all_channels(bContext *C, + Depsgraph *depsgraph, Object *UNUSED(fsDomain), FluidsimSettings *domainSettings, FluidAnimChannels *channels, @@ -341,7 +342,6 @@ static void fluid_init_all_channels(bContext *C, { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); Base *base; int i; int length = channels->length; @@ -514,9 +514,11 @@ static void fluid_init_all_channels(bContext *C, } } -static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length) +static void export_fluid_objects(Depsgraph *depsgraph, + ListBase *fobjects, + Scene *scene, + int length) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); FluidObject *fobj; for (fobj = fobjects->first; fobj; fobj = fobj->next) { @@ -922,7 +924,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); int i; FluidsimSettings *domainSettings; @@ -1051,11 +1053,11 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor (double)noFrames; /* ******** initialize and allocate animation channels ******** */ - fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); + fluid_init_all_channels(C, depsgraph, fsDomain, domainSettings, channels, fobjects); /* reset to original current frame */ scene->r.cfra = origFrame; - ED_update_for_newframe(CTX_data_main(C), depsgraph); + ED_update_for_newframe(CTX_data_main(C), CTX_data_depsgraph_pointer(C)); /* ******** init domain object's matrix ******** */ copy_m4_m4(domainMat, fsDomain->obmat); @@ -1153,7 +1155,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor elbeemAddDomain(fsset); /* ******** export all fluid objects to elbeem ******** */ - export_fluid_objects(C, fobjects, scene, channels->length); + export_fluid_objects(depsgraph, fobjects, scene, channels->length); /* custom data for fluid bake job */ fb->settings = fsset; diff --git a/source/blender/editors/physics/physics_pointcache.c b/source/blender/editors/physics/physics_pointcache.c index e9e89a31f94..bc2f1d6cef6 100644 --- a/source/blender/editors/physics/physics_pointcache.c +++ b/source/blender/editors/physics/physics_pointcache.c @@ -156,7 +156,8 @@ static PTCacheBaker *ptcache_baker_create(bContext *C, wmOperator *op, bool all) baker->bmain = CTX_data_main(C); baker->scene = CTX_data_scene(C); baker->view_layer = CTX_data_view_layer(C); - baker->depsgraph = CTX_data_depsgraph(C); + /* Depsgraph is used to sweep the frame range and evaluate scene at different times. */ + baker->depsgraph = CTX_data_depsgraph_pointer(C); baker->bake = RNA_boolean_get(op->ptr, "bake"); baker->render = 0; baker->anim_init = 0; diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index aa323dc53eb..70142b790c0 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -464,7 +464,7 @@ static const EnumPropertyItem *rigidbody_materials_itemf(bContext *UNUSED(C), static int rigidbody_objects_calc_mass_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); int material = RNA_enum_get(op->ptr, "material"); float density; bool changed = false; @@ -537,7 +537,7 @@ void RIGIDBODY_OT_mass_calculate(wmOperatorType *ot) ot->poll = ED_operator_scene_editable; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = prop = RNA_def_enum( diff --git a/source/blender/editors/render/render_internal.c b/source/blender/editors/render/render_internal.c index 9ac93f07300..acd7126e56a 100644 --- a/source/blender/editors/render/render_internal.c +++ b/source/blender/editors/render/render_internal.c @@ -368,7 +368,7 @@ static int screen_render_exec(bContext *C, wmOperator *op) RE_SetReports(re, NULL); // no redraw needed, we leave state as we entered it - ED_update_for_newframe(mainp, CTX_data_depsgraph(C)); + ED_update_for_newframe(mainp, CTX_data_depsgraph_pointer(C)); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_RESULT, scene); @@ -978,8 +978,11 @@ static int screen_render_invoke(bContext *C, wmOperator *op, const wmEvent *even rj->scene = scene; rj->current_scene = rj->scene; rj->single_layer = single_layer; - /* TODO(sergey): Render engine should be using own depsgraph. */ - rj->depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): Render engine should be using own depsgraph. + * + * NOTE: Currently is only used by ED_update_for_newframe() at the end of the render, so no + * need to ensure evaluation here. */ + rj->depsgraph = CTX_data_depsgraph_pointer(C); rj->camera_override = camera_override; rj->anim = is_animation; rj->write_still = is_write_still && !is_animation; diff --git a/source/blender/editors/render/render_opengl.c b/source/blender/editors/render/render_opengl.c index 72e6c6fdf03..f419d30a17e 100644 --- a/source/blender/editors/render/render_opengl.c +++ b/source/blender/editors/render/render_opengl.c @@ -273,7 +273,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) static void screen_opengl_render_doit(const bContext *C, OGLRender *oglrender, RenderResult *rr) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = oglrender->scene; ARegion *ar = oglrender->ar; View3D *v3d = oglrender->v3d; @@ -592,7 +592,9 @@ static bool screen_opengl_render_init(bContext *C, wmOperator *op) oglrender->scene = scene; oglrender->workspace = workspace; oglrender->view_layer = CTX_data_view_layer(C); - oglrender->depsgraph = CTX_data_depsgraph(C); + /* NOTE: The depsgraph is not only used to update scene for a new frames, but also to initialize + * output video handles, which does need evaluated scene. */ + oglrender->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); oglrender->cfrao = scene->r.cfra; oglrender->ofs_samples = samples; diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index f7a1d7187f1..5c305f45fb2 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -859,7 +859,7 @@ static int light_cache_bake_exec(bContext *C, wmOperator *op) EEVEE_lightbake_job_data_free(rj); // no redraw needed, we leave state as we entered it - ED_update_for_newframe(bmain, CTX_data_depsgraph(C)); + ED_update_for_newframe(bmain, CTX_data_depsgraph_pointer(C)); WM_event_add_notifier(C, NC_SCENE | NA_EDITED, scene); diff --git a/source/blender/editors/render/render_update.c b/source/blender/editors/render/render_update.c index 64869b71746..82e4d577777 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -135,7 +135,7 @@ void ED_render_scene_update(const DEGEditorUpdateContext *update_ctx, int update /* NOTE: Important to pass non-updated depsgraph, This is because this function is called * from inside dependency graph evaluation. Additionally, if we pass fully evaluated one * we will loose updates stored in the graph. */ - engine->type->view_update(engine, C, CTX_data_depsgraph(C)); + engine->type->view_update(engine, C, CTX_data_depsgraph_pointer(C)); } else { RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c9a45728bc2..121db2fac99 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -4465,7 +4465,7 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) { bScreen *screen = CTX_wm_screen(C); Scene *scene = CTX_data_scene(C); - Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_depsgraph(C)); + Scene *scene_eval = DEG_get_evaluated_scene(CTX_data_ensure_evaluated_depsgraph(C)); if (ED_screen_animation_playing(CTX_wm_manager(C))) { /* stop playback now */ diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c index d7e1b47d973..5852012891d 100644 --- a/source/blender/editors/sculpt_paint/paint_hide.c +++ b/source/blender/editors/sculpt_paint/paint_hide.c @@ -339,7 +339,7 @@ static int hide_show_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me = ob->data; PartialVisAction action; PartialVisArea area; diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a0f578c04d0..f3a6cfa0d5c 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -1238,7 +1238,7 @@ void PAINT_OT_texture_paint_toggle(wmOperatorType *ot) ot->poll = texture_paint_toggle_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static int brush_colors_flip_exec(bContext *C, wmOperator *UNUSED(op)) diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c index d7f618023be..38f8a6d7adf 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -4012,7 +4012,7 @@ static void project_paint_bleed_add_face_user(const ProjPaintState *ps, /* Return true if evaluated mesh can be painted on, false otherwise */ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *ps) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob = ps->ob; Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); @@ -5710,7 +5710,7 @@ void paint_proj_stroke(const bContext *C, /* clone gets special treatment here to avoid going through image initialization */ if (ps_handle->is_clone_cursor_pick) { Scene *scene = ps_handle->scene; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); float *cursor = scene->cursor.location; @@ -5779,7 +5779,7 @@ static void project_state_init(bContext *C, Object *ob, ProjPaintState *ps, int ps->rv3d = CTX_wm_region_view3d(C); ps->ar = CTX_wm_region(C); - ps->depsgraph = CTX_data_depsgraph(C); + ps->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ps->scene = scene; /* allow override of active object */ ps->ob = ob; @@ -6143,7 +6143,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) char filename[FILE_MAX]; Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *settings = scene->toolsettings; int w = settings->imapaint.screen_grab_size[0]; @@ -6234,8 +6234,7 @@ static int texture_paint_image_from_view_exec(bContext *C, wmOperator *op) array += sizeof(rv3d->winmat) / sizeof(float); memcpy(array, rv3d->viewmat, sizeof(rv3d->viewmat)); array += sizeof(rv3d->viewmat) / sizeof(float); - is_ortho = ED_view3d_clip_range_get( - CTX_data_depsgraph(C), v3d, rv3d, &array[0], &array[1], true); + is_ortho = ED_view3d_clip_range_get(depsgraph, v3d, rv3d, &array[0], &array[1], true); /* using float for a bool is dodgy but since its an extra member in the array... * easier then adding a single bool prop */ array[2] = is_ortho ? 1.0f : 0.0f; diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index c7e2b008d1f..74212058fc7 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -130,7 +130,7 @@ static int mask_flood_fill_exec(bContext *C, wmOperator *op) { ARegion *ar = CTX_wm_region(C); Object *ob = CTX_data_active_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); PaintMaskFloodMode mode; float value; PBVH *pbvh; @@ -277,7 +277,7 @@ static void mask_box_select_task_cb(void *__restrict userdata, bool ED_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, const rcti *rect, bool select) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Sculpt *sd = vc->scene->toolsettings->sculpt; BoundBox bb; float clip_planes[4][4]; @@ -444,7 +444,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) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float clip_planes[4][4], clip_planes_final[4][4]; BoundBox bb; Object *ob; diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index c8ad1b5781d..0f37968f599 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -463,7 +463,7 @@ void paint_sample_color( bContext *C, ARegion *ar, int x, int y, bool texpaint_proj, bool use_palette) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Paint *paint = BKE_paint_get_active_from_context(C); Palette *palette = BKE_paint_palette(paint); PaletteColor *color = NULL; diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c index b599234907e..9215a90c446 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1377,7 +1377,7 @@ void PAINT_OT_weight_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -1537,7 +1537,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo bool *defbase_sel; SculptSession *ss = ob->sculpt; VPaint *vp = CTX_data_tool_settings(C)->wpaint; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); if (ED_wpaint_ensure_data(C, op->reports, WPAINT_ENSURE_MIRROR, &vgroup_index) == false) { return false; @@ -2550,7 +2550,7 @@ void PAINT_OT_vertex_paint_toggle(wmOperatorType *ot) ot->poll = paint_poll_test; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /** \} */ @@ -2619,7 +2619,7 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f Object *ob = CTX_data_active_object(C); Mesh *me; SculptSession *ss = ob->sculpt; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); /* context checks could be a poll() */ me = BKE_mesh_from_object(ob); diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index b6a6c897606..1dc28328244 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -119,7 +119,7 @@ static bool weight_from_bones_poll(bContext *C) static int weight_from_bones_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Object *armob = modifiers_isDeformedByArmature(ob); @@ -161,7 +161,7 @@ void PAINT_OT_weight_from_bones(wmOperatorType *ot) ot->poll = weight_from_bones_poll; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* properties */ ot->prop = RNA_def_enum( @@ -746,7 +746,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) float sco_end[2] = {x_end, y_end}; const bool is_interactive = (gesture != NULL); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); WPGradient_userData data = {NULL}; @@ -880,7 +880,7 @@ void PAINT_OT_weight_gradient(wmOperatorType *ot) ot->cancel = WM_gesture_straightline_cancel; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; prop = RNA_def_enum(ot->srna, "type", gradient_types, 0, "Type", ""); RNA_def_property_flag(prop, PROP_SKIP_SAVE); diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 094d9de5d84..c8709d40f96 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -4922,7 +4922,7 @@ static void sculpt_stroke_modifiers_check(const bContext *C, Object *ob, const B SculptSession *ss = ob->sculpt; if (ss->kb || ss->modifiers_active) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); bool need_pmap = sculpt_any_smooth_mode(brush, ss->cache, 0); BKE_sculpt_update_object_for_edit(depsgraph, ob, need_pmap, false); } @@ -5135,7 +5135,7 @@ static void sculpt_brush_init_tex(const Scene *scene, Sculpt *sd, SculptSession static void sculpt_brush_stroke_init(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); Sculpt *sd = CTX_data_tool_settings(C)->sculpt; @@ -5183,7 +5183,7 @@ void sculpt_update_object_bounding_box(Object *ob) static void sculpt_flush_update_step(bContext *C) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; ARegion *ar = CTX_wm_region(C); @@ -5752,7 +5752,7 @@ static void sculpt_dynamic_topology_disable_ex( void sculpt_dynamic_topology_disable(bContext *C, SculptUndoNode *unode) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); sculpt_dynamic_topology_disable_ex(bmain, depsgraph, scene, ob, unode); @@ -5789,7 +5789,7 @@ static void sculpt_dynamic_topology_enable_with_undo(Main *bmain, static int sculpt_dynamic_topology_toggle_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -6244,7 +6244,7 @@ static void SCULPT_OT_sculptmode_toggle(wmOperatorType *ot) ot->exec = sculpt_mode_toggle_exec; ot->poll = ED_operator_object_active_editable_mesh; - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } static bool sculpt_and_constant_or_manual_detail_poll(bContext *C) diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c b/source/blender/editors/sculpt_paint/sculpt_undo.c index e9d17b11ccc..dde1e51e764 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.c +++ b/source/blender/editors/sculpt_paint/sculpt_undo.c @@ -127,11 +127,10 @@ static bool sculpt_undo_restore_deformed( } } -static bool sculpt_undo_restore_coords(bContext *C, SculptUndoNode *unode) +static bool sculpt_undo_restore_coords(bContext *C, Depsgraph *depsgraph, SculptUndoNode *unode) { ViewLayer *view_layer = CTX_data_view_layer(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; MVert *mvert; @@ -455,13 +454,12 @@ static int sculpt_undo_bmesh_restore(bContext *C, return false; } -static void sculpt_undo_restore_list(bContext *C, ListBase *lb) +static void sculpt_undo_restore_list(bContext *C, Depsgraph *depsgraph, ListBase *lb) { Scene *scene = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = CTX_wm_view3d(C); Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); SculptSession *ss = ob->sculpt; SubdivCCG *subdiv_ccg = ss->subdiv_ccg; SculptUndoNode *unode; @@ -512,7 +510,7 @@ static void sculpt_undo_restore_list(bContext *C, ListBase *lb) switch (unode->type) { case SCULPT_UNDO_COORDS: - if (sculpt_undo_restore_coords(C, unode)) { + if (sculpt_undo_restore_coords(C, depsgraph, unode)) { update = true; } break; @@ -1062,21 +1060,27 @@ static bool sculpt_undosys_step_encode(struct bContext *UNUSED(C), return true; } -static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == true); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = false; } -static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo_impl(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { BLI_assert(us->step.is_applied == false); - sculpt_undo_restore_list(C, &us->data.nodes); + sculpt_undo_restore_list(C, depsgraph, &us->data.nodes); us->step.is_applied = true; } -static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_undo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.next && (us_iter->step.next->type == us_iter->step.type)) { @@ -1086,12 +1090,14 @@ static void sculpt_undosys_step_decode_undo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.next; } while (us_iter != us) { - sculpt_undosys_step_decode_undo_impl(C, us_iter); + sculpt_undosys_step_decode_undo_impl(C, depsgraph, us_iter); us_iter = (SculptUndoStep *)us_iter->step.prev; } } -static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep *us) +static void sculpt_undosys_step_decode_redo(struct bContext *C, + Depsgraph *depsgraph, + SculptUndoStep *us) { SculptUndoStep *us_iter = us; while (us_iter->step.prev && (us_iter->step.prev->type == us_iter->step.type)) { @@ -1101,7 +1107,7 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * us_iter = (SculptUndoStep *)us_iter->step.prev; } while (us_iter && (us_iter->step.is_applied == false)) { - sculpt_undosys_step_decode_redo_impl(C, us_iter); + sculpt_undosys_step_decode_redo_impl(C, depsgraph, us_iter); if (us_iter == us) { break; } @@ -1112,6 +1118,8 @@ static void sculpt_undosys_step_decode_redo(struct bContext *C, SculptUndoStep * static void sculpt_undosys_step_decode( struct bContext *C, struct Main *bmain, UndoStep *us_p, int dir, bool UNUSED(is_final)) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + /* Ensure sculpt mode. */ { Scene *scene = CTX_data_scene(C); @@ -1120,7 +1128,6 @@ static void sculpt_undosys_step_decode( BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); Object *ob = OBACT(view_layer); if (ob && (ob->type == OB_MESH)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); if (ob->mode & OB_MODE_SCULPT) { /* pass */ } @@ -1142,10 +1149,10 @@ static void sculpt_undosys_step_decode( SculptUndoStep *us = (SculptUndoStep *)us_p; if (dir < 0) { - sculpt_undosys_step_decode_undo(C, us); + sculpt_undosys_step_decode_undo(C, depsgraph, us); } else { - sculpt_undosys_step_decode_redo(C, us); + sculpt_undosys_step_decode_redo(C, depsgraph, us); } } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 0241a2fbe88..10d38055085 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -305,7 +305,9 @@ static int sound_bake_animation_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* NOTE: We will be forefully evaluating dependency graph at every frame, so no need to ensure + * current scene state is evaluated as it will be lost anyway. */ + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); int oldfra = scene->r.cfra; int cfra; @@ -343,7 +345,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) #ifdef WITH_AUDASPACE char path[FILE_MAX]; char filename[FILE_MAX]; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); Main *bmain = CTX_data_main(C); int split; diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 7e19ac255f0..93584011844 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -947,7 +947,7 @@ static void clip_main_region_draw(const bContext *C, ARegion *ar) ScrArea *sa = CTX_wm_area(C); int mask_width, mask_height; ED_mask_get_size(sa, &mask_width, &mask_height); - ED_mask_draw_region(CTX_data_depsgraph(C), + ED_mask_draw_region(CTX_data_expect_evaluated_depsgraph(C), mask, ar, sc->mask_info.draw_flag, diff --git a/source/blender/editors/space_clip/tracking_ops_orient.c b/source/blender/editors/space_clip/tracking_ops_orient.c index 61991993b10..de0025a53d2 100644 --- a/source/blender/editors/space_clip/tracking_ops_orient.c +++ b/source/blender/editors/space_clip/tracking_ops_orient.c @@ -39,6 +39,7 @@ #include "BKE_report.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "WM_api.h" #include "WM_types.h" @@ -395,7 +396,6 @@ static int set_plane_exec(bContext *C, wmOperator *op) ListBase *tracksbase; Object *object; Object *camera = get_camera_with_movieclip(scene, clip); - Depsgraph *depsgraph = CTX_data_depsgraph(C); int tot = 0; float vec[3][3], mat[4][4], obmat[4][4], newmat[4][4], orig[3] = {0.0f, 0.0f, 0.0f}; int plane = RNA_enum_get(op->ptr, "plane"); @@ -484,7 +484,13 @@ static int set_plane_exec(bContext *C, wmOperator *op) BKE_object_apply_mat4(object, mat, 0, 0); } - BKE_object_where_is_calc(depsgraph, scene, object); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); + Object *object_eval = DEG_get_evaluated_object(depsgraph, object); + BKE_object_transform_copy(object_eval, object); + BKE_object_where_is_calc(depsgraph, scene_eval, object_eval); + BKE_object_transform_copy(object, object_eval); + set_axis(scene, object, clip, tracking_object, axis_track, 'X'); DEG_id_tag_update(&clip->id, 0); diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index e8116193c1f..7ff075bf819 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -576,7 +576,7 @@ static void image_main_region_draw(const bContext *C, ARegion *ar) SpaceImage *sima = CTX_wm_space_image(C); Object *obact = CTX_data_active_object(C); Object *obedit = CTX_data_edit_object(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); Mask *mask = NULL; bool show_uvedit = false; bool show_curve = false; diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c index bee615108f9..c932766ab93 100644 --- a/source/blender/editors/space_outliner/outliner_select.c +++ b/source/blender/editors/space_outliner/outliner_select.c @@ -113,7 +113,7 @@ static void do_outliner_activate_obdata( bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = OBACT(view_layer); Object *ob = base->object; bool use_all = false; @@ -161,7 +161,7 @@ static void do_outliner_activate_pose( bContext *C, Scene *scene, ViewLayer *view_layer, Base *base, const bool extend) { Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *obact = OBACT(view_layer); Object *ob = base->object; bool use_all = false; @@ -341,7 +341,7 @@ static eOLDrawState tree_element_set_active_object(bContext *C, if (base && !BKE_object_is_mode_compat(base->object, object_mode)) { if (object_mode == OB_MODE_OBJECT) { struct Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_object_mode_generic_exit(bmain, depsgraph, scene, base->object); } if (!BKE_object_is_mode_compat(base->object, object_mode)) { diff --git a/source/blender/editors/space_sequencer/sequencer_buttons.c b/source/blender/editors/space_sequencer/sequencer_buttons.c index a6458ee5d31..6740c2baad2 100644 --- a/source/blender/editors/space_sequencer/sequencer_buttons.c +++ b/source/blender/editors/space_sequencer/sequencer_buttons.c @@ -76,7 +76,7 @@ static void metadata_panel_context_draw(const bContext *C, Panel *panel) return; } struct Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); struct Scene *scene = CTX_data_scene(C); SpaceSeq *space_sequencer = CTX_wm_space_seq(C); /* NOTE: We can only reliably show metadata for the original (current) diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 76c198b3d6b..ea815bd5456 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -1546,7 +1546,7 @@ void sequencer_draw_preview(const bContext *C, bool draw_backdrop) { struct Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); struct View2D *v2d = &ar->v2d; struct ImBuf *ibuf = NULL; struct ImBuf *scope = NULL; diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 4ad899f0ebf..611b233eed0 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -181,7 +181,7 @@ static void seq_proxy_build_job(const bContext *C) { wmJob *wm_job; ProxyJob *pj; - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); ScrArea *sa = CTX_wm_area(C); @@ -3612,7 +3612,7 @@ static int sequencer_rebuild_proxy_invoke(bContext *C, static int sequencer_rebuild_proxy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); Editing *ed = BKE_sequencer_editing_get(scene, false); Sequence *seq; diff --git a/source/blender/editors/space_sequencer/sequencer_view.c b/source/blender/editors/space_sequencer/sequencer_view.c index 593dd86477a..534d02c7bf3 100644 --- a/source/blender/editors/space_sequencer/sequencer_view.c +++ b/source/blender/editors/space_sequencer/sequencer_view.c @@ -92,7 +92,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info) static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event) { Main *bmain = CTX_data_main(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); SpaceSeq *sseq = (SpaceSeq *)CTX_wm_space_data(C); ARegion *ar = CTX_wm_region(C); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 9bbfee9f771..8844428b1bf 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1082,7 +1082,7 @@ static void draw_rotation_guide(const RegionView3D *rv3d) static void view3d_draw_border(const bContext *C, ARegion *ar) { Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); RegionView3D *rv3d = ar->regiondata; View3D *v3d = CTX_wm_view3d(C); @@ -1453,7 +1453,7 @@ void view3d_draw_region_info(const bContext *C, ARegion *ar) static void view3d_draw_view(const bContext *C, ARegion *ar) { ED_view3d_draw_setup_view(CTX_wm_window(C), - CTX_data_depsgraph(C), + CTX_data_expect_evaluated_depsgraph(C), CTX_data_scene(C), ar, CTX_wm_view3d(C), diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index a8fdbe8618c..826eddc63d1 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -219,7 +219,7 @@ static void viewops_data_alloc(bContext *C, wmOperator *op) /* store data */ op->customdata = vod; vod->bmain = CTX_data_main(C); - vod->depsgraph = CTX_data_depsgraph(C); + vod->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vod->scene = CTX_data_scene(C); vod->sa = CTX_wm_area(C); vod->ar = CTX_wm_region(C); @@ -249,7 +249,7 @@ static bool view3d_orbit_calc_center(bContext *C, float r_dyn_ofs[3]) static float lastofs[3] = {0, 0, 0}; bool is_set = false; - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); View3D *v3d = CTX_wm_view3d(C); @@ -373,7 +373,7 @@ static void viewops_data_create(bContext *C, const wmEvent *event, enum eViewOpsFlag viewops_flag) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod = op->customdata; RegionView3D *rv3d = vod->rv3d; @@ -1317,7 +1317,7 @@ static int ndof_orbit_invoke(bContext *C, wmOperator *op, const wmEvent *event) return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod; View3D *v3d; RegionView3D *rv3d; @@ -1397,7 +1397,7 @@ static int ndof_orbit_zoom_invoke(bContext *C, wmOperator *op, const wmEvent *ev return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewOpsData *vod; View3D *v3d; RegionView3D *rv3d; @@ -1511,7 +1511,7 @@ static int ndof_pan_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *e return OPERATOR_CANCELLED; } - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); const wmNDOFMotionData *ndof = event->customdata; @@ -2188,7 +2188,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, const wmEvent *event) static int viewzoom_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; RegionView3D *rv3d; @@ -2553,7 +2553,7 @@ static int viewdolly_exec(bContext *C, wmOperator *op) ED_view3d_depth_tag_update(rv3d); - ED_view3d_camera_lock_sync(CTX_data_depsgraph(C), v3d, rv3d); + ED_view3d_camera_lock_sync(CTX_data_ensure_evaluated_depsgraph(C), v3d, rv3d); ED_region_tag_redraw(ar); @@ -2588,7 +2588,7 @@ static int viewdolly_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (vod->rv3d->persp != RV3D_PERSP) { if (vod->rv3d->persp == RV3D_CAMOB) { /* ignore rv3d->lpersp because dolly only makes sense in perspective mode */ - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_switch_from_camera(depsgraph, vod->v3d, vod->rv3d, RV3D_PERSP); } else { @@ -2749,8 +2749,9 @@ static void view3d_from_minmax(bContext *C, } if (ok_dist) { + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); new_dist = ED_view3d_radius_to_dist( - v3d, ar, CTX_data_depsgraph(C), persp, true, (size / 2) * VIEW3D_MARGIN); + v3d, ar, depsgraph, persp, true, (size / 2) * VIEW3D_MARGIN); if (rv3d->is_persp) { /* don't zoom closer than the near clipping plane */ new_dist = max_ff(new_dist, v3d->clip_start * 1.5f); @@ -2817,7 +2818,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Base *base_eval; const bool use_all_regions = RNA_boolean_get(op->ptr, "use_all_regions"); @@ -2922,7 +2923,7 @@ static int viewselected_exec(bContext *C, wmOperator *op) View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *ob_eval = OBACT(view_layer_eval); Object *obedit = CTX_data_edit_object(C); @@ -3120,7 +3121,8 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) if (obact && obact->type == OB_ARMATURE) { if (obact->mode & OB_MODE_POSE) { - Object *obact_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), obact); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact); bPoseChannel *pcham_act = BKE_pose_channel_active(obact_eval); if (pcham_act) { BLI_strncpy(v3d->ob_centre_bone, pcham_act->name, sizeof(v3d->ob_centre_bone)); @@ -3216,7 +3218,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev ARegion *ar = CTX_wm_region(C); if (rv3d) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); float new_ofs[3]; const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); @@ -3262,7 +3264,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot) static int view3d_center_camera_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); float xfac, yfac; float size[2]; @@ -3361,7 +3363,7 @@ static int render_border_exec(bContext *C, wmOperator *op) /* calculate range */ if (rv3d->persp == RV3D_CAMOB) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_calc_camera_border(scene, depsgraph, ar, v3d, rv3d, &vb, false); } else { @@ -3530,7 +3532,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) ED_view3d_dist_range_get(v3d, dist_range); /* Get Z Depths, needed for perspective, nice for ortho */ - ED_view3d_draw_depth(CTX_data_depsgraph(C), ar, v3d, true); + ED_view3d_draw_depth(CTX_data_ensure_evaluated_depsgraph(C), ar, v3d, true); { /* avoid allocating the whole depth buffer */ @@ -3619,7 +3621,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) /* TODO(campbell): 'is_camera_lock' not currently working well. */ const bool is_camera_lock = ED_view3d_camera_lock_check(v3d, rv3d); if ((rv3d->persp == RV3D_CAMOB) && (is_camera_lock == false)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_switch_from_camera(depsgraph, v3d, rv3d, RV3D_PERSP); } @@ -3686,7 +3688,7 @@ static void view3d_set_1_to_1_viewborder(Scene *scene, static int view3d_zoom_1_to_1_camera_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d; @@ -3794,7 +3796,8 @@ static void axis_set_view(bContext *C, dist = rv3d->dist; /* so we animate _from_ the camera location */ - Object *camera_eval = DEG_get_evaluated_object(CTX_data_depsgraph(C), v3d->camera); + Object *camera_eval = DEG_get_evaluated_object(CTX_data_ensure_evaluated_depsgraph(C), + v3d->camera); ED_view3d_from_object(camera_eval, rv3d->ofs, NULL, &rv3d->dist, NULL); ED_view3d_smooth_view(C, @@ -4124,7 +4127,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) float quat_new[4]; if (view_opposite == RV3D_VIEW_USER) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_persp_ensure(depsgraph, v3d, ar); } @@ -4874,7 +4877,7 @@ void ED_view3d_cursor3d_position(bContext *C, } if (use_depth) { /* maybe this should be accessed some other way */ - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); view3d_operator_needs_opengl(C); if (ED_view3d_autodist(depsgraph, ar, v3d, mval, cursor_co, true, NULL)) { @@ -4930,7 +4933,7 @@ void ED_view3d_cursor3d_position_rotation(bContext *C, float ray_co[3]; struct SnapObjectContext *snap_context = ED_transform_snap_object_context_create_view3d( - bmain, scene, CTX_data_depsgraph(C), 0, ar, v3d); + bmain, scene, CTX_data_ensure_evaluated_depsgraph(C), 0, ar, v3d); float obmat[4][4]; Object *ob_dummy = NULL; diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c index 3fa0c2c59b7..961ac4c26fb 100644 --- a/source/blender/editors/space_view3d/view3d_fly.c +++ b/source/blender/editors/space_view3d/view3d_fly.c @@ -270,7 +270,7 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->rv3d = CTX_wm_region_view3d(C); fly->v3d = CTX_wm_view3d(C); fly->ar = CTX_wm_region(C); - fly->depsgraph = CTX_data_depsgraph(C); + fly->depsgraph = CTX_data_expect_evaluated_depsgraph(C); fly->scene = CTX_data_scene(C); #ifdef NDOF_FLY_DEBUG @@ -337,12 +337,8 @@ static bool initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, const wmEvent fly->zlock = FLY_AXISLOCK_STATE_IDLE; } - fly->v3d_camera_control = ED_view3d_cameracontrol_acquire(CTX_data_depsgraph(C), - fly->scene, - fly->v3d, - fly->rv3d, - (U.uiflag & USER_CAM_LOCK_NO_PARENT) == - 0); + fly->v3d_camera_control = ED_view3d_cameracontrol_acquire( + fly->depsgraph, fly->scene, fly->v3d, fly->rv3d, (U.uiflag & USER_CAM_LOCK_NO_PARENT) == 0); /* calculate center */ if (ED_view3d_cameracontrol_object_get(fly->v3d_camera_control)) { diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 002a7e12515..1bb10697936 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -437,7 +437,8 @@ static void WIDGETGROUP_camera_view_draw_prepare(const bContext *C, wmGizmoGroup struct CameraViewWidgetGroup *viewgroup = gzgroup->customdata; ARegion *ar = CTX_wm_region(C); - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* Drawing code should happen with fully evaluated graph. */ + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); RegionView3D *rv3d = ar->regiondata; if (rv3d->persp == RV3D_CAMOB) { Scene *scene = CTX_data_scene(C); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c index 64697a59019..a984e339305 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_preselect_type.c @@ -176,7 +176,7 @@ static int gizmo_preselect_elem_test_select(bContext *C, wmGizmo *gz, const int const float(*coords)[3] = NULL; { Object *ob = gz_ele->bases[gz_ele->base_index]->object; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data); if (me_eval->runtime.edit_data) { coords = me_eval->runtime.edit_data->vertexCos; @@ -334,7 +334,7 @@ static int gizmo_preselect_edgering_test_select(bContext *C, wmGizmo *gz, const const float(*coords)[3] = NULL; { Object *ob = gz_ring->bases[gz_ring->base_index]->object; - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Mesh *me_eval = (Mesh *)DEG_get_evaluated_id(depsgraph, ob->data); if (me_eval->runtime.edit_data) { coords = me_eval->runtime.edit_data->vertexCos; diff --git a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c index e781e129540..97a12c7100e 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_ruler.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_ruler.c @@ -289,7 +289,12 @@ static void ruler_state_set(bContext *C, RulerInfo *ruler_info, int state) else if (state == RULER_STATE_DRAG) { memset(&ruler_info->drag_state_prev, 0x0, sizeof(ruler_info->drag_state_prev)); ruler_info->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, CTX_data_scene(C), CTX_data_depsgraph(C), 0, ruler_info->ar, CTX_wm_view3d(C)); + bmain, + CTX_data_scene(C), + CTX_data_ensure_evaluated_depsgraph(C), + 0, + ruler_info->ar, + CTX_wm_view3d(C)); } else { BLI_assert(0); diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c index 754c8359d28..7a8a25fe028 100644 --- a/source/blender/editors/space_view3d/view3d_select.c +++ b/source/blender/editors/space_view3d/view3d_select.c @@ -126,7 +126,7 @@ void ED_view3d_viewcontext_init(bContext *C, ViewContext *vc) vc->C = C; vc->ar = CTX_wm_region(C); vc->bmain = CTX_data_main(C); - vc->depsgraph = CTX_data_depsgraph(C); + vc->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); vc->scene = CTX_data_scene(C); vc->view_layer = CTX_data_view_layer(C); vc->v3d = CTX_wm_view3d(C); diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index 0103fd0df53..9a2f4062631 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -66,7 +66,7 @@ static bool snap_calc_active_center(bContext *C, const bool select_only, float r /** Snaps every individual object center to its nearest point on the grid. */ static int snap_sel_to_grid_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); @@ -226,7 +226,7 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) ot->poll = ED_operator_region_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ @@ -243,7 +243,6 @@ static int snap_selected_to_location(bContext *C, const float snap_target_global[3], const bool use_offset) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *obedit = CTX_data_edit_object(C); Object *obact = CTX_data_active_object(C); @@ -431,6 +430,7 @@ static int snap_selected_to_location(bContext *C, float originmat[3][3], parentmat[4][4]; /* Use the evaluated object here because sometimes * `ob->parent->runtime.curve_cache` is required. */ + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); BKE_object_get_parent_matrix(ob_eval, ob_eval->parent, parentmat); @@ -486,7 +486,7 @@ void VIEW3D_OT_snap_selected_to_cursor(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; /* rna */ RNA_def_boolean(ot->srna, @@ -523,7 +523,7 @@ void VIEW3D_OT_snap_selected_to_active(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* *************************************************** */ @@ -626,7 +626,7 @@ static void bundle_midpoint(Scene *scene, Object *ob, float r_vec[3]) /** Snaps the 3D cursor location to the median point of the selection. */ static bool snap_curs_to_sel_ex(bContext *C, float cursor[3]) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ViewLayer *view_layer_eval = DEG_get_evaluated_view_layer(depsgraph); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); @@ -757,7 +757,7 @@ void VIEW3D_OT_snap_cursor_to_selected(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* ********************************************** */ @@ -804,7 +804,7 @@ void VIEW3D_OT_snap_cursor_to_active(wmOperatorType *ot) ot->poll = ED_operator_view3d_active; /* flags */ - ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_USE_EVAL_DATA; + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; } /* **************************************************** */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index c0902cd1cd5..2515ee6e482 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -304,7 +304,7 @@ void ED_view3d_smooth_view(bContext *C, const int smooth_viewtx, const struct V3D_SmoothParams *sview) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); @@ -315,7 +315,6 @@ void ED_view3d_smooth_view(bContext *C, /* only meant for timer usage */ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); RegionView3D *rv3d = ar->regiondata; struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; @@ -336,6 +335,8 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool view3d_smooth_view_state_restore(&sms->org, v3d, rv3d); } else { + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + view3d_smooth_view_state_restore(&sms->dst, v3d, rv3d); ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); @@ -372,6 +373,7 @@ static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool rv3d->dist = sms->dst.dist * step + sms->src.dist * step_inv; v3d->lens = sms->dst.lens * step + sms->src.lens * step_inv; + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); ED_view3d_camera_lock_sync(depsgraph, v3d, rv3d); if (ED_screen_animation_playing(CTX_wm_manager(C))) { ED_view3d_camera_lock_autokey(v3d, rv3d, C, true, true); @@ -428,7 +430,7 @@ void ED_view3d_smooth_view_force_finish(bContext *C, View3D *v3d, ARegion *ar) /* force update of view matrix so tools that run immediately after * can use them without redrawing first */ - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ED_view3d_update_viewmat(depsgraph, scene, v3d, ar, NULL, NULL, NULL, false); } @@ -457,7 +459,7 @@ void VIEW3D_OT_smoothview(wmOperatorType *ot) static int view3d_camera_to_view_exec(bContext *C, wmOperator *UNUSED(op)) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); View3D *v3d; ARegion *ar; RegionView3D *rv3d; @@ -527,7 +529,7 @@ void VIEW3D_OT_camera_to_view(wmOperatorType *ot) * meant to take into account vertex/bone selection for eg. */ static int view3d_camera_to_view_selected_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); /* can be NULL */ Object *camera_ob = v3d ? v3d->camera : scene->camera; @@ -1413,7 +1415,7 @@ static void view3d_localview_exit(const Depsgraph *depsgraph, static int localview_exec(bContext *C, wmOperator *op) { - const Depsgraph *depsgraph = CTX_data_depsgraph(C); + const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); const int smooth_viewtx = WM_operator_smooth_viewtx_get(op); wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c index 853955a4078..c5585857b55 100644 --- a/source/blender/editors/space_view3d/view3d_walk.c +++ b/source/blender/editors/space_view3d/view3d_walk.c @@ -426,7 +426,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d = CTX_wm_region_view3d(C); walk->v3d = CTX_wm_view3d(C); walk->ar = CTX_wm_region(C); - walk->depsgraph = CTX_data_depsgraph(C); + walk->depsgraph = CTX_data_ensure_evaluated_depsgraph(C); walk->scene = CTX_data_scene(C); #ifdef NDOF_WALK_DEBUG @@ -520,7 +520,7 @@ static bool initWalkInfo(bContext *C, WalkInfo *walk, wmOperator *op) walk->rv3d->rflag |= RV3D_NAVIGATING; walk->snap_context = ED_transform_snap_object_context_create_view3d( - bmain, walk->scene, CTX_data_depsgraph(C), 0, walk->ar, walk->v3d); + bmain, walk->scene, CTX_data_ensure_evaluated_depsgraph(C), 0, walk->ar, walk->v3d); walk->v3d_camera_control = ED_view3d_cameracontrol_acquire( walk->depsgraph, diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index d1bff81c4ae..4eccf4c5071 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6657,7 +6657,6 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec /* only key on available channels */ if (adt && adt->action) { ListBase nla_cache = {NULL, NULL}; - for (fcu = adt->action->curves.first; fcu; fcu = fcu->next) { fcu->flag &= ~FCURVE_SELECTED; insert_keyframe(bmain, @@ -9016,7 +9015,7 @@ static void createTransGPencil_center_get(bGPDstroke *gps, float r_center[3]) static void createTransGPencil(bContext *C, TransInfo *t) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); bGPdata *gpd = ED_gpencil_data_get_active(C); ToolSettings *ts = CTX_data_tool_settings(C); diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 4a9584ed9be..7cc2ac5301a 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1391,7 +1391,6 @@ void initTransDataContainers_FromObjectData(TransInfo *t, */ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *sce = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); const eObjectMode object_mode = OBACT(view_layer) ? OBACT(view_layer)->mode : OB_MODE_OBJECT; @@ -1403,7 +1402,7 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve bGPdata *gpd = CTX_data_gpencil_data(C); PropertyRNA *prop; - t->depsgraph = depsgraph; + t->depsgraph = CTX_data_depsgraph_pointer(C); t->scene = sce; t->view_layer = view_layer; t->sa = sa; diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c index a883b5b6ba5..fbfeb4f53de 100644 --- a/source/blender/editors/transform/transform_gizmo_3d.c +++ b/source/blender/editors/transform/transform_gizmo_3d.c @@ -731,7 +731,9 @@ int ED_transform_calc_gizmo_stats(const bContext *C, ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Scene *scene = CTX_data_scene(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); + /* TODO(sergey): This function is used from operator's modal() and from gizmo's refresh(). + * Is it fine to possibly evaluate dependency graph here? */ + Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); ViewLayer *view_layer = CTX_data_view_layer(C); View3D *v3d = sa->spacedata.first; Object *obedit = CTX_data_edit_object(C); diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 183e140169d..473dde1d3a5 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -568,15 +568,6 @@ int ED_undo_operator_repeat(bContext *C, wmOperator *op) } } - if (op->type->flag & OPTYPE_USE_EVAL_DATA) { - /* We need to force refresh of depsgraph after undo step, - * redoing the operator *may* rely on some valid evaluated data. */ - Main *bmain = CTX_data_main(C); - scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - BKE_scene_view_layer_graph_evaluated_ensure(bmain, scene, view_layer); - } - retval = WM_operator_repeat(C, op); if ((retval & OPERATOR_FINISHED) == 0) { if (G.debug & G_DEBUG) { diff --git a/source/blender/editors/util/ed_util.c b/source/blender/editors/util/ed_util.c index c1b6a7b42b2..c2566d111cf 100644 --- a/source/blender/editors/util/ed_util.c +++ b/source/blender/editors/util/ed_util.c @@ -99,7 +99,7 @@ void ED_editors_init_for_undo(Main *bmain) void ED_editors_init(bContext *C) { - struct Depsgraph *depsgraph = CTX_data_depsgraph(C); + struct Depsgraph *depsgraph = CTX_data_expect_evaluated_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); wmWindowManager *wm = CTX_wm_manager(C); diff --git a/source/blender/editors/uvedit/uvedit_ops.c b/source/blender/editors/uvedit/uvedit_ops.c index 71bf6a1946a..6a2f740ba51 100644 --- a/source/blender/editors/uvedit/uvedit_ops.c +++ b/source/blender/editors/uvedit/uvedit_ops.c @@ -2376,7 +2376,7 @@ static void uv_select_all_perform_multi( static int uv_select_all_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; Image *ima = CTX_data_edit_image(C); @@ -2456,7 +2456,7 @@ static int uv_mouse_select_multi(bContext *C, const bool deselect_all, const bool loop) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -3429,7 +3429,7 @@ static void uv_select_flush_from_tag_loop(SpaceImage *sima, static int uv_box_select_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -3587,7 +3587,7 @@ static int uv_inside_circle(const float uv[2], const float offset[2], const floa static int uv_circle_select_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); Scene *scene = CTX_data_scene(C); @@ -3727,7 +3727,7 @@ static bool do_lasso_select_mesh_uv(bContext *C, short moves, const eSelectOp sel_op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); SpaceImage *sima = CTX_wm_space_image(C); Image *ima = CTX_data_edit_image(C); ARegion *ar = CTX_wm_region(C); @@ -4278,7 +4278,7 @@ static void UV_OT_pin(wmOperatorType *ot) static int uv_select_pinned_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); + Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; ViewLayer *view_layer = CTX_data_view_layer(C); |