diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-10 16:07:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-04-12 12:05:18 +0300 |
commit | ca2484e09005207e7bad90f484de6cbba1013833 (patch) | |
tree | f0fb0556c6c88e99ec4c47b7622281f534bf33bf /source/blender/blenkernel | |
parent | c1680902ac9a0a6431a2ae5258b0806b60a95a75 (diff) |
Depsgraph: Remove function bindings with collections
Use single function to evaluate all the collections for the given view layer.
This way we avoid need to get scene ID sub-data. Similar to pchan index, this
allows us to avoid build-time scene expansion, which also simplifies update of
the scene datablock.
Well, sort of. There is still work to be done to get rid of build-time scene
datablock expansion, which includes:
- Need to pass view layer by index.
Annoying part would be to get actual view layer for that index. In practice
doing list lookup might not be such a bad idea, since such lookup will not
happen very often, and it is unlikely to have more than handful of view
layer anyway.
Other idea could be to use view layer from evaluation context.
Or maybe from depsgraph, which is supposed to be in the context. Can have
some assert statements to make sure everything is good.
- Need to get id of base binding for flags flush.
We can replace that with index-based lookup from an array created by view
layer evaluation.
Reviewers: dfelinto
Differential Revision: https://developer.blender.org/D3141
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_layer.h | 11 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/group.c | 26 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 40 |
3 files changed, 37 insertions, 40 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 8140dc5b31d..7542e9da2d5 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -169,14 +169,9 @@ void BKE_collection_engine_property_value_set_bool(struct IDProperty *props, con /* evaluation */ -void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext *eval_ctx, - struct ID *owner_id, - struct ViewLayer *view_layer); -void BKE_layer_eval_layer_collection(const struct EvaluationContext *eval_ctx, - struct LayerCollection *layer_collection, - struct LayerCollection *parent_layer_collection); -void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *eval_ctx, - struct ViewLayer *view_layer); +void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx, + struct ID *owner_id, + struct ViewLayer *view_layer); /* iterators */ diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c index 20da1e7b7ac..7566d370c45 100644 --- a/source/blender/blenkernel/intern/group.c +++ b/source/blender/blenkernel/intern/group.c @@ -381,33 +381,9 @@ void BKE_group_handle_recalc_and_update(const struct EvaluationContext *eval_ctx /* ******** Dependency graph evaluation ******** */ -static void group_eval_layer_collections( - const struct EvaluationContext *eval_ctx, - Group *group, - ListBase *layer_collections, - LayerCollection *parent_layer_collection) -{ - LISTBASE_FOREACH (LayerCollection *, layer_collection, layer_collections) { - /* Evaluate layer collection itself. */ - BKE_layer_eval_layer_collection(eval_ctx, - layer_collection, - parent_layer_collection); - /* Evaluate nested collections. */ - group_eval_layer_collections(eval_ctx, - group, - &layer_collection->layer_collections, - layer_collection); - } -} - void BKE_group_eval_view_layers(const struct EvaluationContext *eval_ctx, Group *group) { DEG_debug_print_eval(__func__, group->id.name, group); - BKE_layer_eval_layer_collection_pre(eval_ctx, &group->id, group->view_layer); - group_eval_layer_collections(eval_ctx, - group, - &group->view_layer->layer_collections, - NULL); - BKE_layer_eval_layer_collection_post(eval_ctx, group->view_layer); + BKE_layer_eval_view_layer(eval_ctx, &group->id, group->view_layer); } diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index 65e76e619f2..8e53dea0c24 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -2253,8 +2253,7 @@ static void idproperty_reset(IDProperty **props, IDProperty *props_ref) } } -void BKE_layer_eval_layer_collection_pre(const struct EvaluationContext *UNUSED(eval_ctx), - ID *owner_id, ViewLayer *view_layer) +static void layer_eval_layer_collection_pre(ID *owner_id, ViewLayer *view_layer) { DEG_debug_print_eval(__func__, view_layer->name, view_layer); Scene *scene = (GS(owner_id->name) == ID_SCE) ? (Scene *)owner_id : NULL; @@ -2296,9 +2295,9 @@ static bool layer_collection_visible_get(const EvaluationContext *eval_ctx, Laye } } -void BKE_layer_eval_layer_collection(const EvaluationContext *eval_ctx, - LayerCollection *layer_collection, - LayerCollection *parent_layer_collection) +static void layer_eval_layer_collection(const EvaluationContext *eval_ctx, + LayerCollection *layer_collection, + LayerCollection *parent_layer_collection) { if (G.debug & G_DEBUG_DEPSGRAPH_EVAL) { /* TODO)sergey): Try to make it more generic and handled by depsgraph messaging. */ @@ -2356,8 +2355,7 @@ void BKE_layer_eval_layer_collection(const EvaluationContext *eval_ctx, } } -void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *UNUSED(eval_ctx), - ViewLayer *view_layer) +static void layer_eval_layer_collection_post(ViewLayer *view_layer) { DEG_debug_print_eval(__func__, view_layer->name, view_layer); /* if base is not selectabled, clear select */ @@ -2368,6 +2366,34 @@ void BKE_layer_eval_layer_collection_post(const struct EvaluationContext *UNUSED } } +static void layer_eval_collections_recurse(const EvaluationContext *eval_ctx, + ListBase *layer_collections, + LayerCollection *parent_layer_collection) +{ + for (LayerCollection *layer_collection = layer_collections->first; + layer_collection != NULL; + layer_collection = layer_collection->next) + { + layer_eval_layer_collection(eval_ctx, + layer_collection, + parent_layer_collection); + layer_eval_collections_recurse(eval_ctx, + &layer_collection->layer_collections, + layer_collection); + } +} + +void BKE_layer_eval_view_layer(const struct EvaluationContext *eval_ctx, + struct ID *owner_id, + struct ViewLayer *view_layer) +{ + layer_eval_layer_collection_pre(owner_id, view_layer); + layer_eval_collections_recurse(eval_ctx, + &view_layer->layer_collections, + NULL); + layer_eval_layer_collection_post(view_layer); +} + /** * Free any static allocated memory. */ |