diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-07-04 16:13:26 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-07-05 17:06:12 +0300 |
commit | 97aa43c36433202ca017a90f72cd0fe579b5f4d0 (patch) | |
tree | 4168e0302f1be881b7d281ea78e4ea64b177b6e1 | |
parent | 9e155eb1f0083354ab5d66f233b1067d16088d62 (diff) |
Depsgraph: Make component traversal more granular
Now it is possible to start traversal from a given component.
4 files changed, 20 insertions, 3 deletions
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h index ee2d4b7be54..18e06410adf 100644 --- a/source/blender/depsgraph/DEG_depsgraph_build.h +++ b/source/blender/depsgraph/DEG_depsgraph_build.h @@ -110,6 +110,9 @@ typedef enum eDepsSceneComponentType { } eDepsSceneComponentType; typedef enum eDepsObjectComponentType { + /* Used in query API, to denote which component caller is interested in. */ + DEG_OB_COMP_ANY, + /* Parameters Component - Default when nothing else fits * (i.e. just SDNA property setting). */ DEG_OB_COMP_PARAMETERS, diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h index 35176284abb..27891acb666 100644 --- a/source/blender/depsgraph/DEG_depsgraph_query.h +++ b/source/blender/depsgraph/DEG_depsgraph_query.h @@ -235,8 +235,11 @@ void DEG_foreach_dependent_ID(const Depsgraph *depsgraph, DEGForeachIDCallback callback, void *user_data); +/* Starts traversal from given component of the given ID, invokes callback for every other + * component which is directly on indirectly dependent on the source one. */ void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, const ID *id, + eDepsObjectComponentType source_component, DEGForeachIDComponentCallback callback, void *user_data); diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc index f5fcdf8e5d1..7bc55b52172 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc @@ -70,6 +70,7 @@ void deg_foreach_clear_flags(const Depsgraph *graph) void deg_foreach_dependent_operation(const Depsgraph *graph, const ID *id, + eDepsObjectComponentType source_component, DEGForeachOperation callback, void *user_data) { @@ -85,6 +86,10 @@ void deg_foreach_dependent_operation(const Depsgraph *graph, /* Start with scheduling all operations from ID node. */ TraversalQueue queue; GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, target_id_node->components) { + if (source_component != DEG_OB_COMP_ANY && + nodeTypeToObjectComponent(comp_node->type) != source_component) { + continue; + } for (OperationNode *op_node : comp_node->operations) { queue.push_back(op_node); op_node->scheduled = true; @@ -144,13 +149,15 @@ void deg_foreach_dependent_component_callback(OperationNode *op_node, void *user void deg_foreach_dependent_ID_component(const Depsgraph *graph, const ID *id, + eDepsObjectComponentType source_component, DEGForeachIDComponentCallback callback, void *user_data) { ForeachIDComponentData data; data.callback = callback; data.user_data = user_data; - deg_foreach_dependent_operation(graph, id, deg_foreach_dependent_component_callback, &data); + deg_foreach_dependent_operation( + graph, id, source_component, deg_foreach_dependent_component_callback, &data); } struct ForeachIDData { @@ -177,7 +184,8 @@ void deg_foreach_dependent_ID(const Depsgraph *graph, ForeachIDData data; data.callback = callback; data.user_data = user_data; - deg_foreach_dependent_operation(graph, id, deg_foreach_dependent_ID_callback, &data); + deg_foreach_dependent_operation( + graph, id, DEG_OB_COMP_ANY, deg_foreach_dependent_ID_callback, &data); } void deg_foreach_ancestor_ID(const Depsgraph *graph, @@ -269,11 +277,12 @@ void DEG_foreach_dependent_ID(const Depsgraph *depsgraph, void DEG_foreach_dependent_ID_component(const Depsgraph *depsgraph, const ID *id, + eDepsObjectComponentType source_component, DEGForeachIDComponentCallback callback, void *user_data) { DEG::deg_foreach_dependent_ID_component( - (const DEG::Depsgraph *)depsgraph, id, callback, user_data); + (const DEG::Depsgraph *)depsgraph, id, source_component, callback, user_data); } void DEG_foreach_ancestor_ID(const Depsgraph *depsgraph, diff --git a/source/blender/depsgraph/intern/node/deg_node.cc b/source/blender/depsgraph/intern/node/deg_node.cc index f53caca00a9..701344c2405 100644 --- a/source/blender/depsgraph/intern/node/deg_node.cc +++ b/source/blender/depsgraph/intern/node/deg_node.cc @@ -177,6 +177,8 @@ eDepsSceneComponentType nodeTypeToSceneComponent(NodeType type) NodeType nodeTypeFromObjectComponent(eDepsObjectComponentType component) { switch (component) { + case DEG_OB_COMP_ANY: + return NodeType::UNDEFINED; case DEG_OB_COMP_PARAMETERS: return NodeType::PARAMETERS; case DEG_OB_COMP_PROXY: |