[Bf-blender-cvs] [267598c] depsgraph_refactor: Removed the `remove_from_graph` callbacks from DepsNode and the generic `remove_node` function in Depsgraph.

Lukas Tönne noreply at git.blender.org
Sun Apr 13 10:41:53 CEST 2014


Commit: 267598c5f0cd4636281979f1f260fceb5c79ee95
Author: Lukas Tönne
Date:   Sun Apr 13 10:32:16 2014 +0200
https://developer.blender.org/rB267598c5f0cd4636281979f1f260fceb5c79ee95

Removed the `remove_from_graph` callbacks from DepsNode and the generic
`remove_node` function in Depsgraph.

These were currently unused anyway. In future for removing a node the
respective remove_xxx methods in the actual container should be called.
This is more consistent with the hierarchical data structure and the
actual ownership of nodes. Might add convenience methods for this sort
of thing later, but the raw Depsgraph node container is cleaner this way.

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

M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph.h
M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/depsgraph/intern/depsnode_component.cpp
M	source/blender/depsgraph/intern/depsnode_component.h
M	source/blender/depsgraph/intern/depsnode_operation.cpp
M	source/blender/depsgraph/intern/depsnode_operation.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index 604985a..e825fa0 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -124,31 +124,6 @@ DepsNode *Depsgraph::add_new_node(const ID *id, const string &subdata,
 	return node;
 }
 
-/* Remove/Free ---------------------------------------- */
-
-/* Remove node from graph, but don't free any of its data */
-void Depsgraph::remove_node(DepsNode *node)
-{
-	if (node == NULL)
-		return;
-	
-	/* relationships 
-	 * - remove these, since they're at the same level as the
-	 *   node itself (inter-relations between sub-nodes will
-	 *   still remain and/or can still work that way)
-	 */
-	DEPSNODE_RELATIONS_ITER_BEGIN(node->inlinks, rel)
-		delete rel;
-	DEPSNODE_RELATIONS_ITER_END;
-	
-	DEPSNODE_RELATIONS_ITER_BEGIN(node->outlinks, rel)
-		delete rel;
-	DEPSNODE_RELATIONS_ITER_END;
-	
-	/* remove node from graph - handle special data the node might have */
-	node->remove_from_graph(this);
-}
-
 /* Query Conditions from RNA ----------------------- */
 
 /* Convenience wrapper to find node given just pointer + property */
@@ -197,6 +172,21 @@ SubgraphDepsNode *Depsgraph::add_subgraph_node(const ID *id)
 	return subgraph_node;
 }
 
