[Bf-blender-cvs] [97aa43c3643] master: Depsgraph: Make component traversal more granular
Sergey Sharybin
noreply at git.blender.org
Fri Jul 5 16:09:10 CEST 2019
Commit: 97aa43c36433202ca017a90f72cd0fe579b5f4d0
Author: Sergey Sharybin
Date: Thu Jul 4 15:13:26 2019 +0200
Branches: master
https://developer.blender.org/rB97aa43c36433202ca017a90f72cd0fe579b5f4d0
Depsgraph: Make component traversal more granular
Now it is possible to start traversal from a given component.
===================================================================
M source/blender/depsgraph/DEG_depsgraph_build.h
M source/blender/depsgraph/DEG_depsgraph_query.h
M source/blender/depsgraph/intern/depsgraph_query_foreach.cc
M source/blender/depsgraph/intern/node/deg_node.cc
===================================================================
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:
More information about the Bf-blender-cvs
mailing list