[Bf-blender-cvs] [91fd4dd] depsgraph_cleanup: Depsgraph: Move builders to own sub-folder

Sergey Sharybin noreply at git.blender.org
Thu May 26 10:02:29 CEST 2016


Commit: 91fd4dd241eb82014ebc41f3ed630f4a21bac2b9
Author: Sergey Sharybin
Date:   Wed May 25 16:00:51 2016 +0200
Branches: depsgraph_cleanup
https://developer.blender.org/rB91fd4dd241eb82014ebc41f3ed630f4a21bac2b9

Depsgraph: Move builders to own sub-folder

Also split builder declaration file.

The idea is to split files into smaller ones, optionally moving
heavy and tricky builder parts into own files, for example we can
add deg_builder_relations_rig.cc, deg_builder_relations_proxy.cc
and so on.

Also started moving depsgraph into DEG namespace. With all the
complexity over code being added to blender now it should make it
easier to avoid name conflicts and such.

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

M	source/blender/depsgraph/CMakeLists.txt
A	source/blender/depsgraph/intern/builder/deg_builder.cc
A	source/blender/depsgraph/intern/builder/deg_builder.h
A	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
A	source/blender/depsgraph/intern/builder/deg_builder_nodes.h
A	source/blender/depsgraph/intern/builder/deg_builder_relations.cc
A	source/blender/depsgraph/intern/builder/deg_builder_relations.h
M	source/blender/depsgraph/intern/depsgraph_build.cc
D	source/blender/depsgraph/intern/depsgraph_build.h
D	source/blender/depsgraph/intern/depsgraph_build_nodes.cc
D	source/blender/depsgraph/intern/depsgraph_build_relations.cc
M	source/blender/depsgraph/intern/depsnode_component.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 91f89ed..bda5f5a 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -42,13 +42,14 @@ set(INC_SYS
 )
 
 set(SRC
+	intern/builder/deg_builder.cc
+	intern/builder/deg_builder_nodes.cc
+	intern/builder/deg_builder_relations.cc
 	intern/depsgraph.cc
 	intern/depsnode.cc
 	intern/depsnode_component.cc
 	intern/depsnode_operation.cc
 	intern/depsgraph_build.cc
-	intern/depsgraph_build_nodes.cc
-	intern/depsgraph_build_relations.cc
 	intern/depsgraph_debug.cc
 	intern/depsgraph_eval.cc
 	intern/depsgraph_query.cc
@@ -64,12 +65,14 @@ set(SRC
 	DEG_depsgraph_build.h
 	DEG_depsgraph_debug.h
 	DEG_depsgraph_query.h
+	intern/builder/deg_builder.h
+	intern/builder/deg_builder_nodes.h
+	intern/builder/deg_builder_relations.h
 	intern/depsgraph.h
 	intern/depsnode.h
 	intern/depsnode_component.h
 	intern/depsnode_operation.h
 	intern/depsnode_opcodes.h
-	intern/depsgraph_build.h
 	intern/depsgraph_debug.h
 	intern/depsgraph_intern.h
 	intern/depsgraph_queue.h
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc
new file mode 100644
index 0000000..e24e3a5
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder.cc
@@ -0,0 +1,125 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Sergey Sharybin
+ * Contributor(s): None Yet
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/depsgraph/intern/build/deg_builder.cc
+ *  \ingroup depsgraph
+ */
+
+// TODO(sergey): Use own wrapper over STD.
+#include <stack>
+
+#include "builder/deg_builder.h"
+
+#include "DNA_anim_types.h"
+
+#include "BLI_string.h"
+
+#include "intern/depsgraph.h"
+#include "intern/depsgraph_types.h"
+#include "intern/depsnode.h"
+#include "intern/depsnode_component.h"
+#include "intern/depsnode_operation.h"
+
+#include "depsgraph_util_foreach.h"
+
+namespace DEG {
+
+string deg_fcurve_id_name(const FCurve *fcu)
+{
+	char index_buf[32];
+	// TODO(sergey): Use int-to-string utility or so.
+	BLI_snprintf(index_buf, sizeof(index_buf), "[%d]", fcu->array_index);
+	return string(fcu->rna_path) + index_buf;
+}
+
+void deg_graph_build_finalize(Depsgraph *graph)
+{
+	std::stack<OperationDepsNode *> stack;
+
+	foreach (OperationDepsNode *node, graph->operations) {
+		node->done = 0;
+		node->num_links_pending = 0;
+		foreach (DepsRelation *rel, node->inlinks) {
+			if ((rel->from->type == DEPSNODE_TYPE_OPERATION) &&
+			    (rel->flag & DEPSREL_FLAG_CYCLIC) == 0)
+			{
+				++node->num_links_pending;
+			}
+		}
+		if (node->num_links_pending == 0) {
+			stack.push(node);
+		}
+		IDDepsNode *id_node = node->owner->owner;
+		id_node->id->tag |= LIB_TAG_DOIT;
+	}
+
+	while (!stack.empty()) {
+		OperationDepsNode *node = stack.top();
+		if (node->done == 0 && node->outlinks.size() != 0) {
+			foreach (DepsRelation *rel, node->outlinks) {
+				if (rel->to->type == DEPSNODE_TYPE_OPERATION) {
+					OperationDepsNode *to = (OperationDepsNode *)rel->to;
+					if ((rel->flag & DEPSREL_FLAG_CYCLIC) == 0) {
+						BLI_assert(to->num_links_pending > 0);
+						--to->num_links_pending;
+					}
+					if (to->num_links_pending == 0) {
+						stack.push(to);
+					}
+				}
+			}
+			node->done = 1;
+		}
+		else {
+			stack.pop();
+			IDDepsNode *id_node = node->owner->owner;
+			foreach (DepsRelation *rel, node->outlinks) {
+				if (rel->to->type == DEPSNODE_TYPE_OPERATION) {
+					OperationDepsNode *to = (OperationDepsNode *)rel->to;
+					IDDepsNode *id_to = to->owner->owner;
+					id_node->layers |= id_to->layers;
+				}
+			}
+		}
+	}
+
+	/* Re-tag IDs for update if it was tagged before the relations update tag. */
+	for (Depsgraph::IDNodeMap::const_iterator it = graph->id_hash.begin();
+	     it != graph->id_hash.end();
+	     ++it)
+	{
+		IDDepsNode *id_node = it->second;
+		ID *id = id_node->id;
+		if (id->tag & LIB_TAG_ID_RECALC_ALL &&
+		    id->tag & LIB_TAG_DOIT)
+		{
+			id_node->tag_update(graph);
+			id->tag &= ~LIB_TAG_DOIT;
+		}
+	}
+}
+
+}  // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder.h b/source/blender/depsgraph/intern/builder/deg_builder.h
new file mode 100644
index 0000000..c46fb28
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder.h
@@ -0,0 +1,46 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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) 2016 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Sergey Sharybin
+ * Contributor(s): None Yet
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/depsgraph/intern/build/deg_builder.h
+ *  \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "depsgraph_types.h"
+
+class Depsgraph;
+
+struct FCurve;
+
+namespace DEG {
+
+/* Get unique identifier for FCurves and Drivers */
+string deg_fcurve_id_name(const FCurve *fcu);
+
+void deg_graph_build_finalize(class Depsgraph *graph);
+
+}  // namespace DEG
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
similarity index 99%
rename from source/blender/depsgraph/intern/depsgraph_build_nodes.cc
rename to source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index acb8738..f8faecf 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -24,12 +24,14 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/depsgraph/intern/depsgraph_build_nodes.cc
+/** \file blender/depsgraph/intern/builder/deg_build_nodes.cc
  *  \ingroup depsgraph
  *
  * Methods for constructing depsgraph's nodes
  */
 
+#include "builder/deg_builder_nodes.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -97,13 +99,15 @@ extern "C" {
 #include "RNA_types.h"
 } /* extern "C" */
 