+void Depsgraph::remove_subgraph_node(SubgraphDepsNode *subgraph_node)
+{
+	subgraphs.erase(subgraph_node);
+	delete subgraph_node;
+}
+
+void Depsgraph::clear_subgraph_nodes()
+{
+	for (Subgraphs::iterator it = subgraphs.begin(); it != subgraphs.end(); ++it) {
+		SubgraphDepsNode *subgraph_node = *it;
+		delete subgraph_node;
+	}
+	subgraphs.clear();
+}
+
 IDDepsNode *Depsgraph::find_id_node(const ID *id) const
 {
 	IDNodeMap::const_iterator it = this->id_hash.find(id);
@@ -293,6 +283,9 @@ Depsgraph::~Depsgraph()
 	if (this->root_node) {
 		delete this->root_node;
 	}
+	
+	clear_id_nodes();
+	clear_subgraph_nodes();
 }
 
 /* Init --------------------------------------------- */
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index ef7b170..b53a1c3 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -143,15 +143,14 @@ struct Depsgraph {
 	
 	RootDepsNode *add_root_node();
 	SubgraphDepsNode *add_subgraph_node(const ID *id);
+	void remove_subgraph_node(SubgraphDepsNode *subgraph_node);
+	void clear_subgraph_nodes();
 	
 	IDDepsNode *find_id_node(const ID *id) const;
 	IDDepsNode *add_id_node(const ID *id, const string &name = "");
 	void remove_id_node(const ID *id);
 	void clear_id_nodes();
 	
-	/* Remove node from graph, but don't free any of its data */
-	void remove_node(DepsNode *node);
-	
 	/* Add new relationship between two nodes */
 	DepsRelation *add_new_relation(DepsNode *from, DepsNode *to,
 	                               eDepsRelation_Type type, 
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index dcbc1a7..7b3ca5f 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -83,13 +83,6 @@ DepsNode::~DepsNode()
 
 /* Root Node ============================================== */
 
-/* Remove 'root' node from graph */
-void RootDepsNode::remove_from_graph(Depsgraph *graph)
-{
-	BLI_assert(graph->root_node == this);
-	graph->root_node = NULL;
-}
-
 TimeSourceDepsNode *RootDepsNode::add_time_source(const string &name)
 {
 	if (!time_source) {
@@ -105,28 +98,6 @@ static DepsNodeFactoryImpl<RootDepsNode> DNTI_ROOT;
 
 /* Time Source Node ======================================= */
 
-/* Remove 'time source' node from graph */
-void TimeSourceDepsNode::remove_from_graph(Depsgraph *graph)
-{
-#if 0
-	BLI_assert(this->owner != NULL);
-	
-	switch(this->owner->type) {
-		case DEPSNODE_TYPE_ROOT: /* root node - standard case */
-		{
-			graph->root_node->time_source = NULL;
-			this->owner = NULL;
-		}
-		break;
-		
-		// XXX: ID node - as needed...
-		
-		default: /* unhandled for now */
-			break;
-	}
-#endif
-}
-
 DEG_DEPSNODE_DEFINE(TimeSourceDepsNode, DEPSNODE_TYPE_TIMESOURCE, "Time Source");
 static DepsNodeFactoryImpl<TimeSourceDepsNode> DNTI_TIMESOURCE;
 
@@ -148,10 +119,7 @@ void IDDepsNode::init(const ID *id, const string &UNUSED(subdata))
 /* Free 'id' node */
 IDDepsNode::~IDDepsNode()
 {
-	for (IDDepsNode::ComponentMap::const_iterator it = this->components.begin(); it != this->components.end(); ++it) {
-		const ComponentDepsNode *comp = it->second;
-		delete comp;
-	}
+	clear_components();
 }
 
 /* Copy 'id' node */
@@ -214,13 +182,6 @@ void IDDepsNode::clear_components()
 	components.clear();
 }
 
-/* Remove 'id' node from graph */
-void IDDepsNode::remove_from_graph(Depsgraph *graph)
-{
-	/* remove toplevel node and hash entry, but don't free... */
-	graph->id_hash.erase(this->id);
-}
-
 /* Validate links between components */
 void IDDepsNode::validate_links(Depsgraph *graph)
 {
@@ -325,21 +286,6 @@ void SubgraphDepsNode::copy(DepsgraphCopyContext *dcc, const SubgraphDepsNode *s
 	/* for now, subgraph itself isn't copied... */
 }
 
-/* Remove 'subgraph' node from graph */
-void SubgraphDepsNode::remove_from_graph(Depsgraph *graph)
-{
-	/* remove from subnodes list */
-	graph->subgraphs.erase(this);
-	
-	/* remove from ID-nodes lookup */
-	if (this->root_id) {
-#if 0 /* XXX subgraph node is NOT a true IDDepsNode - what is this supposed to do? */
-		BLI_assert(graph->find_id_node(this->root_id) == this);
-		graph->id_hash.erase(this->root_id);
-#endif
-	}
-}
-
 /* Validate subgraph links... */
 void SubgraphDepsNode::validate_links(Depsgraph *graph)
 {
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 56b8b32..b2d8909 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -106,9 +106,6 @@ public:
 	virtual void init(const ID *id, const string &subdata) {}
 	virtual void copy(DepsgraphCopyContext *dcc, const DepsNode *src) {}
 	
-	/* Remove node from graph - Only use when node is to be replaced... */
-	virtual void remove_from_graph(Depsgraph *graph) = 0;
-	
 	/* Recursively ensure that all implicit/builtin link rules have been applied */
 	/* i.e. init()/cleanup() callbacks as last items for components + component ordering rules obeyed */
 	virtual void validate_links(Depsgraph *graph) {}
@@ -131,8 +128,6 @@ struct ComponentDepsNode;
 
 /* Time Source Node */
 struct TimeSourceDepsNode : public DepsNode {
-	void remove_from_graph(Depsgraph *graph);
-	
 	// XXX: how do we keep track of the chain of time sources for propagation of delays?
 	
 	double cfra;                    /* new "current time" */
@@ -143,8 +138,6 @@ struct TimeSourceDepsNode : public DepsNode {
 
 /* Root Node */
 struct RootDepsNode : public DepsNode {
-	void remove_from_graph(Depsgraph *graph);
-	
 	TimeSourceDepsNode *add_time_source(const string &name = "");
 	
 	struct Scene *scene;             /* scene that this corresponds to */
@@ -166,8 +159,6 @@ struct IDDepsNode : public DepsNode {
 	void remove_component(eDepsNode_Type type);
 	void clear_components();
 	
-	void remove_from_graph(Depsgraph *graph);
-	
 	void validate_links(Depsgraph *graph);
 	
 	struct ID *id;                  /* ID Block referenced */
@@ -182,8 +173,6 @@ struct SubgraphDepsNode : public DepsNode {
 	void copy(DepsgraphCopyContext *dcc, const SubgraphDepsNode *src);
 	~SubgraphDepsNode();
 	
-	void remove_from_graph(Depsgraph *graph);
-	
 	void validate_links(Depsgraph *graph);
 	
 	Depsgraph *graph;        /* instanced graph */
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp b/source/blender/depsgraph/intern/depsnode_component.cpp
index 2848caf..f1c7b15 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -78,11 +78,7 @@ void ComponentDepsNode::copy(DepsgraphCopyContext *dcc, const ComponentDepsNode
 /* Free 'component' node */
 ComponentDepsNode::~ComponentDepsNode()
 {
-	/* free nodes and list of nodes */
-	for (OperationMap::const_iterator it = this->operations.begin(); it != this->operations.end(); ++it) {
-		OperationDepsNode *op = it->second;
-		delete op;
-	}
+	clear_operations();
 }
 
 OperationDepsNode *ComponentDepsNode::find_operation(const string &name) const
@@ -135,21 +131,6 @@ void ComponentDepsNode::clear_operations()
 	operations.clear();
 }
 
-/* Remove 'component' node from graph */
-void ComponentDepsNode::remove_from_graph(Depsgraph *graph)
-{
-	/* detach from owner (i.e. id-ref) */
-	if (this->owner) {
-		IDDepsNode *id_node = this->owner;
-		id_node->components.erase(this->type);
-		this->owner = NULL;
-	}
-	
-	/* NOTE: don't need to do anything about relationships,
-	 * as those are handled via the standard mechanism
-	 */
-}
-
 /* Parameter Component Defines ============================ */
 
 DEG_DEPSNODE_DEFINE(ParametersComponentDepsNode, DEPSNODE_TYPE_PARAMETERS, "Parameters Component");
@@ -244,6 +225,7 @@ void PoseComponentDepsNode::copy(DepsgraphCopyContext *dcc, const PoseComponentD
 /* Free 'pose eval' node */
 PoseComponentDepsNode::~PoseComponentDepsNode()
 {
+	clear_bone_components();
 }
 
 /* Validate links for pose evaluation */
@@ -314,22 +296,6 @@ void BoneComponentDepsNode::init(const ID *id, const string &subdata)
 	this->pchan = BKE_pose_channel_find_name(ob->pose, subdata.c_str());
 }
 
-/* Remove 'bone component' node from graph */
-void BoneComponentDepsNode::remove_from_graph(Depsgraph *graph)
-{
-	/* detach from owner (i.e. pose component) */
-	if (this->owner) {
-		PoseComponentDepsNode *pose_node = (PoseComponentDepsNode *)this->owner;
-		
-		pose_node->bone_hash.erase(this->name);
-		this->owner = NULL;
-	}
-	
-	/* NOTE: don't need to do anything about relationships,
-	 * as those are handled via the standard mechanism
-	 */
-}
-
 /* Validate 'bone component' links... 
  * - Re-route all component-level relationships to the nodes 
  */
diff --git a/source/blender/depsgraph/intern/depsnode_component.h b/source/blender/depsgraph/intern/depsnode_component.h
index 5ea7fdb..8c20c3b 100644
--- a/source/blender/depsgraph/intern/depsn

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list