diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-21 23:33:04 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-02-21 23:33:04 +0400 |
commit | 20220d47e38c4ad22ad89481fd40b804cc2fd1ef (patch) | |
tree | 5e01f917fa80465bb6401d63f8057641813983d9 /source/blender/blenkernel/intern/scene.c | |
parent | 074565330db93ceb2304247f9bf6499b05cb3b80 (diff) |
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.
Diffstat (limited to 'source/blender/blenkernel/intern/scene.c')
-rw-r--r-- | source/blender/blenkernel/intern/scene.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/scene.c b/source/blender/blenkernel/intern/scene.c index 279c321d371..9a1a146c271 100644 --- a/source/blender/blenkernel/intern/scene.c +++ b/source/blender/blenkernel/intern/scene.c @@ -649,12 +649,11 @@ void BKE_scene_set_background(Main *bmain, Scene *scene) } /* sort baselist */ - DAG_scene_sort(bmain, scene); + DAG_scene_relations_rebuild(bmain, scene); /* ensure dags are built for sets */ - for (sce = scene->set; sce; sce = sce->set) - if (sce->theDag == NULL) - DAG_scene_sort(bmain, sce); + for (sce = scene; sce; sce = sce->set) + DAG_scene_relations_update(bmain, sce); /* copy layers and flags from bases to objects */ for (base = scene->base.first; base; base = base->next) { @@ -1150,9 +1149,15 @@ static void scene_update_tagged_recursive(Main *bmain, Scene *scene, Scene *scen /* this is called in main loop, doing tagged updates before redraw */ void BKE_scene_update_tagged(Main *bmain, Scene *scene) { + Scene *sce_iter; + /* keep this first */ BLI_callback_exec(bmain, &scene->id, BLI_CB_EVT_SCENE_UPDATE_PRE); + /* (re-)build dependency graph if needed */ + for (sce_iter = scene; sce_iter; sce_iter = sce_iter->set) + DAG_scene_relations_update(bmain, sce_iter); + /* flush recalc flags to dependencies */ DAG_ids_flush_tagged(bmain); @@ -1203,10 +1208,8 @@ void BKE_scene_update_for_newframe(Main *bmain, Scene *sce, unsigned int lay) /* clear animation overrides */ /* XXX TODO... */ - for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) { - if (sce_iter->theDag == NULL) - DAG_scene_sort(bmain, sce_iter); - } + for (sce_iter = sce; sce_iter; sce_iter = sce_iter->set) + DAG_scene_relations_update(bmain, sce_iter); /* flush recalc flags to dependencies, if we were only changing a frame * this would not be necessary, but if a user or a script has modified |