[Bf-blender-cvs] [c89e1033484] master: Depsgrapg: Refactor, move Relation to own file

Sergey Sharybin noreply at git.blender.org
Fri Jan 24 12:44:32 CET 2020


Commit: c89e103348414feb3396c7b10abb594c77d8c333
Author: Sergey Sharybin
Date:   Fri Jan 24 11:11:38 2020 +0100
Branches: master
https://developer.blender.org/rBc89e103348414feb3396c7b10abb594c77d8c333

Depsgrapg: Refactor, move Relation to own file

===================================================================

M	source/blender/depsgraph/CMakeLists.txt
M	source/blender/depsgraph/intern/builder/deg_builder.cc
M	source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
M	source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
M	source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
M	source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
M	source/blender/depsgraph/intern/depsgraph.cc
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
M	source/blender/depsgraph/intern/depsgraph_debug.cc
M	source/blender/depsgraph/intern/depsgraph_query_foreach.cc
A	source/blender/depsgraph/intern/depsgraph_relation.cc
A	source/blender/depsgraph/intern/depsgraph_relation.h
M	source/blender/depsgraph/intern/eval/deg_eval.cc
M	source/blender/depsgraph/intern/eval/deg_eval_flush.cc
M	source/blender/depsgraph/intern/node/deg_node.cc
M	source/blender/depsgraph/intern/node/deg_node_time.cc

