diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-20 18:38:32 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-09-25 15:40:06 +0300 |
commit | 615d5fa2fbd24ed6f76a93d7b523066f53da950e (patch) | |
tree | 71599e65499a0afd1216012c4b47979c43ebcf31 /source/blender/editors/object/object_edit.c | |
parent | eb2ed0ea7a2c4090b8e2f239a40da03d6ee29900 (diff) |
Motion paths: Use minimal possible dependency graph
This change makes it so motion paths are using minimal possible
dependency graph which is sufficient to evaluate required motion
path targets.
Disclaimer: granularity is done on ID level, but it is possible
to go more granular if really needed.
Brings time down to 0.5 sec when updating motion path for the
Rain animation file used for benchmarks in the previous commits.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5874
Diffstat (limited to 'source/blender/editors/object/object_edit.c')
-rw-r--r-- | source/blender/editors/object/object_edit.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c index 77897c909d9..4759a3cb0db 100644 --- a/source/blender/editors/object/object_edit.c +++ b/source/blender/editors/object/object_edit.c @@ -936,11 +936,9 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRang } Main *bmain = CTX_data_main(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}; + ViewLayer *view_layer = CTX_data_view_layer(C); + ListBase targets = {NULL, NULL}; /* loop over objects in scene */ CTX_DATA_BEGIN (C, Object *, ob, selected_editable_objects) { /* set flag to force recalc, then grab path(s) from object */ @@ -949,6 +947,21 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRang } CTX_DATA_END; + Depsgraph *depsgraph; + bool free_depsgraph = false; + /* For a single frame update it's faster to re-use existing dependency graph and avoid overhead + * of building all the relations and so on for a temporary one. */ + if (range == OBJECT_PATH_CALC_RANGE_CURRENT_FRAME) { + /* NOTE: Dependency graph will be evaluated at all the frames, but we first need to access some + * nested pointers, like animation data. */ + depsgraph = CTX_data_ensure_evaluated_depsgraph(C); + free_depsgraph = false; + } + else { + depsgraph = animviz_depsgraph_build(bmain, scene, view_layer, &targets); + free_depsgraph = true; + } + /* recalculate paths, then free */ animviz_calc_motionpaths( depsgraph, bmain, scene, &targets, object_path_convert_range(range), true); @@ -964,6 +977,11 @@ void ED_objects_recalculate_paths(bContext *C, Scene *scene, eObjectPathCalcRang } CTX_DATA_END; } + + /* Free temporary depsgraph. */ + if (free_depsgraph) { + DEG_graph_free(depsgraph); + } } /* show popup to determine settings */ |