diff options
author | YimingWu <xp8110@outlook.com> | 2019-08-01 10:14:27 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2019-08-01 10:14:27 +0300 |
commit | 69a9eac2d6b254275724b92bde9be85fe8ca3704 (patch) | |
tree | d231dcad5ae1ac79473cc99657dc3df6f8d7e286 /source/blender/editors | |
parent | 70ba6d35329ea0dd8276616ed182376ef29485e1 (diff) | |
parent | 036312ecff459f7600361d5aba9a0dba896849a1 (diff) |
Merge remote-tracking branch 'origin/master' into soc-2019-npr
Diffstat (limited to 'source/blender/editors')
132 files changed, 709 insertions, 647 deletions
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index 7a7769ccc90..3d7178a4114 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4340,7 +4340,6 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi AnimData *adt = BKE_animdata_from_id(id); FCurve *fcu = (FCurve *)fcu_poin; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4356,7 +4355,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, adt, (float)CFRA); + &nla_cache, &id_ptr, adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4373,7 +4372,7 @@ static void achannel_setting_slider_cb(bContext *C, void *id_poin, void *fcu_poi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { if (adt->action != NULL) { @@ -4395,7 +4394,6 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi KeyBlock *kb = (KeyBlock *)kb_poin; char *rna_path = BKE_keyblock_curval_rnapath_get(key, kb); - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4411,7 +4409,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* Get NLA context for value remapping */ NlaKeyframingContext *nla_context = BKE_animsys_get_nla_keyframing_context( - &nla_cache, depsgraph, &id_ptr, key->adt, (float)CFRA); + &nla_cache, &id_ptr, key->adt, (float)CFRA, false); /* get current frame and apply NLA-mapping to it (if applicable) */ cfra = BKE_nla_tweakedit_remap(key->adt, (float)CFRA, NLATIME_CONVERT_UNMAP); @@ -4433,7 +4431,7 @@ static void achannel_setting_slider_shapekey_cb(bContext *C, void *key_poin, voi /* insert a keyframe for this F-Curve */ done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); + reports, ptr, prop, fcu, cfra, ts->keyframe_type, nla_context, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); @@ -4460,7 +4458,6 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, PropertyRNA *prop; int index; - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -4485,8 +4482,7 @@ static void achannel_setting_slider_nla_curve_cb(bContext *C, } /* insert a keyframe for this F-Curve */ - done = insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); + done = insert_keyframe_direct(reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, flag); if (done) { WM_event_add_notifier(C, NC_ANIMATION | ND_ANIMCHAN | NA_EDITED, NULL); diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index 2d16ce30d31..625a52fc800 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -412,7 +412,6 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) if (scene) { ac->markers = ED_context_get_markers(C); } - ac->depsgraph = CTX_data_depsgraph(C); ac->view_layer = CTX_data_view_layer(C); ac->obact = (ac->view_layer->basact) ? ac->view_layer->basact->object : NULL; ac->sa = sa; diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index f5bd7a47248..fad9a1a8e49 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -238,6 +238,6 @@ void getcolor_fcurve_rainbow(int cur, int tot, float out[3]) /* value is fixed at 1.0f, otherwise we cannot clearly see the curves... */ hsv[2] = 1.0f; - /* finally, conver this to RGB colors */ + /* finally, convert this to RGB colors */ hsv_to_rgb_v(hsv, out); } diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 2bbb8e5888c..ded59466370 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -470,7 +470,7 @@ static void draw_marker_line_if_necessary(TimeMarker *marker, int flag, int xpos } static void draw_marker( - const uiFontStyle *fstyle, TimeMarker *marker, int xpos, int flag, int region_height) + const uiFontStyle *fstyle, TimeMarker *marker, int cfra, int xpos, int flag, int region_height) { GPU_blend(true); GPU_blend_set_func_separate( @@ -484,7 +484,9 @@ static void draw_marker( GPU_blend(false); float name_y = UI_DPI_FAC * 18; - if (marker->flag & SELECT) { + /* Give an offset to the marker name when selected, + * or when near the current frame (5 frames range, starting from the current one). */ + if ((marker->flag & SELECT) || (IN_RANGE_INCL(marker->frame, cfra, cfra - 4))) { name_y += UI_DPI_FAC * 10; } draw_marker_name(fstyle, marker, xpos, name_y); @@ -547,6 +549,7 @@ void ED_markers_draw(const bContext *C, int flag) ARegion *ar = CTX_wm_region(C); View2D *v2d = UI_view2d_fromcontext(C); + int cfra = CTX_data_scene(C)->r.cfra; rctf markers_region_rect; get_marker_region_rect(v2d, &markers_region_rect); @@ -564,17 +567,18 @@ void ED_markers_draw(const bContext *C, int flag) const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; + /* Separate loops in order to draw selected markers on top */ for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if ((marker->flag & SELECT) == 0) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } for (TimeMarker *marker = markers->first; marker; marker = marker->next) { if (marker->flag & SELECT) { if (marker_is_in_frame_range(marker, clip_frame_range)) { - draw_marker(fstyle, marker, marker->frame * xscale, flag, ar->winy); + draw_marker(fstyle, marker, cfra, marker->frame * xscale, flag, ar->winy); } } } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 2e7ed7eae34..de6e4c2fd0d 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -721,23 +721,12 @@ static short new_key_needed(FCurve *fcu, float cFrame, float nValue) /* ------------------ RNA Data-Access Functions ------------------ */ /* Try to read value using RNA-properties obtained already */ -static float *setting_get_rna_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - const bool get_evaluated, - float *buffer, - int buffer_size, - int *r_count) +static float *setting_get_rna_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 1); float *values = buffer; - PointerRNA ptr_eval; - - if (get_evaluated) { - DEG_get_evaluated_rna_pointer(depsgraph, ptr, &ptr_eval); - ptr = &ptr_eval; - } if (RNA_property_array_check(prop)) { int length = *r_count = RNA_property_array_length(ptr, prop); @@ -977,12 +966,8 @@ static bool visualkey_can_use(PointerRNA *ptr, PropertyRNA *prop) * In the event that it is not possible to perform visual keying, try to fall-back * to using the default method. Assumes that all data it has been passed is valid. */ -static float *visualkey_get_values(Depsgraph *depsgraph, - PointerRNA *ptr, - PropertyRNA *prop, - float *buffer, - int buffer_size, - int *r_count) +static float *visualkey_get_values( + PointerRNA *ptr, PropertyRNA *prop, float *buffer, int buffer_size, int *r_count) { BLI_assert(buffer_size >= 4); @@ -999,27 +984,21 @@ static float *visualkey_get_values(Depsgraph *depsgraph, */ if (ptr->type == &RNA_Object) { Object *ob = (Object *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - /* Loc code is specific... */ if (strstr(identifier, "location")) { - copy_v3_v3(buffer, ob_eval->obmat[3]); + copy_v3_v3(buffer, ob->obmat[3]); *r_count = 3; return buffer; } - copy_m4_m4(tmat, ob_eval->obmat); - rotmode = ob_eval->rotmode; + copy_m4_m4(tmat, ob->obmat); + rotmode = ob->rotmode; } else if (ptr->type == &RNA_PoseBone) { - Object *ob = (Object *)ptr->id.data; bPoseChannel *pchan = (bPoseChannel *)ptr->data; - const Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob); - bPoseChannel *pchan_eval = BKE_pose_channel_find_name(ob_eval->pose, pchan->name); - - BKE_armature_mat_pose_to_bone(pchan_eval, pchan_eval->pose_mat, tmat); - rotmode = pchan_eval->rotmode; + BKE_armature_mat_pose_to_bone(pchan, pchan->pose_mat, tmat); + rotmode = pchan->rotmode; /* Loc code is specific... */ if (strstr(identifier, "location")) { @@ -1032,7 +1011,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } } else { - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* Rot/Scale code are common! */ @@ -1066,7 +1045,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, } /* as the function hasn't returned yet, read value from system in the default way */ - return setting_get_rna_values(depsgraph, ptr, prop, true, buffer, buffer_size, r_count); + return setting_get_rna_values(ptr, prop, buffer, buffer_size, r_count); } /* ------------------------- Insert Key API ------------------------- */ @@ -1075,8 +1054,7 @@ static float *visualkey_get_values(Depsgraph *depsgraph, * Retrieve current property values to keyframe, * possibly applying NLA correction when necessary. */ -static float *get_keyframe_values(Depsgraph *depsgraph, - ReportList *reports, +static float *get_keyframe_values(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, int index, @@ -1094,11 +1072,11 @@ static float *get_keyframe_values(Depsgraph *depsgraph, * it works by keyframing using a value extracted from the final matrix * instead of using the kt system to extract a value. */ - values = visualkey_get_values(depsgraph, &ptr, prop, buffer, buffer_size, r_count); + values = visualkey_get_values(&ptr, prop, buffer, buffer_size, r_count); } else { /* read value from system */ - values = setting_get_rna_values(depsgraph, &ptr, prop, false, buffer, buffer_size, r_count); + values = setting_get_rna_values(&ptr, prop, buffer, buffer_size, r_count); } /* adjust the value for NLA factors */ @@ -1207,8 +1185,7 @@ static bool insert_keyframe_value(ReportList *reports, * the keyframe insertion. These include the 'visual' keyframing modes, quick refresh, * and extra keyframe filtering. */ -bool insert_keyframe_direct(Depsgraph *depsgraph, - ReportList *reports, +bool insert_keyframe_direct(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, @@ -1261,8 +1238,7 @@ bool insert_keyframe_direct(Depsgraph *depsgraph, int value_count; int index = fcu->array_index; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, index, @@ -1347,7 +1323,6 @@ static bool insert_keyframe_fcurve_value(Main *bmain, * index of -1 keys all array indices */ short insert_keyframe(Main *bmain, - Depsgraph *depsgraph, ReportList *reports, ID *id, bAction *act, @@ -1405,7 +1380,7 @@ short insert_keyframe(Main *bmain, if (adt && adt->action == act) { /* Get NLA context for value remapping. */ nla_context = BKE_animsys_get_nla_keyframing_context( - nla_cache ? nla_cache : &tmp_nla_cache, depsgraph, &id_ptr, adt, cfra); + nla_cache ? nla_cache : &tmp_nla_cache, &id_ptr, adt, cfra, false); /* Apply NLA-mapping to frame. */ cfra = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP); @@ -1416,8 +1391,7 @@ short insert_keyframe(Main *bmain, int value_count; bool force_all; - float *values = get_keyframe_values(depsgraph, - reports, + float *values = get_keyframe_values(reports, ptr, prop, array_index, @@ -2373,7 +2347,6 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) static int insert_key_button_exec(bContext *C, wmOperator *op) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ToolSettings *ts = scene->toolsettings; @@ -2407,7 +2380,7 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) if (fcu) { success = insert_keyframe_direct( - depsgraph, op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, 0); } else { BKE_report(op->reports, @@ -2423,15 +2396,8 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special); if (fcu && driven) { - success = insert_keyframe_direct(depsgraph, - op->reports, - ptr, - prop, - fcu, - cfra, - ts->keyframe_type, - NULL, - INSERTKEY_DRIVER); + success = insert_keyframe_direct( + op->reports, ptr, prop, fcu, cfra, ts->keyframe_type, NULL, INSERTKEY_DRIVER); } } else { @@ -2468,7 +2434,6 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) } success = insert_keyframe(bmain, - depsgraph, op->reports, ptr.id.data, NULL, @@ -2794,8 +2759,7 @@ bool fcurve_is_changed(PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, float fra float buffer[RNA_MAX_ARRAY_LENGTH]; int count, index = fcu->array_index; - float *values = setting_get_rna_values( - NULL, &ptr, prop, false, buffer, RNA_MAX_ARRAY_LENGTH, &count); + float *values = setting_get_rna_values(&ptr, prop, buffer, RNA_MAX_ARRAY_LENGTH, &count); float fcurve_val = calculate_fcurve(&anim_rna, fcu, frame); float cur_val = (index >= 0 && index < count) ? values[index] : 0.0f; diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 0cb83c79c85..ccd0fc54611 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -1030,7 +1030,6 @@ static short keyingset_apply_keying_flags(const short base_flags, int ANIM_apply_keyingset( bContext *C, ListBase *dsources, bAction *act, KeyingSet *ks, short mode, float cfra) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); ReportList *reports = CTX_wm_reports(C); @@ -1125,7 +1124,6 @@ int ANIM_apply_keyingset( /* action to take depends on mode */ if (mode == MODIFYKEY_MODE_INSERT) { success += insert_keyframe(bmain, - depsgraph, reports, ksp->id, act, diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 5daf6b584e5..8f4896c0b82 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; @@ -384,7 +386,7 @@ void POSE_OT_paths_update(wmOperatorType *ot) ot->idname = "POSE_OT_paths_update"; ot->description = "Recalculate paths for bones that already have them"; - /* api callbakcs */ + /* api callbacks */ ot->exec = pose_update_paths_exec; ot->poll = pose_update_paths_poll; 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..c8e79b879a4 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -1122,7 +1122,7 @@ static int pose_slide_modal(bContext *C, wmOperator *op, const wmEvent *event) break; } - /* Percentage Chane... */ + /* Percentage Change... */ case MOUSEMOVE: /* calculate new position */ { /* only handle mousemove if not doing numinput */ @@ -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 325e6eaee2a..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; @@ -1217,7 +1226,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) workob.adt = ob->adt; workob.pose = dummyPose; - BKE_animsys_evaluate_animdata(NULL, scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM); + BKE_animsys_evaluate_animdata(scene, &workob.id, workob.adt, cframe, ADT_RECALC_ANIM, false); /* copy back values, but on selected bones only */ for (pchan = dummyPose->chanbase.first; pchan; pchan = pchan->next) { 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 0d4ba8157c3..8350761de54 100644 --- a/source/blender/editors/gpencil/gpencil_brush.c +++ b/source/blender/editors/gpencil/gpencil_brush.c @@ -1765,7 +1765,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; Object *ob_eval = DEG_get_evaluated_object(depsgraph, obact); bGPdata *gpd = gso->gpd; diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c index 087d8540b03..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; @@ -387,8 +390,7 @@ static void gp_stroke_path_animation_preprocess_gaps(tGpTimingData *gtd, } } -static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, - ReportList *reports, +static void gp_stroke_path_animation_add_keyframes(ReportList *reports, PointerRNA ptr, PropertyRNA *prop, FCurve *fcu, @@ -446,7 +448,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, cfra = last_valid_time + MIN_TIME_DELTA; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else if (G.debug & G_DEBUG) { @@ -459,7 +461,7 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, cfra = last_valid_time + MIN_TIME_DELTA; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else { @@ -467,15 +469,8 @@ static void gp_stroke_path_animation_add_keyframes(Depsgraph *depsgraph, * and also far enough from (not yet added!) end_stroke keyframe! */ if ((cfra - last_valid_time) > MIN_TIME_DELTA && (end_stroke_time - cfra) > MIN_TIME_DELTA) { - insert_keyframe_direct(depsgraph, - reports, - ptr, - prop, - fcu, - cfra, - BEZT_KEYTYPE_BREAKDOWN, - NULL, - INSERTKEY_FAST); + insert_keyframe_direct( + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_BREAKDOWN, NULL, INSERTKEY_FAST); last_valid_time = cfra; } else if (G.debug & G_DEBUG) { @@ -493,7 +488,6 @@ static void gp_stroke_path_animation(bContext *C, Curve *cu, tGpTimingData *gtd) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); bAction *act; @@ -538,7 +532,7 @@ static void gp_stroke_path_animation(bContext *C, cu->ctime = 0.0f; cfra = (float)gtd->start_frame; insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); cu->ctime = cu->pathlen; if (gtd->realtime) { @@ -548,7 +542,7 @@ static void gp_stroke_path_animation(bContext *C, cfra = (float)gtd->end_frame; } insert_keyframe_direct( - depsgraph, reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); + reports, ptr, prop, fcu, cfra, BEZT_KEYTYPE_KEYFRAME, NULL, INSERTKEY_FAST); } else { /* Use actual recorded timing! */ @@ -575,7 +569,7 @@ static void gp_stroke_path_animation(bContext *C, } gp_stroke_path_animation_add_keyframes( - depsgraph, reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); + reports, ptr, prop, fcu, cu, gtd, rng, time_range, nbr_gaps, tot_gaps_time); BLI_rng_free(rng); } @@ -1250,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 b0c9f9ae6a8..0928913aad5 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 541419fc31d..5224436b52a 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -141,7 +141,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; @@ -161,6 +160,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 */ @@ -1383,7 +1383,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", ""); @@ -2497,7 +2497,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); @@ -2572,7 +2572,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"); @@ -2665,7 +2665,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; @@ -3375,7 +3375,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; @@ -3520,7 +3520,7 @@ void GPENCIL_OT_reproject(wmOperatorType *ot) "CURSOR", 0, "Cursor", - "Reproject the strokes using the orienation of 3D cursor"}, + "Reproject the strokes using the orientation of 3D cursor"}, {0, NULL, 0, NULL, NULL}, }; @@ -3538,7 +3538,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( @@ -4528,7 +4528,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 1fb5ea3a016..c9bfae643b7 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -601,7 +601,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_ops.c b/source/blender/editors/gpencil/gpencil_ops.c index 43b7dbe32d6..faa2367f558 100644 --- a/source/blender/editors/gpencil/gpencil_ops.c +++ b/source/blender/editors/gpencil/gpencil_ops.c @@ -81,9 +81,15 @@ static bool gp_stroke_paintmode_poll_with_tool(bContext *C, const char gpencil_t { /* TODO: limit this to mode, but review 2D editors */ bGPdata *gpd = CTX_data_gpencil_data(C); + if (!gpd) + return false; + ToolSettings *ts = CTX_data_tool_settings(C); + if (!ts || !ts->gp_paint) + return false; + Brush *brush = BKE_paint_brush(&ts->gp_paint->paint); - return ((gpd) && (gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && + return ((gpd->flag & GP_DATA_STROKE_PAINTMODE) && (brush && brush->gpencil_settings) && WM_toolsystem_active_tool_is_brush(C) && (brush->gpencil_tool == gpencil_tool)); } 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 bc47d89234f..a75caf58173 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1001,7 +1001,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); @@ -1206,7 +1206,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); @@ -1274,7 +1274,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); @@ -1498,7 +1498,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..a475e43755c 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}; @@ -1094,7 +1093,7 @@ void ED_gp_project_point_to_plane(const Scene *scene, /* get a vector from the point with the current view direction of the viewport */ ED_view3d_global_to_vector(rv3d, &pt->x, vn); - /* calculate line extrem point to create a ray that cross the plane */ + /* calculate line extreme point to create a ray that cross the plane */ mul_v3_fl(vn, -50.0f); add_v3_v3v3(ray, &pt->x, vn); diff --git a/source/blender/editors/include/ED_anim_api.h b/source/blender/editors/include/ED_anim_api.h index 230d62d400c..a232e1376d3 100644 --- a/source/blender/editors/include/ED_anim_api.h +++ b/source/blender/editors/include/ED_anim_api.h @@ -27,6 +27,7 @@ struct AnimData; struct ID; struct ListBase; +struct Depsgraph; struct ARegion; struct Main; @@ -84,8 +85,6 @@ typedef struct bAnimContext { /** dopesheet data for editor (or which is being used) */ struct bDopeSheet *ads; - /** active dependency graph */ - struct Depsgraph *depsgraph; /** Current Main */ struct Main *bmain; /** active scene */ diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 9fa8996c384..05f641abe91 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -127,7 +127,7 @@ typedef enum eKeyframeExtremeDrawOpts { KEYFRAME_EXTREME_MAX = (1 << 1), /* Grouped keys have different states. */ KEYFRAME_EXTREME_MIXED = (1 << 2), - /* Both neigbors are equal to this key. */ + /* Both neighbors are equal to this key. */ KEYFRAME_EXTREME_FLAT = (1 << 3), } eKeyframeExtremeDrawOpts; diff --git a/source/blender/editors/include/ED_keyframing.h b/source/blender/editors/include/ED_keyframing.h index a893f03bd88..8f197fa9afe 100644 --- a/source/blender/editors/include/ED_keyframing.h +++ b/source/blender/editors/include/ED_keyframing.h @@ -113,8 +113,7 @@ int insert_vert_fcurve( * Use this to insert a keyframe using the current value being keyframed, in the * nominated F-Curve (no creation of animation data performed). Returns success. */ -bool insert_keyframe_direct(struct Depsgraph *depsgraph, - struct ReportList *reports, +bool insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, @@ -130,7 +129,6 @@ bool insert_keyframe_direct(struct Depsgraph *depsgraph, * using the current value being keyframed, in the relevant place. Returns success. */ short insert_keyframe(struct Main *bmain, - struct Depsgraph *depsgraph, struct ReportList *reports, struct ID *id, struct bAction *act, 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_object.h b/source/blender/editors/include/ED_object.h index 038f1bf52a6..5f9534a1f1c 100644 --- a/source/blender/editors/include/ED_object.h +++ b/source/blender/editors/include/ED_object.h @@ -166,13 +166,11 @@ void ED_object_vpaintmode_enter_ex(struct Main *bmain, struct wmWindowManager *wm, struct Scene *scene, struct Object *ob); -void ED_object_vpaintmode_enter(struct bContext *C); void ED_object_wpaintmode_enter_ex(struct Main *bmain, struct Depsgraph *depsgraph, struct wmWindowManager *wm, struct Scene *scene, struct Object *ob); -void ED_object_wpaintmode_enter(struct bContext *C); void ED_object_vpaintmode_exit_ex(struct Object *ob); void ED_object_vpaintmode_exit(struct bContext *C); @@ -185,12 +183,10 @@ void ED_object_sculptmode_enter_ex(struct Main *bmain, struct Object *ob, const bool force_dyntopo, struct ReportList *reports); -void ED_object_sculptmode_enter(struct bContext *C, struct ReportList *reports); void ED_object_sculptmode_exit_ex(struct Main *bmain, struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob); -void ED_object_sculptmode_exit(struct bContext *C); void ED_object_location_from_view(struct bContext *C, float loc[3]); void ED_object_rotation_from_quat(float rot[3], const float quat[4], const char align_axis); @@ -271,7 +267,6 @@ bool ED_object_mode_compat_set(struct bContext *C, struct ReportList *reports); void ED_object_mode_toggle(struct bContext *C, eObjectMode mode); void ED_object_mode_set(struct bContext *C, eObjectMode mode); -void ED_object_mode_exit(struct bContext *C); bool ED_object_mode_generic_enter(struct bContext *C, eObjectMode object_mode); void ED_object_mode_generic_exit(struct Main *bmain, 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/include/UI_icons.h b/source/blender/editors/include/UI_icons.h index 47cf827ed66..03a49943ed3 100644 --- a/source/blender/editors/include/UI_icons.h +++ b/source/blender/editors/include/UI_icons.h @@ -90,8 +90,8 @@ DEF_ICON(COPY_ID) DEF_ICON(EYEDROPPER) DEF_ICON_BLANK(92) DEF_ICON(AUTO) -DEF_ICON(CHECKBOX_DEHLT) /* de-Hilight - Checkbox OFF */ -DEF_ICON(CHECKBOX_HLT) /* Hilight - Checkbox ON */ +DEF_ICON(CHECKBOX_DEHLT) /* de-Highlight - Checkbox OFF */ +DEF_ICON(CHECKBOX_HLT) /* Highlight - Checkbox ON */ DEF_ICON(UNLOCKED) DEF_ICON(LOCKED) DEF_ICON(UNPINNED) diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 5ff200fa7e4..4d87cc22ef2 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -286,12 +286,11 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) if (special) { /* NLA Strip property */ if (IS_AUTOKEY_ON(scene)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; insert_keyframe_direct( - depsgraph, reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0); + reports, but->rnapoin, but->rnaprop, fcu, cfra, ts->keyframe_type, NULL, 0); WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } } @@ -300,12 +299,10 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) * making it easier to set up corrective drivers */ if (IS_AUTOKEY_ON(scene)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; - insert_keyframe_direct(depsgraph, - reports, + insert_keyframe_direct(reports, but->rnapoin, but->rnaprop, fcu, @@ -321,7 +318,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) /* TODO: this should probably respect the keyingset only option for anim */ if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; short flag = ANIM_get_keyframing_flags(scene, 1); @@ -333,7 +329,6 @@ void ui_but_anim_autokey(bContext *C, uiBut *but, Scene *scene, float cfra) * E.g., color wheels (see T42567). */ BLI_assert((fcu->array_index == but->rnaindex) || (but->rnaindex == -1)); insert_keyframe(bmain, - depsgraph, reports, id, action, 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/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d4e8b7548bc..245277c8d22 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -10113,31 +10113,18 @@ static int ui_handler_region_menu(bContext *C, const wmEvent *event, void *UNUSE if (but) { bScreen *screen = CTX_wm_screen(C); - ARegion *ar_temp; uiBut *but_other; uiHandleButtonData *data; - bool is_inside_menu = false; - - /* look for a popup menu containing the mouse */ - for (ar_temp = screen->regionbase.first; ar_temp; ar_temp = ar_temp->next) { - rcti winrct; - - ui_region_winrct_get_no_margin(ar_temp, &winrct); - - if (BLI_rcti_isect_pt_v(&winrct, &event->x) || ui_region_find_active_but(ar_temp)) { - BLI_assert(ar_temp->type->regionid == RGN_TYPE_TEMPORARY); - - is_inside_menu = true; - break; - } - } /* handle activated button events */ data = but->active; if ((data->state == BUTTON_STATE_MENU_OPEN) && + /* Make sure this popup isn't dragging a button. + * can happen with popovers (see T67882). */ + (ui_region_find_active_but(data->menu->region) == NULL) && /* make sure mouse isn't inside another menu (see T43247) */ - (is_inside_menu == false) && + (ui_screen_region_find_mouse_over(screen, event) == NULL) && (ELEM(but->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU)) && (but_other = ui_but_find_mouse_over(ar, event)) && (but != but_other) && (ELEM(but_other->type, UI_BTYPE_PULLDOWN, UI_BTYPE_POPOVER, UI_BTYPE_MENU))) { diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index ea5ef94d90d..7584a43a790 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -464,7 +464,7 @@ DEF_ICON_VECTOR_COLORSET_DRAW_NTH(20, 19) # undef DEF_ICON_VECTOR_COLORSET_DRAW_NTH /* Dynamically render icon instead of rendering a plain color to a texture/buffer - * This is mot strictly a "vicon", as it needs access to icon->obj to get the color info, + * This is not strictly a "vicon", as it needs access to icon->obj to get the color info, * but it works in a very similar way. */ static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h) diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index fc65129ebf7..a5d9d35e2fe 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -938,6 +938,9 @@ uiBut *ui_region_find_active_but(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT; bool ui_region_contains_point_px(const struct ARegion *ar, int x, int y) ATTR_WARN_UNUSED_RESULT; bool ui_region_contains_rect_px(const struct ARegion *ar, const rcti *rect_px); +ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y); +ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const struct wmEvent *event); + /* interface_context_menu.c */ bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); void ui_popup_context_menu_for_panel(struct bContext *C, struct ARegion *ar, struct Panel *pa); diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 462183b4245..d0efb3714bc 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -570,3 +570,29 @@ bool ui_region_contains_rect_px(const ARegion *ar, const rcti *rect_px) } /** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Screen (#bScreen) Spatial + * \{ */ + +/** Check if the cursor is over any popups. */ +ARegion *ui_screen_region_find_mouse_over_ex(bScreen *screen, int x, int y) +{ + for (ARegion *ar = screen->regionbase.first; ar; ar = ar->next) { + rcti winrct; + + ui_region_winrct_get_no_margin(ar, &winrct); + + if (BLI_rcti_isect_pt(&winrct, x, y)) { + return ar; + } + } + return NULL; +} + +ARegion *ui_screen_region_find_mouse_over(bScreen *screen, const wmEvent *event) +{ + return ui_screen_region_find_mouse_over_ex(screen, event->x, event->y); +} + +/** \} */ diff --git a/source/blender/editors/interface/interface_region_hud.c b/source/blender/editors/interface/interface_region_hud.c index bba5103bc03..54bdbe0ec6e 100644 --- a/source/blender/editors/interface/interface_region_hud.c +++ b/source/blender/editors/interface/interface_region_hud.c @@ -70,7 +70,7 @@ static bool last_redo_poll(const bContext *C, short region_type) bool success = false; { - /* Make sure that we are using the same region type as the originial + /* Make sure that we are using the same region type as the original * operator call. Otherwise we would be polling the operator with the * wrong context. */ diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index 7d9b722fcc0..b57d100127e 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -31,6 +31,7 @@ #include "BLI_blenlib.h" #include "BLI_utildefines.h" #include "BLI_math_base.h" +#include "BLI_math_vector.h" #include "BKE_context.h" @@ -1146,33 +1147,49 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event } else if (event->type == MOUSEMOVE) { float dx, dy; + float zoomfac = 0.01f; + + /* some view2d's (graph) don't have min/max zoom, or extreme ones */ + if (v2d->maxzoom > 0.0f) { + zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); + } /* calculate new delta transform, based on zooming mode */ if (U.viewzoom == USER_ZOOM_SCALE) { /* 'scale' zooming */ float dist; + float len_old[2]; + float len_new[2]; /* x-axis transform */ dist = BLI_rcti_size_x(&v2d->mask) / 2.0f; - dx = 1.0f - (fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist) + 2.0f) / - (fabsf(event->mval[0] - dist) + 2.0f); - dx *= 0.5f * BLI_rctf_size_x(&v2d->cur); + len_old[0] = fabsf(vzd->lastx - vzd->ar->winrct.xmin - dist); + len_new[0] = fabsf(event->x - vzd->ar->winrct.xmin - dist); + + len_old[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur); + len_new[0] *= zoomfac * BLI_rctf_size_x(&v2d->cur); /* y-axis transform */ dist = BLI_rcti_size_y(&v2d->mask) / 2.0f; - dy = 1.0f - (fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist) + 2.0f) / - (fabsf(event->mval[1] - dist) + 2.0f); - dy *= 0.5f * BLI_rctf_size_y(&v2d->cur); + len_old[1] = fabsf(vzd->lasty - vzd->ar->winrct.ymin - dist); + len_new[1] = fabsf(event->y - vzd->ar->winrct.ymin - dist); + + len_old[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur); + len_new[1] *= zoomfac * BLI_rctf_size_y(&v2d->cur); + + /* Calculate distance */ + if (v2d->keepzoom & V2D_KEEPASPECT) { + dist = len_v2(len_new) - len_v2(len_old); + dx = dy = dist; + } + else { + dx = len_new[0] - len_old[0]; + dy = len_new[1] - len_old[1]; + } } else { /* 'continuous' or 'dolly' */ - float fac, zoomfac = 0.01f; - - /* some view2d's (graph) don't have min/max zoom, or extreme ones */ - if (v2d->maxzoom > 0.0f) { - zoomfac = clamp_f(0.001f * v2d->maxzoom, 0.001f, 0.01f); - } - + float fac; /* x-axis transform */ fac = zoomfac * (event->x - vzd->lastx); dx = fac * BLI_rctf_size_x(&v2d->cur); @@ -1180,6 +1197,18 @@ static int view_zoomdrag_modal(bContext *C, wmOperator *op, const wmEvent *event /* y-axis transform */ fac = zoomfac * (event->y - vzd->lasty); dy = fac * BLI_rctf_size_y(&v2d->cur); + + /* Only respect user setting zoom axis if the view does not have any zoom restrictions + * any will be scaled uniformly */ + if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && + (v2d->keepzoom & V2D_KEEPASPECT)) { + if (U.uiflag & USER_ZOOM_HORIZ) { + dy = 0; + } + else { + dx = 0; + } + } } /* support zoom to always zoom entirely - the v2d code uses portrait or 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 7d69816bf93..f40d041294a 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/mesh_mirror.c b/source/blender/editors/mesh/mesh_mirror.c index d76801a2500..e086eda9b33 100644 --- a/source/blender/editors/mesh/mesh_mirror.c +++ b/source/blender/editors/mesh/mesh_mirror.c @@ -278,7 +278,7 @@ void ED_mesh_mirrtopo_init(Mesh *me, } if ((tot_unique <= tot_unique_prev) && (tot_unique_edges <= tot_unique_edges_prev)) { - /* Finish searching for unique values when 1 loop dosn't give a + /* Finish searching for unique values when 1 loop doesn't give a * higher number of unique values compared to the previous loop. */ break; } 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 fae53bf7182..fe1d1b1dd46 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", @@ -2132,7 +2140,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); View3D *v3d = CTX_wm_view3d(C); 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..ed40a4eb948 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 */ @@ -1056,7 +1058,7 @@ void OBJECT_OT_paths_update(wmOperatorType *ot) ot->idname = "OBJECT_OT_paths_update"; ot->description = "Recalculate paths for selected objects"; - /* api callbakcs */ + /* api callbacks */ ot->exec = object_update_paths_exec; ot->poll = object_update_paths_poll; 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 0ec98e089a2..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); } } @@ -194,20 +186,6 @@ void ED_object_mode_set(bContext *C, eObjectMode mode) wm->op_undo_depth--; } -void ED_object_mode_exit(bContext *C) -{ - Depsgraph *depsgraph = CTX_data_depsgraph(C); - struct Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - FOREACH_OBJECT_BEGIN (view_layer, ob) { - if (ob->mode & OB_MODE_ALL_MODE_DATA) { - ED_object_mode_generic_exit(bmain, depsgraph, scene, ob); - } - } - FOREACH_OBJECT_END; -} - /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index d1d910021a6..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); @@ -2316,8 +2316,9 @@ static int ocean_bake_exec(bContext *C, wmOperator *op) for (f = omd->bakestart; f <= omd->bakeend; f++) { /* For now only simple animation of time value is supported, nothing else. * No drivers or other modifier parameters. */ - BKE_animsys_evaluate_animdata( - CTX_data_depsgraph(C), scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM); + /* TODO(sergey): This operates on an original data, so no flush is needed. However, baking + * usually should happen on an evaluated objects, so this seems to be deeper issue here. */ + BKE_animsys_evaluate_animdata(scene, (ID *)ob, ob->adt, f, ADT_RECALC_ANIM, false); och->time[i] = omd->time; i++; @@ -2402,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); @@ -2477,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..a69f4872e72 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( @@ -1727,7 +1727,7 @@ static Collection *single_object_users_collection(Main *bmain, const bool is_master_collection) { /* Generate new copies for objects in given collection and all its children, - * and optionnaly also copy collections themselves. */ + * and optionally also copy collections themselves. */ if (copy_collections && !is_master_collection) { collection = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection)); } 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 2f2516f2055..e6870cda19d 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -252,7 +252,7 @@ static void pe_update_hair_particle_edit_pointers(PTCacheEdit *edit) /* always gets at least the first particlesystem even if PSYS_CURRENT flag is not set * - * note: this function runs on poll, therefor it can runs many times a second + * note: this function runs on poll, therefore it can runs many times a second * keep it fast! */ static PTCacheEdit *pe_get_current(Depsgraph *depsgraph, Scene *scene, Object *ob, int create) { @@ -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); } @@ -1499,7 +1499,7 @@ static void PE_update_selection(Depsgraph *depsgraph, Scene *scene, Object *ob, DEG_id_tag_update(&ob->id, ID_RECALC_SELECT); } -void update_world_cos(Depsgraph *UNUSED(depsgraph), Object *ob, PTCacheEdit *edit) +void update_world_cos(Object *ob, PTCacheEdit *edit) { ParticleSystem *psys = edit->psys; ParticleSystemModifierData *psmd_eval = edit->psmd_eval; @@ -1619,7 +1619,7 @@ void PE_update_object(Depsgraph *depsgraph, Scene *scene, Object *ob, int usefla PE_apply_mirror(ob, edit->psys); } if (edit->psys) { - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); } if (pset->flag & PE_AUTO_VELOCITY) { update_velocities(edit); @@ -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; @@ -3519,7 +3519,7 @@ static int mirror_exec(bContext *C, wmOperator *UNUSED(op)) PE_mirror_x(scene, ob, 0); - update_world_cos(CTX_data_depsgraph(C), ob, edit); + update_world_cos(ob, edit); WM_event_add_notifier(C, NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -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; @@ -4747,7 +4747,7 @@ static void brush_edit_apply(bContext *C, wmOperator *op, PointerRNA *itemptr) PE_mirror_x(scene, ob, 1); } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -4993,7 +4993,6 @@ static void shape_cut(PEData *data, int pa_index) static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *scene = CTX_data_scene(C); Object *ob = CTX_data_active_object(C); ParticleEditSettings *pset = PE_settings(scene); @@ -5032,7 +5031,7 @@ static int shape_cut_exec(bContext *C, wmOperator *UNUSED(op)) recalc_lengths(edit); if (removed) { - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); psys_free_path_cache(NULL, edit); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } @@ -5203,7 +5202,7 @@ void PE_create_particle_edit( } pa++; } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); } else { PTCacheMem *pm; @@ -5295,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; @@ -5496,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 fcee2cde5b1..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; @@ -1037,7 +1037,7 @@ static void copy_particle_edit(Depsgraph *depsgraph, pa++; } - update_world_cos(depsgraph, ob, edit); + update_world_cos(ob, edit); UI_GetThemeColor3ubv(TH_EDGE_SELECT, edit->sel_col); UI_GetThemeColor3ubv(TH_WIRE, edit->nosel_col); @@ -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..44858e36fab 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) { @@ -714,7 +716,7 @@ static bool fluid_init_filepaths(Main *bmain, /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); - /* Ensure whole path exists and is wirtable. */ + /* Ensure whole path exists and is writeable. */ const bool dir_exists = BLI_dir_create_recursive(targetDir); const bool is_writable = BLI_file_is_writable(targetFile); @@ -747,7 +749,7 @@ static bool fluid_init_filepaths(Main *bmain, /* .tmp: don't overwrite/delete original file */ BLI_join_dirfile(targetFile, FILE_MAX, targetDir, suffixConfigTmp); - /* Ensure whole path exists and is wirtable. */ + /* Ensure whole path exists and is writeable. */ if (!BLI_dir_create_recursive(targetDir) || !BLI_file_is_writable(targetFile)) { BKE_reportf(reports, RPT_ERROR, @@ -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_intern.h b/source/blender/editors/physics/physics_intern.h index bb7cfe9b1a3..9ebbba07fdf 100644 --- a/source/blender/editors/physics/physics_intern.h +++ b/source/blender/editors/physics/physics_intern.h @@ -70,7 +70,7 @@ void recalc_lengths(struct PTCacheEdit *edit); void recalc_emitter_field(struct Depsgraph *depsgraph, struct Object *ob, struct ParticleSystem *psys); -void update_world_cos(struct Depsgraph *depsgraph, struct Object *ob, struct PTCacheEdit *edit); +void update_world_cos(struct Object *ob, struct PTCacheEdit *edit); /* particle_object.c */ void OBJECT_OT_particle_system_add(struct wmOperatorType *ot); 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_intern.h b/source/blender/editors/render/render_intern.h index 8e96e382328..5f402583da8 100644 --- a/source/blender/editors/render/render_intern.h +++ b/source/blender/editors/render/render_intern.h @@ -37,6 +37,7 @@ void OBJECT_OT_material_slot_select(struct wmOperatorType *ot); void OBJECT_OT_material_slot_deselect(struct wmOperatorType *ot); void OBJECT_OT_material_slot_copy(struct wmOperatorType *ot); void OBJECT_OT_material_slot_move(struct wmOperatorType *ot); +void OBJECT_OT_material_slot_remove_unused(struct wmOperatorType *ot); void OBJECT_OT_lanpr_update_gp_target(struct wmOperatorType *ot); 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_ops.c b/source/blender/editors/render/render_ops.c index c9b50302784..3512872cb15 100644 --- a/source/blender/editors/render/render_ops.c +++ b/source/blender/editors/render/render_ops.c @@ -42,6 +42,7 @@ void ED_operatortypes_render(void) WM_operatortype_append(OBJECT_OT_material_slot_deselect); WM_operatortype_append(OBJECT_OT_material_slot_copy); WM_operatortype_append(OBJECT_OT_material_slot_move); + WM_operatortype_append(OBJECT_OT_material_slot_remove_unused); WM_operatortype_append(OBJECT_OT_lanpr_update_gp_target); /* Not working */ diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index c646ef12846..9b380ad5db1 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -290,7 +290,7 @@ static void set_preview_visibility(Scene *scene, char pr_type, int pr_method) { - /* Set appropriate layer as visibile. */ + /* Set appropriate layer as visible. */ LayerCollection *lc = view_layer->layer_collections.first; const char *collection_name = preview_collection_name(pr_type); diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c index f7a1d7187f1..01740c13c9d 100644 --- a/source/blender/editors/render/render_shading.c +++ b/source/blender/editors/render/render_shading.c @@ -310,7 +310,7 @@ static int material_slot_de_select(bContext *C, bool select) } else { /* Find the first matching material. - * Note: there may be multiple but thats not a common use case. */ + * Note: there may be multiple but that's not a common use case. */ for (short i = 0; i < ob->totcol; i++) { const Material *mat = give_current_material(ob, i + 1); if (mat_active == mat) { @@ -549,6 +549,73 @@ void OBJECT_OT_material_slot_move(wmOperatorType *ot) "Direction to move the active material towards"); } +static int material_slot_remove_unused_exec(bContext *C, wmOperator *op) +{ + Object *ob = CTX_data_active_object(C); + + if (!ob) { + return OPERATOR_CANCELLED; + } + + /* Removing material slots in edit mode screws things up, see bug #21822.*/ + if (ob == CTX_data_edit_object(C)) { + BKE_report(op->reports, RPT_ERROR, "Unable to remove material slot in edit mode"); + return OPERATOR_CANCELLED; + } + + int actcol = ob->actcol; + + int removed = 0; + for (int slot = 1; slot <= ob->totcol; slot++) { + while (slot <= ob->totcol && !BKE_object_material_slot_used(ob->data, slot)) { + ob->actcol = slot; + BKE_object_material_slot_remove(CTX_data_main(C), ob); + + if (actcol >= slot) { + actcol--; + } + + removed++; + } + } + + ob->actcol = actcol; + + if (!removed) { + return OPERATOR_CANCELLED; + } + + BKE_reportf(op->reports, RPT_INFO, "Removed %d slots", removed); + + if (ob->mode & OB_MODE_TEXTURE_PAINT) { + Scene *scene = CTX_data_scene(C); + BKE_paint_proj_mesh_data_check(scene, ob, NULL, NULL, NULL, NULL); + WM_event_add_notifier(C, NC_SCENE | ND_TOOLSETTINGS, NULL); + } + + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, ob); + WM_event_add_notifier(C, NC_OBJECT | ND_OB_SHADING, ob); + WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_PREVIEW, ob); + + return OPERATOR_FINISHED; +} + +void OBJECT_OT_material_slot_remove_unused(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Remove Unused Slots"; + ot->idname = "OBJECT_OT_material_slot_remove_unused"; + ot->description = "Remove unused material slots"; + + /* api callbacks */ + ot->exec = material_slot_remove_unused_exec; + ot->poll = ED_operator_object_active_editable; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} + /********************** new material operator *********************/ static int new_material_exec(bContext *C, wmOperator *UNUSED(op)) @@ -859,7 +926,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 cf630ab65dd..3254b8d9f8a 100644 --- a/source/blender/editors/render/render_update.c +++ b/source/blender/editors/render/render_update.c @@ -140,7 +140,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/area.c b/source/blender/editors/screen/area.c index e5bbeafd89d..5099c370a85 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2696,7 +2696,7 @@ void ED_region_header_init(ARegion *ar) int ED_area_headersize(void) { - /* Accomodate widget and padding. */ + /* Accommodate widget and padding. */ return U.widget_unit + (int)(UI_DPI_FAC * HEADER_PADDING_Y); } diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index c9a45728bc2..eccd85ab276 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -1059,7 +1059,7 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) is_gesture = (delta_max > split_threshold); } else { - /* Different area, so posible join. */ + /* Different area, so possible join. */ if (sad->gesture_dir == 'n') { WM_cursor_set(win, BC_N_ARROWCURSOR); } @@ -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 f768a66a41c..e5527e7210d 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.c +++ b/source/blender/editors/sculpt_paint/paint_image_proj.c @@ -1771,7 +1771,7 @@ static float project_paint_uvpixel_mask(const ProjPaintState *ps, } else if (angle_cos < ps->normal_angle_inner__cos) { mask *= (ps->normal_angle - acosf(angle_cos)) / ps->normal_angle_range; - } /* otherwise no mask normal is needed, were within the limit */ + } /* otherwise no mask normal is needed, we're within the limit */ } /* This only works when the opacity doesn't change while painting, stylus pressure messes with @@ -3159,7 +3159,7 @@ static void project_paint_face_init(const ProjPaintState *ps, //#endif } -#if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +#if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -3215,7 +3215,7 @@ static void project_paint_face_init(const ProjPaintState *ps, * clipped by the bucket's screen aligned rectangle. */ float bucket_clip_edges[2][2]; float edge_verts_inset_clip[2][3]; - /* face edge pairs - loop throuh these: + /* face edge pairs - loop through these: * ((0,1), (1,2), (2,3), (3,0)) or ((0,1), (1,2), (2,0)) for a tri */ int fidx1, fidx2; @@ -3395,12 +3395,12 @@ static void project_paint_face_init(const ProjPaintState *ps, } else if (has_x_isect) { /* assuming the face is not a bow-tie - we know - * we cant intersect again on the X */ + * we can't intersect again on the X */ break; } } -# if 0 /* TODO - investigate why this dosnt work sometimes! it should! */ +# if 0 /* TODO - investigate why this doesn't work sometimes! it should! */ /* no intersection for this entire row, * after some intersection above means we can quit now */ if (has_x_isect == 0 && has_isect) { @@ -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); @@ -4388,7 +4388,7 @@ static void project_paint_prepare_all_faces(ProjPaintState *ps, image_index = BLI_linklist_index(image_LinkList.list, tpage); if (image_index == -1 && BKE_image_has_ibuf(tpage, NULL)) { - /* MemArena dosnt have an append func */ + /* MemArena doesn't have an append func */ BLI_linklist_append(&image_LinkList, tpage); image_index = ps->image_tot; ps->image_tot++; @@ -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_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c index 12891484e73..f073877ebcf 100644 --- a/source/blender/editors/sculpt_paint/paint_stroke.c +++ b/source/blender/editors/sculpt_paint/paint_stroke.c @@ -1329,7 +1329,7 @@ int paint_stroke_modal(bContext *C, wmOperator *op, const wmEvent *event) redraw = true; } - /* do updates for redraw. if event is inbetween mousemove there are more + /* do updates for redraw. if event is in between mouse-move there are more * coming, so postpone potentially slow redraw updates until all are done */ if (event->type != INBETWEEN_MOUSEMOVE) { wmWindow *window = CTX_wm_window(C); 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 47fa2872ff9..9215a90c446 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.c +++ b/source/blender/editors/sculpt_paint/paint_vertex.c @@ -1171,30 +1171,11 @@ void ED_object_vpaintmode_enter_ex( { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_VERTEX_PAINT); } -void ED_object_vpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_vpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} - void ED_object_wpaintmode_enter_ex( Main *bmain, Depsgraph *depsgraph, wmWindowManager *wm, Scene *scene, Object *ob) { ed_vwpaintmode_enter_generic(bmain, depsgraph, wm, scene, ob, OB_MODE_WEIGHT_PAINT); } -void ED_object_wpaintmode_enter(struct bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - wmWindowManager *wm = CTX_wm_manager(C); - Scene *scene = CTX_data_scene(C); - Object *ob = CTX_data_active_object(C); - ED_object_wpaintmode_enter_ex(bmain, depsgraph, wm, scene, ob); -} /** \} */ @@ -1396,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; } /** \} */ @@ -1556,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; @@ -2569,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; } /** \} */ @@ -2638,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); @@ -2705,8 +2686,9 @@ static bool vpaint_stroke_test_start(bContext *C, struct wmOperator *op, const f return 1; } -static void do_vpaint_brush_calc_average_color_cb_ex( - void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls)) +static void do_vpaint_brush_calc_average_color_cb_ex(void *__restrict userdata, + const int n, + const TaskParallelTLS *__restrict UNUSED(tls)) { SculptThreadedTaskData *data = userdata; SculptSession *ss = data->ob->sculpt; 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 4b35fdbd2ed..c8709d40f96 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1262,7 +1262,6 @@ float tex_strength(SculptSession *ss, /* Falloff curve */ avg *= BKE_brush_curve_strength(br, len, cache->radius); - avg *= frontface(br, cache->view_normal, vno, fno); /* Paint mask */ @@ -4923,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); } @@ -5136,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; @@ -5184,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); @@ -5753,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); @@ -5790,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; @@ -6153,16 +6152,6 @@ void ED_object_sculptmode_enter_ex(Main *bmain, DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_enter(struct bContext *C, ReportList *reports) -{ - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - ED_object_sculptmode_enter_ex(bmain, depsgraph, scene, ob, false, reports); -} - void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scene, Object *ob) { const int mode_flag = OB_MODE_SCULPT; @@ -6209,16 +6198,6 @@ void ED_object_sculptmode_exit_ex(Main *bmain, Depsgraph *depsgraph, Scene *scen DEG_id_tag_update(&ob->id, ID_RECALC_COPY_ON_WRITE); } -void ED_object_sculptmode_exit(bContext *C) -{ - Main *bmain = CTX_data_main(C); - Depsgraph *depsgraph = CTX_data_depsgraph(C); - Scene *scene = CTX_data_scene(C); - ViewLayer *view_layer = CTX_data_view_layer(C); - Object *ob = OBACT(view_layer); - ED_object_sculptmode_exit_ex(bmain, depsgraph, scene, ob); -} - static int sculpt_mode_toggle_exec(bContext *C, wmOperator *op) { struct wmMsgBus *mbus = CTX_wm_message_bus(C); @@ -6265,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_action/action_edit.c b/source/blender/editors/space_action/action_edit.c index 7fc84db3f75..944a0c74f4c 100644 --- a/source/blender/editors/space_action/action_edit.c +++ b/source/blender/editors/space_action/action_edit.c @@ -704,7 +704,6 @@ static void insert_action_keys(bAnimContext *ac, short mode) bAnimListElem *ale; int filter; - struct Depsgraph *depsgraph = ac->depsgraph; ReportList *reports = ac->reports; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; @@ -741,7 +740,6 @@ static void insert_action_keys(bAnimContext *ac, short mode) */ if (ale->id && !ale->owner) { insert_keyframe(ac->bmain, - depsgraph, reports, ale->id, NULL, diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index e1af9728685..5f04d0863a7 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -626,36 +626,35 @@ static void view_zoom_apply( bContext *C, ViewZoomData *vpd, wmOperator *op, const wmEvent *event, const bool zoom_to_pos) { float factor; + float delta; - if (U.viewzoom == USER_ZOOM_CONT) { - SpaceClip *sclip = CTX_wm_space_clip(C); - double time = PIL_check_seconds_timer(); - float time_step = (float)(time - vpd->timer_lastdraw); - float fac; - float zfac; - + if (U.viewzoom != USER_ZOOM_SCALE) { if (U.uiflag & USER_ZOOM_HORIZ) { - fac = (float)(event->x - vpd->x); + delta = (float)(event->x - vpd->x); } else { - fac = (float)(event->y - vpd->y); + delta = (float)(event->y - vpd->y); } + } + else { + delta = event->x - vpd->x + event->y - vpd->y; + } - if (U.uiflag & USER_ZOOM_INVERT) { - fac = -fac; - } + if (U.uiflag & USER_ZOOM_INVERT) { + delta = -delta; + } - zfac = 1.0f + ((fac / 20.0f) * time_step); + if (U.viewzoom == USER_ZOOM_CONT) { + SpaceClip *sclip = CTX_wm_space_clip(C); + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float zfac; + + zfac = 1.0f + ((delta / 20.0f) * time_step); vpd->timer_lastdraw = time; factor = (sclip->zoom * zfac) / vpd->zoom; } else { - float delta = event->x - vpd->x + event->y - vpd->y; - - if (U.uiflag & USER_ZOOM_INVERT) { - delta *= -1; - } - factor = 1.0f + delta / 300.0f; } diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 7e19ac255f0..c1cb975447f 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -556,17 +556,17 @@ static void clip_operatortypes(void) static void clip_keymap(struct wmKeyConfig *keyconf) { - /* ******** Global hotkeys avalaible for all regions ******** */ + /* ******** Global hotkeys available for all regions ******** */ WM_keymap_ensure(keyconf, "Clip", SPACE_CLIP, 0); - /* ******** Hotkeys avalaible for main region only ******** */ + /* ******** Hotkeys available for main region only ******** */ WM_keymap_ensure(keyconf, "Clip Editor", SPACE_CLIP, 0); // keymap->poll = ED_space_clip_tracking_poll; - /* ******** Hotkeys avalaible for preview region only ******** */ + /* ******** Hotkeys available for preview region only ******** */ WM_keymap_ensure(keyconf, "Clip Graph Editor", SPACE_CLIP, 0); - /* ******** Hotkeys avalaible for channels region only ******** */ + /* ******** Hotkeys available for channels region only ******** */ WM_keymap_ensure(keyconf, "Clip Dopesheet Editor", SPACE_CLIP, 0); } @@ -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, @@ -1224,7 +1224,7 @@ static void clip_header_region_listener(wmWindow *UNUSED(win), switch (wmn->data) { /* for proportional editmode only */ case ND_TOOLSETTINGS: - /* TODO - should do this when in mask mode only but no datas available */ + /* TODO - should do this when in mask mode only but no data available */ // if (sc->mode == SC_MODE_MASKEDIT) { ED_region_tag_redraw(ar); 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_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 9bdea13276b..3a6d59c1dbf 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -536,7 +536,7 @@ static void renamebutton_cb(bContext *C, void *UNUSED(arg1), char *oldname) WM_report_banner_show(); } else { - /* If rename is sucessfull, scroll to newly renamed entry. */ + /* If rename is successful, scroll to newly renamed entry. */ BLI_strncpy(sfile->params->renamefile, filename, sizeof(sfile->params->renamefile)); sfile->params->rename_flag = FILE_PARAMS_RENAME_POSTSCROLL_PENDING; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 4e50413513a..eb5f02b6e13 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1757,7 +1757,7 @@ static int file_smoothscroll_invoke(bContext *C, wmOperator *UNUSED(op), const w (middle_offset - min_middle_offset < items_block_size)); /* OR edited item must be towards the end, and we are scrolled fully to the end. * This one is crucial (unlike the one for the beginning), because without it we won't scroll - * fully to the end, and last column or row wil end up only partially drawn. */ + * fully to the end, and last column or row will end up only partially drawn. */ const bool is_full_end = ((sfile->scroll_offset > max_middle_offset) && (max_tot_scroll - max_curr_scroll < 1.0f) && (max_middle_offset - middle_offset < items_block_size)); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index faaecd975a3..db42d007b8e 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -28,7 +28,7 @@ #include <sys/stat.h> #include <sys/types.h> -/* path/file handeling stuff */ +/* path/file handling stuff */ #ifdef WIN32 # include <io.h> # include <direct.h> diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index b16374e0d66..e7ba498fc11 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -721,7 +721,7 @@ static void draw_fcurve_curve_bezts( v1[1] = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { - /* extrapolate linear dosnt use the handle, use the next points center instead */ + /* extrapolate linear doesn't use the handle, use the next points center instead */ fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) { fac = 1.0f / fac; @@ -840,7 +840,7 @@ static void draw_fcurve_curve_bezts( v1[1] = prevbezt->vec[1][1]; } else if (prevbezt->ipo == BEZT_IPO_LIN) { - /* extrapolate linear dosnt use the handle, use the previous points center instead */ + /* extrapolate linear doesn't use the handle, use the previous points center instead */ bezt = prevbezt - 1; fac = (prevbezt->vec[1][0] - bezt->vec[1][0]) / (prevbezt->vec[1][0] - v1[0]); if (fac) { diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index dc5837e3fd1..b624e21937f 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -604,7 +604,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) ReportList *reports = ac->reports; SpaceGraph *sipo = (SpaceGraph *)ac->sl; - struct Depsgraph *depsgraph = ac->depsgraph; Scene *scene = ac->scene; ToolSettings *ts = scene->toolsettings; short flag = 0; @@ -696,7 +695,6 @@ static void insert_graph_keys(bAnimContext *ac, eGraphKeys_InsertKey_Types mode) */ if (ale->id && !ale->owner && !fcu->driver) { insert_keyframe(ac->bmain, - depsgraph, reports, ale->id, NULL, diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index b79ed1c83c4..374a58d1808 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -556,39 +556,36 @@ static void image_zoom_apply(ViewZoomData *vpd, const bool zoom_to_pos) { float factor; + float delta; - if (viewzoom == USER_ZOOM_CONT) { - double time = PIL_check_seconds_timer(); - float time_step = (float)(time - vpd->timer_lastdraw); - float fac; - float zfac; - + if (viewzoom != USER_ZOOM_SCALE) { if (U.uiflag & USER_ZOOM_HORIZ) { - fac = (float)(x - vpd->origx); + delta = (float)(x - vpd->origx); } else { - fac = (float)(y - vpd->origy); + delta = (float)(y - vpd->origy); } + } + else { + delta = x - vpd->origx + y - vpd->origy; + } - if (zoom_invert) { - fac = -fac; - } + if (zoom_invert) { + delta = -delta; + } + + if (viewzoom == USER_ZOOM_CONT) { + double time = PIL_check_seconds_timer(); + float time_step = (float)(time - vpd->timer_lastdraw); + float zfac; /* oldstyle zoom */ - zfac = 1.0f + ((fac / 20.0f) * time_step); + zfac = 1.0f + ((delta / 20.0f) * time_step); vpd->timer_lastdraw = time; /* this is the final zoom, but instead make it into a factor */ - // zoom = vpd->sima->zoom * zfac; factor = (vpd->sima->zoom * zfac) / vpd->zoom; } else { - /* for now do the same things for scale and dolly */ - float delta = x - vpd->origx + y - vpd->origy; - - if (zoom_invert) { - delta *= -1.0f; - } - factor = 1.0f + delta / 300.0f; } 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_info/info_stats.c b/source/blender/editors/space_info/info_stats.c index 1c9a7d3584c..946274de882 100644 --- a/source/blender/editors/space_info/info_stats.c +++ b/source/blender/editors/space_info/info_stats.c @@ -158,7 +158,7 @@ static void stats_object(Object *ob, SceneStats *stats, GSet *objects_gset) if (stats_mesheval(me_eval, is_selected, stats)) { break; } - ATTR_FALLTHROUGH; /* Falltrough to displist. */ + ATTR_FALLTHROUGH; /* Fallthrough to displist. */ } case OB_MBALL: { int totv = 0, totf = 0, tottri = 0; diff --git a/source/blender/editors/space_node/node_ops.c b/source/blender/editors/space_node/node_ops.c index 0836617ab44..11933ef0811 100644 --- a/source/blender/editors/space_node/node_ops.c +++ b/source/blender/editors/space_node/node_ops.c @@ -143,7 +143,6 @@ void ED_operatormacros_node(void) "Move nodes and attach to frame", OPTYPE_UNDO | OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); @@ -153,7 +152,6 @@ void ED_operatormacros_node(void) "Move nodes and attach to frame", OPTYPE_UNDO | OPTYPE_REGISTER); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); RNA_boolean_set(mot->ptr, "remove_on_cancel", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); WM_operatortype_macro_define(ot, "NODE_OT_insert_offset"); @@ -168,7 +166,6 @@ void ED_operatormacros_node(void) OPTYPE_UNDO | OPTYPE_REGISTER); WM_operatortype_macro_define(ot, "NODE_OT_detach"); mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate"); - RNA_boolean_set(mot->ptr, "release_confirm", true); WM_operatortype_macro_define(ot, "NODE_OT_attach"); ot = WM_operatortype_append_macro("NODE_OT_duplicate_move", 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 ff0ab9285db..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); @@ -2886,7 +2886,7 @@ static int sequencer_view_all_preview_exec(bContext *C, wmOperator *UNUSED(op)) imgwidth = (scene->r.size * scene->r.xsch) / 100; imgheight = (scene->r.size * scene->r.ysch) / 100; - /* Apply aspect, dosnt need to be that accurate */ + /* Apply aspect, doesn't need to be that accurate */ imgwidth = (int)(imgwidth * (scene->r.xasp / scene->r.yasp)); if (((imgwidth >= width) || (imgheight >= height)) && ((width > 0) && (height > 0))) { @@ -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_text/space_text.c b/source/blender/editors/space_text/space_text.c index 24f282ff920..c5e90cf247d 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -254,7 +254,9 @@ static int text_context(const bContext *C, const char *member, bContextDataResul return 1; } else if (CTX_data_equals(member, "edit_text")) { - CTX_data_id_pointer_set(result, &st->text->id); + if (st->text != NULL) { + CTX_data_id_pointer_set(result, &st->text->id); + } return 1; } diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index cdaecdf06f1..7acff998e2b 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -1141,7 +1141,7 @@ static void view3d_header_region_listener(wmWindow *UNUSED(win), } /* From topbar, which ones are needed? split per header? */ - /* Disable for now, re-enable if neede, or remove - campbell. */ + /* Disable for now, re-enable if needed, or remove - campbell. */ #if 0 /* context changes */ switch (wmn->category) { 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 fd0d9c6891f..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 */ @@ -3585,7 +3587,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) float mval_f[2]; float zfac; - /* We cant use the depth, fallback to the old way that dosnt set the center depth */ + /* We can't use the depth, fallback to the old way that doesn't set the center depth */ copy_v3_v3(new_ofs, rv3d->ofs); { @@ -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..36eb07e9a2f 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); @@ -3956,7 +3956,7 @@ static int view3d_circle_select_exec(bContext *C, wmOperator *op) const int radius = RNA_int_get(op->ptr, "radius"); const int mval[2] = {RNA_int_get(op->ptr, "x"), RNA_int_get(op->ptr, "y")}; - /* Allow each selection type to allocate their own data thats used between executions. */ + /* Allow each selection type to allocate their own data that's used between executions. */ wmGesture *gesture = op->customdata; /* NULL when non-modal. */ wmGenericUserData wm_userdata_buf = {0}; wmGenericUserData *wm_userdata = gesture ? &gesture->user_data : &wm_userdata_buf; 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.c b/source/blender/editors/transform/transform.c index d8dd6aa97b5..5ef86c71d2d 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1595,11 +1595,8 @@ int transformEvent(TransInfo *t, const wmEvent *event) } /* confirm transform if launch key is released after mouse move */ - if (t->flag & T_RELEASE_CONFIRM) { - /* XXX Keyrepeat bug in Xorg messes this up, will test when fixed */ - if ((event->type == t->launch_event) && ISMOUSE(t->launch_event)) { - t->state = TRANS_CONFIRM; - } + if ((t->flag & T_RELEASE_CONFIRM) && event->type == t->launch_event) { + t->state = TRANS_CONFIRM; } } @@ -4640,8 +4637,13 @@ static void applyRotationValue(TransInfo *t, * Note that this is only needed when doing 'absolute' rotation * (i.e. from initial rotation again, typically when using numinput). * regular incremental rotation (from mouse/widget/...) will be called often enough, - * hence steps are small enough to be properly handled without that complicated trick. */ - if (is_large_rotation) { + * hence steps are small enough to be properly handled without that complicated trick. + * Note that we can only do that kind of stepped rotation if we have initial rotation values + * (and access to some actual rotation value storage). + * Otherwise, just assume it's useless (e.g. in case of mesh/UV/etc. editing). + * Also need to be in Euler rotation mode, the others never allow more than one turn anyway. + */ + if (is_large_rotation && td->ext != NULL && td->ext->rotOrder == ROT_MODE_EUL) { copy_v3_v3(td->ext->rot, td->ext->irot); for (float angle_progress = angle_step; fabsf(angle_progress) < fabsf(angle_final); angle_progress += angle_step) { diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b0f720bfdf7..833792379ae 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -102,7 +102,7 @@ typedef struct TransSnap { * Get the transform distance between two points (used by Closest snap) * * \note Return value can be anything, - * where the smallest absolute value defines whats closest. + * where the smallest absolute value defines what's closest. */ float (*distance)(struct TransInfo *t, const float p1[3], const float p2[3]); diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 5626e9b5c81..4eccf4c5071 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -6631,7 +6631,6 @@ void autokeyframe_object(bContext *C, Scene *scene, ViewLayer *view_layer, Objec // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); @@ -6658,11 +6657,9 @@ 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, - depsgraph, reports, id, adt->action, @@ -6777,7 +6774,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t // TODO: this should probably be done per channel instead... if (autokeyframe_cfra_can_key(scene, id)) { - Depsgraph *depsgraph = CTX_data_depsgraph(C); ReportList *reports = CTX_wm_reports(C); ToolSettings *ts = scene->toolsettings; KeyingSet *active_ks = ANIM_scene_get_active_keyingset(scene); @@ -6825,7 +6821,6 @@ void autokeyframe_pose(bContext *C, Scene *scene, Object *ob, int tmode, short t */ if (pchanName && STREQ(pchanName, pchan->name)) { insert_keyframe(bmain, - depsgraph, reports, id, act, @@ -9020,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..969e2558abb 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; @@ -1692,7 +1691,8 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve } } else { - if (U.flag & USER_RELEASECONFIRM) { + if (ISMOUSE(t->launch_event) && (U.flag & USER_RELEASECONFIRM)) { + /* Global "release confirm" on mouse bindings */ t->flag |= T_RELEASE_CONFIRM; } } 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..c84d7539cce 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) { @@ -748,7 +739,7 @@ void ED_undo_object_editmode_restore_helper(struct bContext *C, Main *bmain = CTX_data_main(C); ViewLayer *view_layer = CTX_data_view_layer(C); uint bases_len = 0; - /* Don't request unique data because we wan't to de-select objects when exiting edit-mode + /* Don't request unique data because we want to de-select objects when exiting edit-mode * for that to be done on all objects we can't skip ones that share data. */ Base **bases = BKE_view_layer_array_from_bases_in_edit_mode(view_layer, NULL, &bases_len); for (uint i = 0; i < bases_len; i++) { 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/util/select_buffer_utils.c b/source/blender/editors/util/select_buffer_utils.c index 79f0f48830e..2201ee5cec2 100644 --- a/source/blender/editors/util/select_buffer_utils.c +++ b/source/blender/editors/util/select_buffer_utils.c @@ -216,7 +216,7 @@ uint ED_select_buffer_sample_point(const int center[2]) /** * Find the selection id closest to \a center. * \param dist[in,out]: Use to initialize the distance, - * when found, this value is set to the distance of the selection thats returned. + * when found, this value is set to the distance of the selection that's returned. */ uint ED_select_buffer_find_nearest_to_point(const int center[2], const uint id_min, diff --git a/source/blender/editors/uvedit/uvedit_buttons.c b/source/blender/editors/uvedit/uvedit_buttons.c index 1482fea456d..2abbe67237e 100644 --- a/source/blender/editors/uvedit/uvedit_buttons.c +++ b/source/blender/editors/uvedit/uvedit_buttons.c @@ -40,8 +40,9 @@ #include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_screen.h" #include "BKE_editmesh.h" +#include "BKE_layer.h" +#include "BKE_screen.h" #include "DEG_depsgraph.h" @@ -57,7 +58,8 @@ /* UV Utilities */ -static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float center[2]) +static int uvedit_center( + Scene *scene, Object **objects, uint objects_len, Image *ima, float center[2]) { BMFace *f; BMLoop *l; @@ -65,19 +67,24 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im MLoopUV *luv; int tot = 0; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - zero_v2(center); - BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, f)) { - continue; - } - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(center, luv->uv); - tot++; + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, obedit, ima, f)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + add_v2_v2(center, luv->uv); + tot++; + } } } } @@ -91,24 +98,29 @@ static int uvedit_center(Scene *scene, Object *obedit, BMEditMesh *em, Image *im } static void uvedit_translate( - Scene *scene, Object *obedit, BMEditMesh *em, Image *ima, float delta[2]) + Scene *scene, Object **objects, uint objects_len, Image *ima, float delta[2]) { BMFace *f; BMLoop *l; BMIter iter, liter; MLoopUV *luv; - const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + BMEditMesh *em = BKE_editmesh_from_object(obedit); - BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { - if (!uvedit_face_visible_test(scene, obedit, ima, f)) { - continue; - } + const int cd_loop_uv_offset = CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV); - BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { - if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { - luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); - add_v2_v2(luv->uv, delta); + BM_ITER_MESH (f, &iter, em->bm, BM_FACES_OF_MESH) { + if (!uvedit_face_visible_test(scene, obedit, ima, f)) { + continue; + } + + BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) { + if (uvedit_uv_select_test(scene, l, cd_loop_uv_offset)) { + luv = BM_ELEM_CD_GET_VOID_P(l, cd_loop_uv_offset); + add_v2_v2(luv->uv, delta); + } } } } @@ -122,18 +134,17 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); Image *ima = sima->image; - BMEditMesh *em; float center[2]; int imx, imy, step, digits; float width = 8 * UI_UNIT_X; + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len); ED_space_image_get_size(sima, &imx, &imy); - em = BKE_editmesh_from_object(obedit); - - if (uvedit_center(scene, obedit, em, ima, center)) { + if (uvedit_center(scene, objects, objects_len, ima, center)) { float range_xy[2][2] = { {-10.0f, 10.0f}, {-10.0f, 10.0f}, @@ -193,15 +204,15 @@ static void uvedit_vertex_buttons(const bContext *C, uiBlock *block) ""); UI_block_align_end(block); } + + MEM_freeN(objects); } static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) { SpaceImage *sima = CTX_wm_space_image(C); Scene *scene = CTX_data_scene(C); - Object *obedit = CTX_data_edit_object(C); Image *ima = sima->image; - BMEditMesh *em; float center[2], delta[2]; int imx, imy; @@ -209,10 +220,12 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) return; } - em = BKE_editmesh_from_object(obedit); + uint objects_len = 0; + Object **objects = BKE_view_layer_array_from_objects_in_edit_mode_unique_data_with_uvs( + CTX_data_view_layer(C), CTX_wm_view3d(C), &objects_len); ED_space_image_get_size(sima, &imx, &imy); - uvedit_center(scene, obedit, em, ima, center); + uvedit_center(scene, objects, objects_len, ima, center); if (sima->flag & SI_COORDFLOATS) { delta[0] = uvedit_old_center[0] - center[0]; @@ -223,10 +236,15 @@ static void do_uvedit_vertex(bContext *C, void *UNUSED(arg), int event) delta[1] = uvedit_old_center[1] / imy - center[1]; } - uvedit_translate(scene, obedit, em, ima, delta); + uvedit_translate(scene, objects, objects_len, ima, delta); WM_event_add_notifier(C, NC_IMAGE, sima->image); - DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY); + for (uint ob_index = 0; ob_index < objects_len; ob_index++) { + Object *obedit = objects[ob_index]; + DEG_id_tag_update((ID *)obedit->data, ID_RECALC_GEOMETRY); + } + + MEM_freeN(objects); } /* Panels */ 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); |