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:
Diffstat (limited to 'source/blender/depsgraph/intern/depsgraph_query_foreach.cc')
-rw-r--r--source/blender/depsgraph/intern/depsgraph_query_foreach.cc75
1 files changed, 31 insertions, 44 deletions
diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
index efd7d6e77ef..b68c4b91fcc 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
@@ -23,14 +23,9 @@
* Implementation of Querying and Filtering API's
*/
-#include <unordered_set>
-
#include "MEM_guardedalloc.h"
-extern "C" {
-#include "BLI_ghash.h"
#include "BLI_utildefines.h"
-} /* extern "C" */
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
@@ -50,8 +45,6 @@ extern "C" {
namespace DEG {
namespace {
-using std::unordered_set;
-
typedef deque<OperationNode *> TraversalQueue;
typedef void (*DEGForeachOperation)(OperationNode *op_node, void *user_data);
@@ -66,11 +59,12 @@ bool deg_foreach_needs_visit(const OperationNode *op_node, const int flags)
return true;
}
-static void deg_foreach_dependent_operation(const IDNode *target_id_node,
- eDepsObjectComponentType source_component_type,
- int flags,
- DEGForeachOperation callback,
- void *user_data)
+void deg_foreach_dependent_operation(const Depsgraph *UNUSED(graph),
+ const IDNode *target_id_node,
+ eDepsObjectComponentType source_component_type,
+ int flags,
+ DEGForeachOperation callback,
+ void *user_data)
{
if (target_id_node == nullptr) {
/* TODO(sergey): Shall we inform or assert here about attempt to start
@@ -79,8 +73,8 @@ static void deg_foreach_dependent_operation(const IDNode *target_id_node,
}
/* Start with scheduling all operations from ID node. */
TraversalQueue queue;
- unordered_set<OperationNode *> scheduled;
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, target_id_node->components) {
+ Set<OperationNode *> scheduled;
+ for (ComponentNode *comp_node : target_id_node->components.values()) {
if (source_component_type != DEG_OB_COMP_ANY &&
nodeTypeToObjectComponent(comp_node->type) != source_component_type) {
continue;
@@ -90,10 +84,9 @@ static void deg_foreach_dependent_operation(const IDNode *target_id_node,
continue;
}
queue.push_back(op_node);
- scheduled.insert(op_node);
+ scheduled.add(op_node);
}
}
- GHASH_FOREACH_END();
/* Process the queue. */
while (!queue.empty()) {
/* get next operation node to process. */
@@ -104,9 +97,8 @@ static void deg_foreach_dependent_operation(const IDNode *target_id_node,
/* Schedule outgoing operation nodes. */
if (op_node->outlinks.size() == 1) {
OperationNode *to_node = (OperationNode *)op_node->outlinks[0]->to;
- if (scheduled.find(to_node) == scheduled.end() &&
- deg_foreach_needs_visit(to_node, flags)) {
- scheduled.insert(to_node);
+ if (!scheduled.contains(to_node) && deg_foreach_needs_visit(to_node, flags)) {
+ scheduled.add_new(to_node);
op_node = to_node;
}
else {
@@ -116,10 +108,9 @@ static void deg_foreach_dependent_operation(const IDNode *target_id_node,
else {
for (Relation *rel : op_node->outlinks) {
OperationNode *to_node = (OperationNode *)rel->to;
- if (scheduled.find(to_node) == scheduled.end() &&
- deg_foreach_needs_visit(to_node, flags)) {
+ if (!scheduled.contains(to_node) && deg_foreach_needs_visit(to_node, flags)) {
queue.push_front(to_node);
- scheduled.insert(to_node);
+ scheduled.add_new(to_node);
}
}
break;
@@ -132,7 +123,7 @@ struct ForeachIDComponentData {
DEGForeachIDComponentCallback callback;
void *user_data;
IDNode *target_id_node;
- unordered_set<ComponentNode *> visited;
+ Set<ComponentNode *> visited;
};
void deg_foreach_dependent_component_callback(OperationNode *op_node, void *user_data_v)
@@ -140,11 +131,10 @@ void deg_foreach_dependent_component_callback(OperationNode *op_node, void *user
ForeachIDComponentData *user_data = reinterpret_cast<ForeachIDComponentData *>(user_data_v);
ComponentNode *comp_node = op_node->owner;
IDNode *id_node = comp_node->owner;
- if (id_node != user_data->target_id_node &&
- user_data->visited.find(comp_node) == user_data->visited.end()) {
+ if (id_node != user_data->target_id_node && !user_data->visited.contains(comp_node)) {
user_data->callback(
id_node->id_orig, nodeTypeToObjectComponent(comp_node->type), user_data->user_data);
- user_data->visited.insert(comp_node);
+ user_data->visited.add_new(comp_node);
}
}
@@ -159,7 +149,8 @@ void deg_foreach_dependent_ID_component(const Depsgraph *graph,
data.callback = callback;
data.user_data = user_data;
data.target_id_node = graph->find_id_node(id);
- deg_foreach_dependent_operation(data.target_id_node,
+ deg_foreach_dependent_operation(graph,
+ data.target_id_node,
source_component_type,
flags,
deg_foreach_dependent_component_callback,
@@ -170,7 +161,7 @@ struct ForeachIDData {
DEGForeachIDCallback callback;
void *user_data;
IDNode *target_id_node;
- unordered_set<IDNode *> visited;
+ Set<IDNode *> visited;
};
void deg_foreach_dependent_ID_callback(OperationNode *op_node, void *user_data_v)
@@ -178,10 +169,9 @@ void deg_foreach_dependent_ID_callback(OperationNode *op_node, void *user_data_v
ForeachIDData *user_data = reinterpret_cast<ForeachIDData *>(user_data_v);
ComponentNode *comp_node = op_node->owner;
IDNode *id_node = comp_node->owner;
- if (id_node != user_data->target_id_node &&
- user_data->visited.find(id_node) == user_data->visited.end()) {
+ if (id_node != user_data->target_id_node && !user_data->visited.contains(id_node)) {
user_data->callback(id_node->id_orig, user_data->user_data);
- user_data->visited.insert(id_node);
+ user_data->visited.add_new(id_node);
}
}
@@ -195,7 +185,7 @@ void deg_foreach_dependent_ID(const Depsgraph *graph,
data.user_data = user_data;
data.target_id_node = graph->find_id_node(id);
deg_foreach_dependent_operation(
- data.target_id_node, DEG_OB_COMP_ANY, 0, deg_foreach_dependent_ID_callback, &data);
+ graph, data.target_id_node, DEG_OB_COMP_ANY, 0, deg_foreach_dependent_ID_callback, &data);
}
void deg_foreach_ancestor_ID(const Depsgraph *graph,
@@ -212,16 +202,15 @@ void deg_foreach_ancestor_ID(const Depsgraph *graph,
}
/* Start with scheduling all operations from ID node. */
TraversalQueue queue;
- unordered_set<OperationNode *> scheduled;
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, target_id_node->components) {
+ Set<OperationNode *> scheduled;
+ for (ComponentNode *comp_node : target_id_node->components.values()) {
for (OperationNode *op_node : comp_node->operations) {
queue.push_back(op_node);
- scheduled.insert(op_node);
+ scheduled.add(op_node);
}
}
- GHASH_FOREACH_END();
- unordered_set<IDNode *> visited;
- visited.insert(target_id_node);
+ Set<IDNode *> visited;
+ visited.add_new(target_id_node);
/* Process the queue. */
while (!queue.empty()) {
/* get next operation node to process. */
@@ -231,18 +220,17 @@ void deg_foreach_ancestor_ID(const Depsgraph *graph,
/* Check whether we need to inform callee about corresponding ID node. */
ComponentNode *comp_node = op_node->owner;
IDNode *id_node = comp_node->owner;
- if (visited.find(id_node) == visited.end()) {
+ if (!visited.contains(id_node)) {
/* TODO(sergey): Is it orig or CoW? */
callback(id_node->id_orig, user_data);
- visited.insert(id_node);
+ visited.add_new(id_node);
}
/* Schedule incoming operation nodes. */
if (op_node->inlinks.size() == 1) {
Node *from = op_node->inlinks[0]->from;
if (from->get_class() == NodeClass::OPERATION) {
OperationNode *from_node = (OperationNode *)from;
- if (scheduled.find(from_node) == scheduled.end()) {
- scheduled.insert(from_node);
+ if (scheduled.add(from_node)) {
op_node = from_node;
}
else {
@@ -255,9 +243,8 @@ void deg_foreach_ancestor_ID(const Depsgraph *graph,
Node *from = rel->from;
if (from->get_class() == NodeClass::OPERATION) {
OperationNode *from_node = (OperationNode *)from;
- if (scheduled.find(from_node) == scheduled.end()) {
+ if (scheduled.add(from_node)) {
queue.push_front(from_node);
- scheduled.insert(from_node);
}
}
}