+#include "builder/deg_builder.h"
 #include "depsnode.h"
 #include "depsnode_component.h"
 #include "depsnode_operation.h"
 #include "depsgraph_types.h"
-#include "depsgraph_build.h"
 #include "depsgraph_intern.h"
 
+namespace DEG {
+
 /* ************ */
 /* Node Builder */
 
@@ -1234,3 +1238,5 @@ void DepsgraphNodeBuilder::build_gpencil(bGPdata *gpd)
 	 */
 	build_animdata(gpd_id);
 }
+
+}  // namespace DEG
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
new file mode 100644
index 0000000..e375d18
--- /dev/null
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -0,0 +1,138 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Lukas Toenne
+ * Contributor(s): None Yet
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/depsgraph/intern/builder/deg_builder_nodes.h
+ *  \ingroup depsgraph
+ */
+
+#pragma once
+
+#include "depsgraph_types.h"
+
+struct Base;
+struct bGPdata;
+struct ListBase;
+struct GHash;
+struct ID;
+struct FCurve;
+struct Group;
+struct Key;
+struct Main;
+struct Material;
+struct MTex;
+struct bNodeTree;
+struct Object;
+struct bPoseChannel;
+struct bConstraint;
+struct Scene;
+struct Tex;
+struct World;
+
+struct PropertyRNA;
+
+struct Depsgraph;
+struct DepsNode;
+struct DepsNodeHandle;
+struct RootDepsNode;
+struct SubgraphDepsNode;
+struct IDDepsNode;
+struct TimeSourceDepsNode;
+struct ComponentDepsNode;
+struct OperationDepsNode;
+struct RootPChanMap;
+
+namespace DEG {
+
+struct DepsgraphNodeBuilder {
+	DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph);
+	~DepsgraphNodeBuilder();
+
+	RootDepsNode *add_root_node();
+	IDDepsNode *add_id_node(ID *id);
+	TimeSourceDepsNode *add_time_source(ID *id);
+
+	ComponentDepsNode *add_component_node(ID *id, eDepsNode_Type comp_type, const string &comp_name = "");
+
+	OperationDeps

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list