Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-09-20 18:38:32 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-09-25 15:40:06 +0300
commit615d5fa2fbd24ed6f76a93d7b523066f53da950e (patch)
tree71599e65499a0afd1216012c4b47979c43ebcf31 /source/blender/editors/animation
parenteb2ed0ea7a2c4090b8e2f239a40da03d6ee29900 (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/animation')
-rw-r--r--source/blender/editors/animation/anim_motion_paths.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/source/blender/editors/animation/anim_motion_paths.c b/source/blender/editors/animation/anim_motion_paths.c
index aff532f4d54..30bf837f6c0 100644
--- a/source/blender/editors/animation/anim_motion_paths.c
+++ b/source/blender/editors/animation/anim_motion_paths.c
@@ -36,6 +36,7 @@
#include "BKE_scene.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "GPU_batch.h"
@@ -67,6 +68,37 @@ typedef struct MPathTarget {
/* ........ */
+/* update scene for current frame */
+static void motionpaths_calc_update_scene(Main *bmain, struct Depsgraph *depsgraph)
+{
+ BKE_scene_graph_update_for_newframe(depsgraph, bmain);
+}
+
+Depsgraph *animviz_depsgraph_build(Main *bmain,
+ Scene *scene,
+ ViewLayer *view_layer,
+ ListBase *targets)
+{
+ /* Allocate dependency graph. */
+ Depsgraph *depsgraph = DEG_graph_new(bmain, scene, view_layer, DAG_EVAL_VIEWPORT);
+
+ /* Make a flat array of IDs for the DEG API. */
+ const int num_ids = BLI_listbase_count(targets);
+ ID **ids = MEM_malloc_arrayN(sizeof(ID *), num_ids, "animviz IDS");
+ int current_id_index = 0;
+ for (MPathTarget *mpt = targets->first; mpt != NULL; mpt = mpt->next) {
+ ids[current_id_index++] = &mpt->ob->id;
+ }
+
+ /* Build graph from all requested IDs. */
+ DEG_graph_build_from_ids(depsgraph, bmain, scene, view_layer, ids, num_ids);
+ MEM_freeN(ids);
+
+ /* Update once so we can access pointers of evaluated animation data. */
+ motionpaths_calc_update_scene(bmain, depsgraph);
+ return depsgraph;
+}
+
/* get list of motion paths to be baked for the given object
* - assumes the given list is ready to be used
*/
@@ -106,24 +138,6 @@ void animviz_get_object_motionpaths(Object *ob, ListBase *targets)
/* ........ */
-/* update scene for current frame */
-static void motionpaths_calc_update_scene(Main *bmain, struct Depsgraph *depsgraph)
-{
- /* Do all updates
- * - if this is too slow, resort to using a more efficient way
- * that doesn't force complete update, but for now, this is the
- * most accurate way!
- *
- * TODO(segey): Bring back partial updates, which became impossible
- * with the new depsgraph due to unsorted nature of bases.
- *
- * TODO(sergey): Use evaluation context dedicated to motion paths.
- */
- BKE_scene_graph_update_for_newframe(depsgraph, bmain);
-}
-
-/* ........ */
-
/* perform baking for the targets on the current frame */
static void motionpaths_calc_bake_targets(ListBase *targets, int cframe)
{