From 20220d47e38c4ad22ad89481fd40b804cc2fd1ef Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 21 Feb 2013 19:33:04 +0000 Subject: Dependency Graph: some refactoring which should have no user visible impact besides performance in some cases. * DAG_scene_sort is now removed and replaced by DAG_relations_tag_update in most cases. This will clear the dependency graph, and only rebuild it right before it's needed again when the scene is re-evaluated. This is done because DAG_scene_sort is slow when called many times from python operators. Further the scene argument is not needed because most operations can potentially affect more than the current scene. * DAG_scene_relations_update will now rebuild the dependency graph if it's not there yet, and DAG_scene_relations_rebuild will force a rebuild for the rare cases that need it. * Remove various places where ob->recalc was set manually. This should go through DAG_id_tag_update() in nearly all cases instead since this is now a fast operation. Also removed DAG_ids_flush_update that goes along with such manual tagging of ob->recalc. --- source/blender/editors/animation/drivers.c | 4 -- source/blender/editors/animation/keyframing.c | 26 +------- source/blender/editors/animation/keyingsets.c | 7 +- source/blender/editors/armature/editarmature.c | 4 +- source/blender/editors/curve/editcurve.c | 4 +- .../editors/interface/interface_templates.c | 3 +- source/blender/editors/mesh/editmesh_tools.c | 6 +- source/blender/editors/mesh/meshtools.c | 2 +- source/blender/editors/object/object_add.c | 38 +++++------ source/blender/editors/object/object_constraint.c | 17 ++--- source/blender/editors/object/object_edit.c | 24 ++++--- source/blender/editors/object/object_group.c | 10 +-- source/blender/editors/object/object_hook.c | 2 +- source/blender/editors/object/object_modifier.c | 18 ++---- source/blender/editors/object/object_relations.c | 74 ++++++++-------------- source/blender/editors/object/object_transform.c | 7 -- source/blender/editors/physics/dynamicpaint_ops.c | 2 +- source/blender/editors/physics/particle_boids.c | 6 +- source/blender/editors/physics/particle_object.c | 9 +-- .../blender/editors/physics/rigidbody_constraint.c | 6 +- source/blender/editors/physics/rigidbody_object.c | 8 --- source/blender/editors/space_graph/graph_buttons.c | 5 +- .../blender/editors/space_outliner/outliner_edit.c | 14 ++-- .../editors/space_outliner/outliner_tools.c | 14 +--- source/blender/editors/space_view3d/view3d_snap.c | 12 ++-- .../editors/transform/transform_conversions.c | 2 + 26 files changed, 109 insertions(+), 215 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 25833c13925..cd5e873f40d 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -489,8 +489,6 @@ static int add_driver_button_exec(bContext *C, wmOperator *op) /* send updates */ uiContextAnimUpdate(C); - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } @@ -541,8 +539,6 @@ static int remove_driver_button_exec(bContext *C, wmOperator *op) /* send updates */ uiContextAnimUpdate(C); - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_ANIMATION | ND_FCURVES_ORDER, NULL); // XXX } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index c99f939300e..6d1e6eab26b 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -1215,7 +1215,6 @@ static int modify_key_op_poll(bContext *C) static int insert_key_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; int type = RNA_enum_get(op->ptr, "type"); @@ -1261,9 +1260,6 @@ static int insert_key_exec(bContext *C, wmOperator *op) else BKE_report(op->reports, RPT_WARNING, "Keying set failed to insert any keyframes"); - /* send updates */ - DAG_ids_flush_update(bmain, 0); - return OPERATOR_FINISHED; } @@ -1371,7 +1367,6 @@ void ANIM_OT_keyframe_insert_menu(wmOperatorType *ot) static int delete_key_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; int type = RNA_enum_get(op->ptr, "type"); @@ -1417,9 +1412,6 @@ static int delete_key_exec(bContext *C, wmOperator *op) else BKE_report(op->reports, RPT_WARNING, "Keying set failed to remove any keyframes"); - /* send updates */ - DAG_ids_flush_update(bmain, 0); - return OPERATOR_FINISHED; } @@ -1459,8 +1451,6 @@ void ANIM_OT_keyframe_delete(wmOperatorType *ot) static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); - CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { /* just those in active action... */ @@ -1505,12 +1495,11 @@ static int clear_anim_v3d_exec(bContext *C, wmOperator *UNUSED(op)) } /* update... */ - ob->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); return OPERATOR_FINISHED; @@ -1536,7 +1525,6 @@ void ANIM_OT_keyframe_clear_v3d(wmOperatorType *ot) static int delete_key_v3d_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); float cfra = (float)CFRA; @@ -1563,12 +1551,11 @@ static int delete_key_v3d_exec(bContext *C, wmOperator *op) /* report success (or failure) */ BKE_reportf(op->reports, RPT_INFO, "Object '%s' successfully had %d keyframes removed", id->name + 2, success); - ob->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, NULL); return OPERATOR_FINISHED; @@ -1596,7 +1583,6 @@ void ANIM_OT_keyframe_delete_v3d(wmOperatorType *ot) static int insert_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; @@ -1655,8 +1641,6 @@ static int insert_key_button_exec(bContext *C, wmOperator *op) /* send updates */ uiContextAnimUpdate(C); - DAG_ids_flush_update(bmain, 0); - /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } @@ -1686,7 +1670,6 @@ void ANIM_OT_keyframe_insert_button(wmOperatorType *ot) static int delete_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; @@ -1728,8 +1711,6 @@ static int delete_key_button_exec(bContext *C, wmOperator *op) /* send updates */ uiContextAnimUpdate(C); - DAG_ids_flush_update(bmain, 0); - /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } @@ -1760,7 +1741,6 @@ void ANIM_OT_keyframe_delete_button(wmOperatorType *ot) static int clear_key_button_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); PointerRNA ptr = {{NULL}}; PropertyRNA *prop = NULL; char *path; @@ -1800,8 +1780,6 @@ static int clear_key_button_exec(bContext *C, wmOperator *op) /* send updates */ uiContextAnimUpdate(C); - DAG_ids_flush_update(bmain, 0); - /* send notifiers that keyframes have been changed */ WM_event_add_notifier(C, NC_ANIMATION | ND_KEYFRAME | NA_EDITED, NULL); } diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 28db7bf572d..4e8d7bdafe5 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -289,7 +289,6 @@ void ANIM_OT_keying_set_path_remove(wmOperatorType *ot) static int add_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop = NULL; @@ -360,7 +359,6 @@ static int add_keyingset_button_exec(bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); /* show notification/report header, so that users notice that something changed */ @@ -392,7 +390,6 @@ void ANIM_OT_keyingset_button_add(wmOperatorType *ot) static int remove_keyingset_button_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks = NULL; PropertyRNA *prop = NULL; @@ -442,7 +439,6 @@ static int remove_keyingset_button_exec(bContext *C, wmOperator *op) if (success) { /* send updates */ - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE | ND_KEYINGSET, NULL); /* show warning */ @@ -1006,7 +1002,8 @@ int ANIM_apply_keyingset(bContext *C, ListBase *dsources, bAction *act, KeyingSe { Object *ob = (Object *)ksp->id; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; // XXX: only object transforms only? + // XXX: only object transforms? + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } break; } diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c index 06e00cd02c1..2eac6ba87ee 100644 --- a/source/blender/editors/armature/editarmature.c +++ b/source/blender/editors/armature/editarmature.c @@ -1004,7 +1004,7 @@ int join_armature_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); /* because we removed object(s) */ + DAG_relations_tag_update(bmain); /* because we removed object(s) */ ED_armature_from_edit(ob); ED_armature_edit_free(ob); @@ -1217,7 +1217,7 @@ static int separate_armature_exec(bContext *C, wmOperator *UNUSED(op)) /* 2) duplicate base */ newbase = ED_object_add_duplicate(bmain, scene, oldbase, USER_DUP_ARM); /* only duplicate linked armature */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); newob = newbase->object; newbase->flag &= ~SELECT; diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index e736c494add..b5aa55dbda9 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1395,7 +1395,7 @@ static int separate_exec(bContext *C, wmOperator *op) /* 1. duplicate the object and data */ newbase = ED_object_add_duplicate(bmain, scene, oldbase, 0); /* 0 = fully linked */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); ED_base_object_select(newbase, BA_DESELECT); newob = newbase->object; @@ -6218,7 +6218,7 @@ int join_curve_exec(bContext *C, wmOperator *UNUSED(op)) cu = ob->data; BLI_movelisttolist(&cu->nurb, &tempbase); - DAG_scene_sort(bmain, scene); // because we removed object(s), call before editmode! + DAG_relations_tag_update(bmain); // because we removed object(s), call before editmode! ED_object_enter_editmode(C, EM_WAITCURSOR); ED_object_exit_editmode(C, EM_FREEDATA | EM_WAITCURSOR | EM_DO_UNDO); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 8e4d0289f78..adc40288777 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -1048,9 +1048,8 @@ static void do_constraint_panels(bContext *C, void *ob_pt, int event) case B_CONSTRAINT_CHANGETARGET: { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); if (ob->pose) ob->pose->flag |= POSE_RECALC; /* checks & sorts pose channels */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); break; } #endif diff --git a/source/blender/editors/mesh/editmesh_tools.c b/source/blender/editors/mesh/editmesh_tools.c index ee1d19de7b0..1448b53d997 100644 --- a/source/blender/editors/mesh/editmesh_tools.c +++ b/source/blender/editors/mesh/editmesh_tools.c @@ -2389,7 +2389,7 @@ static void shape_propagate(BMEditMesh *em, wmOperator *op) //TAG Mesh Objects that share this data for (base = scene->base.first; base; base = base->next) { if (base->object && base->object->data == me) { - base->object->recalc = OB_RECALC_DATA; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } #endif @@ -3042,7 +3042,7 @@ static int mesh_separate_tagged(Main *bmain, Scene *scene, Base *base_old, BMesh CustomData_bmesh_init_pool(&bm_new->pdata, bm_mesh_allocsize_default.totface, BM_FACE); base_new = ED_object_add_duplicate(bmain, scene, base_old, USER_DUP_MESH); - /* DAG_scene_sort(bmain, scene); */ /* normally would call directly after but in this case delay recalc */ + /* DAG_relations_tag_update(bmain); */ /* normally would call directly after but in this case delay recalc */ assign_matarar(base_new->object, give_matarar(obedit), *give_totcolp(obedit)); /* new in 2.5 */ ED_base_object_select(base_new, BA_SELECT); @@ -3276,7 +3276,7 @@ static int edbm_separate_exec(bContext *C, wmOperator *op) if (retval) { /* delay depsgraph recalc until all objects are duplicated */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mesh/meshtools.c b/source/blender/editors/mesh/meshtools.c index cb69faa5b51..f983a43f573 100644 --- a/source/blender/editors/mesh/meshtools.c +++ b/source/blender/editors/mesh/meshtools.c @@ -559,7 +559,7 @@ int join_mesh_exec(bContext *C, wmOperator *op) } - DAG_scene_sort(bmain, scene); // removed objects, need to rebuild dag before editmode call + DAG_relations_tag_update(bmain); // removed objects, need to rebuild dag #if 0 ED_object_enter_editmode(C, EM_WAITCURSOR); diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index ab9cd55f99b..bc577f6ee29 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -381,7 +381,7 @@ Object *ED_object_add_type(bContext *C, int type, const float loc[3], const floa ED_object_base_init_transform(C, BASACT, loc, rot); DAG_id_type_tag(bmain, ID_OB); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); if (ob->data) { ED_render_id_flush_update(bmain, ob->data); } @@ -469,7 +469,7 @@ static int effector_add_exec(bContext *C, wmOperator *op) ob->pd = object_add_collision_fields(type); - DAG_scene_sort(CTX_data_main(C), CTX_data_scene(C)); + DAG_relations_tag_update(CTX_data_main(C)); return OPERATOR_FINISHED; } @@ -835,9 +835,9 @@ static int group_instance_add_exec(bContext *C, wmOperator *op) id_lib_extern(&group->id); /* works without this except if you try render right after, see: 22027 */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); - WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, CTX_data_scene(C)); + WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); return OPERATOR_FINISHED; } @@ -993,13 +993,12 @@ static int object_delete_exec(bContext *C, wmOperator *op) if (scene->id.flag & LIB_DOIT) { scene->id.flag &= ~LIB_DOIT; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); } } - DAG_ids_flush_update(bmain, 0); return OPERATOR_FINISHED; } @@ -1260,8 +1259,7 @@ static int object_duplicates_make_real_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE, scene); WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); @@ -1325,7 +1323,7 @@ static Base *duplibase_for_convert(Scene *scene, Base *base, Object *ob) } obn = BKE_object_copy(ob); - obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); basen = MEM_mallocN(sizeof(Base), "duplibase"); *basen = *base; @@ -1427,7 +1425,7 @@ static int convert_exec(bContext *C, wmOperator *op) } else { newob = ob; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } /* make new mesh data from the original copy */ @@ -1492,7 +1490,7 @@ static int convert_exec(bContext *C, wmOperator *op) for (ob1 = bmain->object.first; ob1; ob1 = ob1->id.next) { if (ob1->data == ob->data) { ob1->type = OB_CURVE; - ob1->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob1->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } } } @@ -1623,7 +1621,7 @@ static int convert_exec(bContext *C, wmOperator *op) } /* delete object should renew depsgraph */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); } // XXX ED_object_enter_editmode(C, 0); @@ -1639,7 +1637,7 @@ static int convert_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT | ND_DATA, BASACT->object); } - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -1691,7 +1689,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } else { obn = BKE_object_copy(ob); - obn->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&obn->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); basen = MEM_mallocN(sizeof(Base), "duplibase"); *basen = *base; @@ -1816,7 +1814,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base } break; case OB_ARMATURE: - obn->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&obn->id, OB_RECALC_DATA); if (obn->pose) obn->pose->flag |= POSE_RECALC; if (dupflag & USER_DUP_ARM) { @@ -1906,7 +1904,7 @@ static Base *object_add_duplicate_internal(Main *bmain, Scene *scene, Base *base /* single object duplicate, if dupflag==0, fully linked, else it uses the flags given */ /* leaves selection of base/object unaltered. * note: don't call this within a loop since clear_* funcs loop over the entire database. - * note: caller must do DAG_scene_sort(bmain, scene); + * note: caller must do DAG_relations_tag_update(bmain); * this is not done automatic since we may duplicate many objects in a batch */ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag) { @@ -1927,7 +1925,7 @@ Base *ED_object_add_duplicate(Main *bmain, Scene *scene, Base *base, int dupflag BKE_object_relink(ob); set_sca_new_poins_ob(ob); - /* DAG_scene_sort(bmain, scene); */ /* caller must do */ + /* DAG_relations_tag_update(bmain); */ /* caller must do */ if (ob->data) { ED_render_id_flush_update(bmain, ob->data); @@ -1971,8 +1969,7 @@ static int duplicate_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C, dupflag); - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); @@ -2047,8 +2044,7 @@ static int add_named_exec(bContext *C, wmOperator *op) copy_object_set_idnew(C, dupflag); - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); MEM_freeN(base); diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 7746329c17f..72a9e328a02 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -1151,7 +1151,7 @@ void ED_object_constraint_dependency_update(Main *bmain, Scene *scene, Object *o ED_object_constraint_update(ob); if (ob->pose) ob->pose->flag |= POSE_RECALC; // checks & sorts pose channels - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); } static int constraint_poll(bContext *C) @@ -1310,7 +1310,6 @@ void CONSTRAINT_OT_move_up(wmOperatorType *ot) static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); Object *ob = BKE_object_pose_armature_get(CTX_data_active_object(C)); /* free constraints for all selected bones */ @@ -1322,7 +1321,7 @@ static int pose_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_relations_tag_update(bmain); /* note, calling BIK_clear_data() isn't needed here */ @@ -1349,7 +1348,6 @@ void POSE_OT_constraints_clear(wmOperatorType *ot) static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); /* do freeing */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -1360,7 +1358,7 @@ static int object_constraints_clear_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; /* force depsgraph to get recalculated since relationships removed */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_relations_tag_update(bmain); /* do updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); @@ -1385,7 +1383,6 @@ void OBJECT_OT_constraints_clear(wmOperatorType *ot) static int pose_constraint_copy_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); bPoseChannel *pchan = CTX_data_active_pose_bone(C); /* don't do anything if bone doesn't exist or doesn't have any constraints */ @@ -1407,7 +1404,7 @@ static int pose_constraint_copy_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects/bones */ + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT, NULL); @@ -1432,7 +1429,6 @@ void POSE_OT_constraints_copy(wmOperatorType *ot) static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); Object *obact = ED_object_active_context(C); /* copy all constraints from active object to all selected objects */ @@ -1447,7 +1443,7 @@ static int object_constraint_copy_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_relations_tag_update(bmain); /* notifiers for updates */ WM_event_add_notifier(C, NC_OBJECT | ND_CONSTRAINT | NA_ADDED, NULL); @@ -1615,7 +1611,6 @@ static short get_new_constraint_target(bContext *C, int con_type, Object **tar_o static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase *list, int type, short setTarget) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); bPoseChannel *pchan; bConstraint *con; @@ -1709,7 +1704,7 @@ static int constraint_add_exec(bContext *C, wmOperator *op, Object *ob, ListBase /* force depsgraph to get recalculated since new relationships added */ - DAG_scene_sort(bmain, scene); /* sort order of objects */ + DAG_relations_tag_update(bmain); if ((ob->type == OB_ARMATURE) && (pchan)) { ob->pose->flag |= POSE_RECALC; /* sort pose channels */ diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index a13c0509824..b94c9e940dc 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -150,7 +150,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *UNUSED(op)) } if (changed) { DAG_id_type_tag(bmain, ID_OB); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } @@ -207,7 +207,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op) if (changed) { DAG_id_type_tag(bmain, ID_OB); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, CTX_data_scene(C)); @@ -771,7 +771,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) Base *base; Curve *cu, *cu1; Nurb *nu; - int do_scene_sort = FALSE; + bool do_depgraph_update = false; if (scene->id.lib) return; @@ -798,7 +798,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) for (base = FIRSTBASE; base; base = base->next) { if (base != BASACT) { if (TESTBASELIB(v3d, base)) { - base->object->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); if (event == 1) { /* loc */ copy_v3_v3(base->object->loc, ob->loc); @@ -897,7 +897,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) BLI_strncpy(cu1->family, cu->family, sizeof(cu1->family)); - base->object->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } else if (event == 19) { /* bevel settings */ @@ -913,7 +913,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) cu1->ext1 = cu->ext1; cu1->ext2 = cu->ext2; - base->object->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } else if (event == 25) { /* curve resolution */ @@ -932,7 +932,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) nu = nu->next; } - base->object->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } else if (event == 21) { @@ -948,7 +948,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } modifier_copyData(md, tmd); - base->object->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&base->object->id, OB_RECALC_DATA); } } } @@ -956,7 +956,7 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) /* Copy the constraint channels over */ BKE_copy_constraints(&base->object->constraints, &ob->constraints, TRUE); - do_scene_sort = TRUE; + do_depgraph_update = true; } else if (event == 23) { base->object->softflag = ob->softflag; @@ -1008,10 +1008,8 @@ static void copy_attr(Main *bmain, Scene *scene, View3D *v3d, short event) } } - if (do_scene_sort) - DAG_scene_sort(bmain, scene); - - DAG_ids_flush_update(bmain, 0); + if (do_depgraph_update) + DAG_relations_tag_update(bmain); } static void UNUSED_FUNCTION(copy_attr_menu) (Main * bmain, Scene * scene, View3D * v3d) diff --git a/source/blender/editors/object/object_group.c b/source/blender/editors/object/object_group.c index 9b683a1ba98..3112bb21091 100644 --- a/source/blender/editors/object/object_group.c +++ b/source/blender/editors/object/object_group.c @@ -137,7 +137,7 @@ static int objects_add_active_exec(bContext *C, wmOperator *op) BKE_report(op->reports, RPT_WARNING, "Skipped some groups because of cycle detected"); } - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -197,7 +197,7 @@ static int objects_remove_active_exec(bContext *C, wmOperator *op) if (!ok) BKE_report(op->reports, RPT_ERROR, "Active object contains no groups"); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -229,7 +229,7 @@ static int group_objects_remove_all_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -269,7 +269,7 @@ static int group_objects_remove_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -319,7 +319,7 @@ static int group_create_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_GROUP | NA_EDITED, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index b1612a2b9d3..43736909c40 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -516,7 +516,7 @@ static int add_hook_object(Main *bmain, Scene *scene, Object *obedit, Object *ob mul_serie_m4(hmd->parentinv, ob->imat, obedit->obmat, NULL, NULL, NULL, NULL, NULL, NULL); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); return TRUE; } diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 00082b03781..b5faa5bdc4e 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -151,10 +151,10 @@ ModifierData *ED_object_modifier_add(ReportList *reports, Main *bmain, Scene *sc ob->pd = object_add_collision_fields(0); ob->pd->deflect = 1; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); } else if (type == eModifierType_Surface) - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); else if (type == eModifierType_Multires) { /* set totlvl from existing MDISPS layer if object already had it */ multiresModifier_set_levels_from_disps((MultiresModifierData *)new_md, ob); @@ -343,10 +343,7 @@ int ED_object_modifier_remove(ReportList *reports, Main *bmain, Scene *scene, Ob } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - - /* sorting has to be done after the update so that dynamic systems can react properly */ - if (sort_depsgraph) - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); return 1; } @@ -370,10 +367,7 @@ void ED_object_modifier_clear(Main *bmain, Scene *scene, Object *ob) } DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - - /* sorting has to be done after the update so that dynamic systems can react properly */ - if (sort_depsgraph) - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); } int ED_object_modifier_move_up(ReportList *reports, Object *ob, ModifierData *md) @@ -522,7 +516,7 @@ int ED_object_modifier_convert(ReportList *UNUSED(reports), Main *bmain, Scene * } } - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); return 1; } @@ -1831,7 +1825,7 @@ static int skin_armature_create_exec(bContext *C, wmOperator *op) arm_md->object = arm_ob; arm_md->deformflag = ARM_DEF_VGROUP | ARM_DEF_QUATERNION; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index 629dba465bc..c5e8310e9fb 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -223,7 +223,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { if (ob != obedit) { - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); par = obedit->parent; while (par) { @@ -260,7 +260,7 @@ static int vertex_parent_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT, NULL); @@ -364,7 +364,7 @@ static int make_proxy_exec(bContext *C, wmOperator *op) BKE_object_make_proxy(newob, ob, gob); /* depsgraph flushes are needed for the new data */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&newob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, newob); } @@ -512,14 +512,13 @@ void ED_object_parent_clear(Object *ob, int type) break; } - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); } /* note, poll should check for editable scene */ static int parent_clear_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); int type = RNA_enum_get(op->ptr, "type"); CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -528,8 +527,7 @@ static int parent_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; @@ -597,7 +595,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object bPoseChannel *pchan = NULL; int pararm = ELEM4(partype, PAR_ARMATURE, PAR_ARMATURE_NAME, PAR_ARMATURE_ENVELOPE, PAR_ARMATURE_AUTO); - par->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&par->id, OB_RECALC_OB); /* preconditions */ if (partype == PAR_FOLLOW || partype == PAR_PATH_CONST) { @@ -762,7 +760,7 @@ int ED_object_parent_set(ReportList *reports, Main *bmain, Scene *scene, Object invert_m4_m4(ob->parentinv, workob.obmat); } - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); } } @@ -791,8 +789,7 @@ static int parent_set_exec(bContext *C, wmOperator *op) if (!ok) return OPERATOR_CANCELLED; - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); @@ -903,7 +900,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); Object *par = ED_object_active_context(C); - par->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&par->id, OB_RECALC_OB); /* context iterator */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -918,7 +915,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) memset(ob->loc, 0, 3 * sizeof(float)); /* set recalc flags */ - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA); /* set parenting type for object - object only... */ ob->parent = par; @@ -928,8 +925,7 @@ static int parent_noinv_set_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_scene_sort(bmain, CTX_data_scene(C)); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -955,7 +951,6 @@ void OBJECT_OT_parent_no_inverse_set(wmOperatorType *ot) static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -965,13 +960,12 @@ static int object_slow_parent_clear_exec(bContext *C, wmOperator *UNUSED(op)) ob->partype -= PARSLOW; BKE_object_where_is_calc(scene, ob); ob->partype |= PARSLOW; - ob->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } } CTX_DATA_END; - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -998,7 +992,6 @@ void OBJECT_OT_slow_parent_clear(wmOperatorType *ot) static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) @@ -1006,12 +999,11 @@ static int object_slow_parent_set_exec(bContext *C, wmOperator *UNUSED(op)) if (ob->parent) ob->partype |= PARSLOW; - ob->recalc |= OB_RECALC_OB; + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } CTX_DATA_END; - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SCENE, scene); return OPERATOR_FINISHED; @@ -1046,7 +1038,6 @@ static EnumPropertyItem prop_clear_track_types[] = { static int object_track_clear_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); int type = RNA_enum_get(op->ptr, "type"); if (CTX_data_edit_object(C)) { @@ -1059,7 +1050,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) /* remove track-object for old track */ ob->track = NULL; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* also remove all tracking constraints */ for (con = ob->constraints.last; con; con = pcon) { @@ -1073,8 +1064,7 @@ static int object_track_clear_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(bmain, 0); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -1111,7 +1101,6 @@ static EnumPropertyItem prop_make_track_types[] = { static int track_set_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); Object *obact = ED_object_active_context(C); int type = RNA_enum_get(op->ptr, "type"); @@ -1127,7 +1116,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) @@ -1147,7 +1136,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) { @@ -1169,7 +1158,7 @@ static int track_set_exec(bContext *C, wmOperator *op) data = con->data; data->tar = obact; - ob->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); /* Lamp, Camera and Speaker track differently by default */ if (ob->type == OB_LAMP || ob->type == OB_CAMERA || ob->type == OB_SPEAKER) { @@ -1181,8 +1170,7 @@ static int track_set_exec(bContext *C, wmOperator *op) CTX_DATA_END; } - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -1297,7 +1285,7 @@ static int move_to_layer_exec(bContext *C, wmOperator *op) WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, scene); WM_event_add_notifier(C, NC_SCENE | ND_LAYER_CONTENT, scene); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); return OPERATOR_FINISHED; } @@ -1360,7 +1348,6 @@ Base *ED_object_scene_link(Scene *scene, Object *ob) static int make_links_scene_exec(bContext *C, wmOperator *op) { - Main *bmain = CTX_data_main(C); Scene *scene_to = BLI_findlink(&CTX_data_main(C)->scene, RNA_enum_get(op->ptr, "scene")); if (scene_to == NULL) { @@ -1384,8 +1371,6 @@ static int make_links_scene_exec(bContext *C, wmOperator *op) } CTX_DATA_END; - DAG_ids_flush_update(bmain, 0); - /* redraw the 3D view because the object center points are colored differently */ WM_event_add_notifier(C, NC_OBJECT | ND_DRAW, NULL); @@ -1476,7 +1461,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) /* if amount of material indices changed: */ test_object_materials(ob_dst->data); - ob_dst->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&ob_dst->id, OB_RECALC_DATA); break; case MAKE_LINKS_MATERIALS: /* new approach, using functions from kernel */ @@ -1515,7 +1500,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) break; case MAKE_LINKS_MODIFIERS: BKE_object_link_modifiers(ob_dst, ob_src); - ob_dst->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; case MAKE_LINKS_FONTS: { @@ -1535,7 +1520,7 @@ static int make_links_data_exec(bContext *C, wmOperator *op) cu_dst->vfontbi = cu_src->vfontbi; id_us_plus((ID *)cu_dst->vfontbi); - ob_dst->recalc |= OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME; + DAG_id_tag_update(&ob_dst->id, OB_RECALC_OB | OB_RECALC_DATA | OB_RECALC_TIME); break; } } @@ -1554,10 +1539,9 @@ static int make_links_data_exec(bContext *C, wmOperator *op) } } - DAG_scene_sort(bmain, scene); - - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); + return OPERATOR_FINISHED; } @@ -1706,7 +1690,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) id = ob->data; if (id && id->us > 1 && id->lib == NULL) { - ob->recalc = OB_RECALC_DATA; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); BKE_copy_animdata_id_action(id); @@ -1742,7 +1726,7 @@ static void single_obdata_users(Main *bmain, Scene *scene, int flag) ob->data = BKE_lattice_copy(ob->data); break; case OB_ARMATURE: - ob->recalc |= OB_RECALC_DATA; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); ob->data = BKE_armature_copy(ob->data); BKE_pose_rebuild(ob, ob->data); break; @@ -1778,7 +1762,7 @@ static void single_object_action_users(Scene *scene, int flag) for (base = FIRSTBASE; base; base = base->next) { ob = base->object; if (ob->id.lib == NULL && (flag == 0 || (base->flag & SELECT)) ) { - ob->recalc = OB_RECALC_DATA; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); BKE_copy_animdata_id_action(&ob->id); } } @@ -2148,7 +2132,6 @@ void OBJECT_OT_make_single_user(wmOperatorType *ot) static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Main *bmain = CTX_data_main(C); Base *base = ED_view3d_give_base_under_cursor(C, event->mval); Material *ma; char name[MAX_ID_NAME - 2]; @@ -2160,7 +2143,6 @@ static int drop_named_material_invoke(bContext *C, wmOperator *op, wmEvent *even assign_material(base->object, ma, 1, BKE_MAT_ASSIGN_USERPREF); - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); diff --git a/source/blender/editors/object/object_transform.c b/source/blender/editors/object/object_transform.c index 13523154d62..01dcac2d1b4 100644 --- a/source/blender/editors/object/object_transform.c +++ b/source/blender/editors/object/object_transform.c @@ -213,7 +213,6 @@ static void object_clear_scale(Object *ob) static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, void (*clear_func)(Object *), const char default_ksName[]) { - Main *bmain = CTX_data_main(C); Scene *scene = CTX_data_scene(C); KeyingSet *ks; @@ -244,8 +243,6 @@ static int object_clear_transform_generic_exec(bContext *C, wmOperator *op, CTX_DATA_END; /* this is needed so children are also updated */ - DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -318,7 +315,6 @@ void OBJECT_OT_scale_clear(wmOperatorType *ot) static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); float *v1, *v3; float mat[3][3]; @@ -338,8 +334,6 @@ static int object_origin_clear_exec(bContext *C, wmOperator *UNUSED(op)) } CTX_DATA_END; - DAG_ids_flush_update(bmain, 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -991,7 +985,6 @@ static int object_origin_set_exec(bContext *C, wmOperator *op) DAG_id_tag_update(&tob->id, OB_RECALC_OB | OB_RECALC_DATA); if (tot_change) { - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); } diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index ecc7ea4ae00..48316cfccb7 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -172,8 +172,8 @@ static int type_toggle_exec(bContext *C, wmOperator *op) /* update dependency */ DAG_id_tag_update(&cObject->id, OB_RECALC_DATA); + DAG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, cObject); - DAG_scene_sort(CTX_data_main(C), scene); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/physics/particle_boids.c b/source/blender/editors/physics/particle_boids.c index dc309ec3c31..154daf0eb72 100644 --- a/source/blender/editors/physics/particle_boids.c +++ b/source/blender/editors/physics/particle_boids.c @@ -100,7 +100,6 @@ void BOID_OT_rule_add(wmOperatorType *ot) static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings); ParticleSettings *part = ptr.data; BoidRule *rule; @@ -123,7 +122,7 @@ static int rule_del_exec(bContext *C, wmOperator *UNUSED(op)) if (rule) rule->flag |= BOIDRULE_CURRENT; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); return OPERATOR_FINISHED; @@ -254,7 +253,6 @@ void BOID_OT_state_add(wmOperatorType *ot) static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_settings", &RNA_ParticleSettings); ParticleSettings *part = ptr.data; BoidState *state; @@ -280,7 +278,7 @@ static int state_del_exec(bContext *C, wmOperator *UNUSED(op)) state->flag |= BOIDSTATE_CURRENT; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&part->id, OB_RECALC_DATA|PSYS_RECALC_RESET); return OPERATOR_FINISHED; diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 23069ab8a08..8cae0140b5a 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -151,7 +151,6 @@ static int psys_poll(bContext *C) static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) { - Scene *scene = CTX_data_scene(C); Main *bmain= CTX_data_main(C); ParticleSystem *psys; ParticleSettings *part = NULL; @@ -177,7 +176,7 @@ static int new_particle_settings_exec(bContext *C, wmOperator *UNUSED(op)) psys_check_boid_data(psys); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -205,7 +204,6 @@ void PARTICLE_OT_new(wmOperatorType *ot) static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob = ptr.id.data; @@ -226,7 +224,7 @@ static int new_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) BLI_addtail(&psys->targets, pt); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); @@ -251,7 +249,6 @@ void PARTICLE_OT_new_target(wmOperatorType *ot) static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) { Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); PointerRNA ptr = CTX_data_pointer_get_type(C, "particle_system", &RNA_ParticleSystem); ParticleSystem *psys= ptr.data; Object *ob = ptr.id.data; @@ -275,7 +272,7 @@ static int remove_particle_target_exec(bContext *C, wmOperator *UNUSED(op)) if (pt) pt->flag |= PTARGET_CURRENT; - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); DAG_id_tag_update(&ob->id, OB_RECALC_DATA); WM_event_add_notifier(C, NC_OBJECT|ND_PARTICLE, ob); diff --git a/source/blender/editors/physics/rigidbody_constraint.c b/source/blender/editors/physics/rigidbody_constraint.c index a72a409f277..b3f92d3de46 100644 --- a/source/blender/editors/physics/rigidbody_constraint.c +++ b/source/blender/editors/physics/rigidbody_constraint.c @@ -96,6 +96,8 @@ void ED_rigidbody_con_add(wmOperator *op, Scene *scene, Object *ob, int type) /* add constraint to rigid body constraint group */ add_to_group(rbw->constraints, ob, scene, NULL); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } void ED_rigidbody_con_remove(Scene *scene, Object *ob) @@ -130,8 +132,6 @@ static int rigidbody_con_add_exec(bContext *C, wmOperator *op) ED_rigidbody_con_add(op, scene, ob, type); /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); /* done */ @@ -177,8 +177,6 @@ static int rigidbody_con_remove_exec(bContext *C, wmOperator *op) } /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); /* done */ diff --git a/source/blender/editors/physics/rigidbody_object.c b/source/blender/editors/physics/rigidbody_object.c index 2bf962f4f4a..6bcdf6e07aa 100644 --- a/source/blender/editors/physics/rigidbody_object.c +++ b/source/blender/editors/physics/rigidbody_object.c @@ -151,8 +151,6 @@ static int rigidbody_ob_add_exec(bContext *C, wmOperator *op) ED_rigidbody_ob_add(op, scene, ob, type); /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); /* done */ @@ -197,8 +195,6 @@ static int rigidbody_ob_remove_exec(bContext *C, wmOperator *op) ED_rigidbody_ob_remove(scene, ob); /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); /* done */ @@ -242,8 +238,6 @@ static int rigidbody_obs_add_exec(bContext *C, wmOperator *op) CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); @@ -289,8 +283,6 @@ static int rigidbody_obs_remove_exec(bContext *C, wmOperator *UNUSED(op)) CTX_DATA_END; /* send updates */ - DAG_ids_flush_update(CTX_data_main(C), 0); - WM_event_add_notifier(C, NC_OBJECT | ND_POINTCACHE, NULL); /* done */ diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 483348db18e..ab16a9d55e6 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -383,10 +383,7 @@ static void do_graph_region_driver_buttons(bContext *C, void *UNUSED(arg), int e case B_IPO_DEPCHANGE: { /* rebuild depsgraph for the new deps */ - DAG_scene_sort(bmain, scene); - - /* force an update of depsgraph */ - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); } break; } diff --git a/source/blender/editors/space_outliner/outliner_edit.c b/source/blender/editors/space_outliner/outliner_edit.c index ab660b9cd4a..9a1b3628196 100644 --- a/source/blender/editors/space_outliner/outliner_edit.c +++ b/source/blender/editors/space_outliner/outliner_edit.c @@ -1432,8 +1432,7 @@ static int parent_drop_exec(bContext *C, wmOperator *op) ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE, FALSE); - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); @@ -1522,8 +1521,7 @@ static int parent_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) if ((par->type != OB_ARMATURE) && (par->type != OB_CURVE) && (par->type != OB_LATTICE)) { if (ED_object_parent_set(op->reports, bmain, scene, ob, par, partype, FALSE, FALSE)) { - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); } @@ -1706,8 +1704,7 @@ static int parent_clear_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(even ED_object_parent_clear(ob, RNA_enum_get(op->ptr, "type")); - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); WM_event_add_notifier(C, NC_OBJECT | ND_PARENT, NULL); return OPERATOR_FINISHED; @@ -1795,8 +1792,7 @@ static int scene_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) ED_base_object_select(base, BA_SELECT); } - DAG_scene_sort(bmain, scene); - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(bmain); WM_main_add_notifier(NC_SCENE | ND_OB_SELECT, scene); @@ -1828,7 +1824,6 @@ void OUTLINER_OT_scene_drop(wmOperatorType *ot) static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) { - Main *bmain = CTX_data_main(C); Material *ma = NULL; Object *ob = NULL; SpaceOops *soops = CTX_wm_space_outliner(C); @@ -1860,7 +1855,6 @@ static int material_drop_invoke(bContext *C, wmOperator *op, wmEvent *event) assign_material(ob, ma, ob->totcol + 1, BKE_MAT_ASSIGN_USERPREF); - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C)); WM_event_add_notifier(C, NC_MATERIAL | ND_SHADING_LINKS, ma); diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index b2070cc2f1c..303782f3fbd 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -619,7 +619,7 @@ static int outliner_object_operation_exec(bContext *C, wmOperator *op) * cleanup tree here to prevent such cases. */ outliner_cleanup_tree(soops); - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(bmain); str = "Delete Objects"; WM_event_add_notifier(C, NC_SCENE | ND_OB_ACTIVE, scene); } @@ -712,10 +712,8 @@ static int outliner_group_operation_exec(bContext *C, wmOperator *op) if (event == 3) { /* instance */ - Main *bmain = CTX_data_main(C); - /* works without this except if you try render right after, see: 22027 */ - DAG_scene_sort(bmain, scene); + DAG_relations_tag_update(CTX_data_main(C)); } ED_undo_push(C, prop_group_op_types[event].name); @@ -1110,14 +1108,8 @@ static int outliner_animdata_operation_exec(bContext *C, wmOperator *op) /* update dependencies */ if (updateDeps) { - Main *bmain = CTX_data_main(C); - Scene *scene = CTX_data_scene(C); - /* rebuild depsgraph for the new deps */ - DAG_scene_sort(bmain, scene); - - /* force an update of depsgraph */ - DAG_ids_flush_update(bmain, 0); + DAG_relations_tag_update(CTX_data_main(C)); } return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_snap.c b/source/blender/editors/space_view3d/view3d_snap.c index f570ec38ae3..6edcf980d58 100644 --- a/source/blender/editors/space_view3d/view3d_snap.c +++ b/source/blender/editors/space_view3d/view3d_snap.c @@ -532,7 +532,6 @@ static void make_trans_verts(Object *obedit, float min[3], float max[3], int mod static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); RegionView3D *rv3d = CTX_wm_region_data(C); @@ -623,8 +622,6 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - ob->recalc |= OB_RECALC_OB; - vec[0] = -ob->obmat[3][0] + gridf * floorf(0.5f + ob->obmat[3][0] / gridf); vec[1] = -ob->obmat[3][1] + gridf * floorf(0.5f + ob->obmat[3][1] / gridf); vec[2] = -ob->obmat[3][2] + gridf * floorf(0.5f + ob->obmat[3][2] / gridf); @@ -644,12 +641,13 @@ static int snap_sel_to_grid(bContext *C, wmOperator *UNUSED(op)) /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; } - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; @@ -674,7 +672,6 @@ void VIEW3D_OT_snap_selected_to_grid(wmOperatorType *ot) static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) { - Main *bmain = CTX_data_main(C); Object *obedit = CTX_data_edit_object(C); Scene *scene = CTX_data_scene(C); View3D *v3d = CTX_wm_view3d(C); @@ -748,8 +745,6 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } else { - ob->recalc |= OB_RECALC_OB; - vec[0] = -ob->obmat[3][0] + curs[0]; vec[1] = -ob->obmat[3][1] + curs[1]; vec[2] = -ob->obmat[3][2] + curs[2]; @@ -769,12 +764,13 @@ static int snap_sel_to_curs(bContext *C, wmOperator *UNUSED(op)) /* auto-keyframing */ ED_autokeyframe_object(C, scene, ob, ks); + + DAG_id_tag_update(&ob->id, OB_RECALC_OB); } } CTX_DATA_END; } - DAG_ids_flush_update(bmain, 0); WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL); return OPERATOR_FINISHED; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 32ceaf97331..5be06188e4e 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -4743,6 +4743,7 @@ static void set_trans_object_base_flags(TransInfo *t) } /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ + DAG_scene_relations_update(G.main, t->scene); DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ @@ -4820,6 +4821,7 @@ static int count_proportional_objects(TransInfo *t) /* all recalc flags get flushed to all layers, so a layer flip later on works fine */ + DAG_scene_relations_update(G.main, t->scene); DAG_scene_flush_update(G.main, t->scene, -1, 0); /* and we store them temporal in base (only used for transform code) */ -- cgit v1.2.3