===================================================================

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 7f3c7d5043f..f98b4caf08e 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -83,6 +83,7 @@ set(SRC
   intern/depsgraph_query.cc
   intern/depsgraph_query_foreach.cc
   intern/depsgraph_query_iter.cc
+  intern/depsgraph_relation.cc
   intern/depsgraph_registry.cc
   intern/depsgraph_tag.cc
   intern/depsgraph_type.cc
@@ -129,6 +130,7 @@ set(SRC
   intern/depsgraph.h
   intern/depsgraph_physics.h
   intern/depsgraph_registry.h
+  intern/depsgraph_relation.h
   intern/depsgraph_tag.h
   intern/depsgraph_type.h
   intern/depsgraph_update.h
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
index fb7104e7556..440d9dd07f6 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -42,6 +42,7 @@ extern "C" {
 }
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
 #include "intern/depsgraph_tag.h"
 #include "intern/depsgraph_type.h"
 #include "intern/builder/deg_builder_cache.h"
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
index bea59eceea2..f18583beb9c 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_cycle.cc
@@ -35,6 +35,7 @@
 #include "intern/node/deg_node_operation.h"
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
 
 namespace DEG {
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
index bc428dd755f..bc441676c86 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc
@@ -114,6 +114,7 @@ extern "C" {
 #include "intern/node/deg_node_operation.h"
 #include "intern/node/deg_node_time.h"
 
+#include "intern/depsgraph_relation.h"
 #include "intern/depsgraph_type.h"
 
 namespace DEG {
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
index e254f8df0d2..484a4d828e3 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_rig.cc
@@ -58,6 +58,7 @@ extern "C" {
 #include "intern/node/deg_node_operation.h"
 
 #include "intern/depsgraph_type.h"
+#include "intern/depsgraph_relation.h"
 
 namespace DEG {
 
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
index 13cf8e63832..fc7c546e294 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_transitive.cc
@@ -30,6 +30,7 @@
 #include "intern/node/deg_node_operation.h"
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
 #include "intern/debug/deg_debug.h"
 
 namespace DEG {
diff --git a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
index ee3959a0861..45d15c230d7 100644
--- a/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
+++ b/source/blender/depsgraph/intern/debug/deg_debug_relations_graphviz.cc
@@ -36,6 +36,8 @@ extern "C" {
 #include "DEG_depsgraph_debug.h"
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
+
 #include "intern/node/deg_node_component.h"
 #include "intern/node/deg_node_id.h"
 #include "intern/node/deg_node_operation.h"
diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc
index 190ff4e929f..0e929f4e8b6 100644
--- a/source/blender/depsgraph/intern/depsgraph.cc
+++ b/source/blender/depsgraph/intern/depsgraph.cc
@@ -46,6 +46,7 @@ extern "C" {
 
 #include "intern/depsgraph_update.h"
 #include "intern/depsgraph_physics.h"
+#include "intern/depsgraph_relation.h"
 #include "intern/depsgraph_registry.h"
 
 #include "intern/eval/deg_eval_copy_on_write.h"
@@ -220,43 +221,6 @@ Relation *Depsgraph::check_nodes_connected(const Node *from,
   return NULL;
 }
 
-/* ************************ */
-/* Relationships Management */
-
-Relation::Relation(Node *from, Node *to, const char *description)
-    : from(from), to(to), name(description), flag(0)
-{
-  /* Hook it up to the nodes which use it.
-   *
-   * NOTE: We register relation in the nodes which this link connects to here
-   * in constructor but we don't unregister it in the destructor.
-   *
-   * Reasoning:
-   *
-   * - Destructor is currently used on global graph destruction, so there's no
-   *   real need in avoiding dangling pointers, all the memory is to be freed
-   *   anyway.
-   *
-   * - Unregistering relation is not a cheap operation, so better to have it
-   *   as an explicit call if we need this. */
-  from->outlinks.push_back(this);
-  to->inlinks.push_back(this);
-}
-
-Relation::~Relation()
-{
-  /* Sanity check. */
-  BLI_assert(from != NULL && to != NULL);
-}
-
-void Relation::unlink()
-{
-  /* Sanity check. */
-  BLI_assert(from != NULL && to != NULL);
-  remove_from_vector(&from->outlinks, this);
-  remove_from_vector(&to->inlinks, this);
-}
-
 /* Low level tagging -------------------------------------- */
 
 /* Tag a specific node as needing updates. */
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index 71603334530..89c5af9c798 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -53,47 +53,9 @@ namespace DEG {
 struct IDNode;
 struct Node;
 struct OperationNode;
+struct Relation;
 struct TimeSourceNode;
 
-/* *************************** */
-/* Relationships Between Nodes */
-
-/* Settings/Tags on Relationship.
- * NOTE: Is a bitmask, allowing accumulation. */
-enum RelationFlag {
-  /* "cyclic" link - when detecting cycles, this relationship was the one
-   * which triggers a cyclic relationship to exist in the graph. */
-  RELATION_FLAG_CYCLIC = (1 << 0),
-  /* Update flush will not go through this relation. */
-  RELATION_FLAG_NO_FLUSH = (1 << 1),
-  /* Only flush along the relation is update comes from a node which was
-   * affected by user input. */
-  RELATION_FLAG_FLUSH_USER_EDIT_ONLY = (1 << 2),
-  /* The relation can not be killed by the cyclic dependencies solver. */
-  RELATION_FLAG_GODMODE = (1 << 4),
-  /* Relation will check existence before being added. */
-  RELATION_CHECK_BEFORE_ADD = (1 << 5),
-};
-
-/* B depends on A (A -> B) */
-struct Relation {
-  Relation(Node *from, Node *to, const char *description);
-  ~Relation();
-
-  void unlink();
-
-  /* the nodes in the relationship (since this is shared between the nodes) */
-  Node *from; /* A */
-  Node *to;   /* B */
-
-  /* relationship attributes */
-  const char *name; /* label for debugging */
-  int flag;         /* Bitmask of RelationFlag) */
-};
-
-/* ********* */
-/* Depsgraph */
-
 /* Dependency Graph object */
 struct Depsgraph {
   // TODO(sergey): Go away from C++ container and use some native BLI.
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc
index 0acf777e2f0..4ecb8b8068c 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cc
+++ b/source/blender/depsgraph/intern/depsgraph_build.cc
@@ -59,6 +59,7 @@ extern "C" {
 #include "intern/node/deg_node_id.h"
 #include "intern/node/deg_node_operation.h"
 
+#include "intern/depsgraph_relation.h"
 #include "intern/depsgraph_registry.h"
 #include "intern/depsgraph_type.h"
 
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc
index 51267491458..4cf3a150eac 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cc
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cc
@@ -38,6 +38,7 @@ extern "C" {
 #include "DEG_depsgraph_query.h"
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
 #include "intern/depsgraph_type.h"
 #include "intern/debug/deg_debug.h"
 #include "intern/node/deg_node_component.h"
diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
index b7a40fb69bd..cd5e8f8a8d9 100644
--- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
+++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc
@@ -40,6 +40,7 @@ extern "C" {
 #include "DEG_depsgraph_query.h"
 
 #include "intern/depsgraph.h"
+#include "intern/depsgraph_relation.h"
 #include "intern/node/deg_node.h"
 #include "intern/node/deg_node_component.h"
 #include "intern/node/deg_node_id.h"
diff --git a/source/blender/depsgraph/intern/depsgraph_relation.cc b/source/blender/depsgraph/intern/depsgraph_relation.cc
new file mode 100644
index 00000000000..387582ca4e0
--- /dev/null
+++ b/source/blender/depsgraph/intern/depsgraph_relation.cc
@@ -0,0 +1,73 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup depsgraph
+ */
+
+#include "intern/depsgraph_relation.h" /* own include */
+
+#include "BLI_utildefines.h"
+
+#incl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list