[Bf-blender-cvs] [e8639f1] depsgraph_refactor: Depsgraph: Make sure we don't try to create operations twice

Sergey Sharybin noreply at git.blender.org
Fri Feb 13 15:02:05 CET 2015


Commit: e8639f189eef106ab4359e4e22b815810a615d59
Author: Sergey Sharybin
Date:   Fri Feb 13 17:58:12 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBe8639f189eef106ab4359e4e22b815810a615d59

Depsgraph: Make sure we don't try to create operations twice

This isn't totally bad, but might confuse depsgraph a bit.

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

M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build.h
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsnode_component.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index f5c5630..c63baf5 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -249,11 +249,11 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *c
 		m_graph->operations.push_back(op_node);
 	}
 	else {
-		/* TODO(sergey): Ideally graph builder shouldn't create duplicate nodes. */
 		fprintf(stderr, "add_operation: Operation already exists - %s has %s at %p\n",
 		        comp_node->identifier().c_str(),
 		        op_node->identifier().c_str(),
 		        op_node);
+		BLI_assert(!"Should not happen!");
 	}
 	return op_node;
 }
@@ -270,6 +270,17 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ID *id,
 	return add_operation_node(comp_node, optype, op, opcode, description);
 }
 
+bool DepsgraphNodeBuilder::has_operation_node(ID *id,
+                                              eDepsNode_Type comp_type,
+                                              const string &comp_name,
+                                              eDepsOperation_Type optype,
+                                              eDepsOperation_Code opcode,
+                                              const string &description)
+{
+	ComponentDepsNode *comp_node = add_component_node(id, comp_type, comp_name);
+	return comp_node->has_operation(opcode, description) != NULL;
+}
+
 /* ************************************************* */
 /* Relations Builder */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 8c04c18..fe3b363 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -75,6 +75,9 @@ struct DepsgraphNodeBuilder {
 		return add_operation_node(id, comp_type, "", optype, op, opcode, description);
 	}
 
+	bool has_operation_node(ID *id, eDepsNode_Type comp_type, const string &comp_name, eDepsOperation_Type optype,
+	                        eDepsOperation_Code opcode, const string &description = "");
+
 	void build_scene(Main *bmain, Scene *scene);
 	SubgraphDepsNode *build_subgraph(Group *group);
 	void build_group(Scene *scene, Base *base, Object *object, Group *group);
@@ -295,7 +298,9 @@ struct DepsNodeHandle
 	    builder(builder),
 	    node(node),
 	    default_name(default_name)
-	{}
+	{
+		BLI_assert(node != NULL);
+	}
 
 	DepsgraphRelationBuilder *builder;
 	OperationDepsNode *node;
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index b7ceb58..51dec11 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -539,6 +539,12 @@ void DepsgraphNodeBuilder::build_ik_pose(Scene *scene, Object *ob, bPoseChannel
 	/* Find the chain's root. */
 	bPoseChannel *rootchan = BKE_armature_ik_solver_find_root(pchan, data);
 
+	if (has_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name,
+	                       DEPSOP_TYPE_SIM, DEG_OPCODE_POSE_IK_SOLVER))
+	{
+		return;
+	}
+
 	/* Operation node for evaluating/running IK Solver. */
 	add_operation_node(&ob->id, DEPSNODE_TYPE_EVAL_POSE, rootchan->name,
 	                   DEPSOP_TYPE_SIM, function_bind(BKE_pose_iktree_evaluate, _1, scene, ob, rootchan),
@@ -712,8 +718,54 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
 	 * TODO(sergey): Get rid of this node.
 	 */
 	add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
-					   DEPSOP_TYPE_POST, function_bind(BKE_object_eval_uber_data, _1, scene, ob),
-					   DEG_OPCODE_GEOMETRY_UBEREVAL);
+	                   DEPSOP_TYPE_POST, function_bind(BKE_object_eval_uber_data, _1, scene, ob),
+	                   DEG_OPCODE_GEOMETRY_UBEREVAL);
+
+	add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
+	                   DEPSOP_TYPE_INIT, NULL,
+	                   DEG_OPCODE_PLACEHOLDER, "Eval Init");
+
+	// TODO: "Done" operation
+
+	/* ShapeKeys */
+	Key *key = BKE_key_from_object(ob);
+	if (key)
+		build_shapekeys(key);
+
+	/* Modifiers */
+	if (ob->modifiers.first) {
+		ModifierData *md;
+
+		for (md = (ModifierData *)ob->modifiers.first; md; md = md->next) {
+			add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
+			                   DEPSOP_TYPE_EXEC, function_bind(BKE_object_eval_modifier, _1, scene, ob, md),
+			                   DEG_OPCODE_GEOMETRY_MODIFIER, md->name);
+		}
+	}
+
+	/* materials */
+	if (ob->totcol) {
+		int a;
+
+		for (a = 1; a <= ob->totcol; a++) {
+			Material *ma = give_current_material(ob, a);
+
+			if (ma) {
+				// XXX?!
+				ComponentDepsNode *geom_node = add_component_node(&ob->id, DEPSNODE_TYPE_GEOMETRY);
+				build_material(geom_node, ma);
+			}
+		}
+	}
+
+	/* geometry collision */
+	if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
+		// add geometry collider relations
+	}
+
+	if (obdata->flag & LIB_DOIT) {
+		return;
+	}
 
 	/* nodes for result of obdata's evaluation, and geometry evaluation on object */
 	switch (ob->type) {
@@ -781,48 +833,6 @@ void DepsgraphNodeBuilder::build_obdata_geom(Scene *scene, Object *ob)
 	add_operation_node(obdata, DEPSNODE_TYPE_GEOMETRY,
 	                   DEPSOP_TYPE_POST, NULL,
 	                   DEG_OPCODE_PLACEHOLDER, "Eval Done");
-
-	add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
-	                   DEPSOP_TYPE_INIT, NULL,
-	                   DEG_OPCODE_PLACEHOLDER, "Eval Init");
-
-	// TODO: "Done" operation
-
-	/* ShapeKeys */
-	Key *key = BKE_key_from_object(ob);
-	if (key)
-		build_shapekeys(key);
-
-	/* Modifiers */
-	if (ob->modifiers.first) {
-		ModifierData *md;
-
-		for (md = (ModifierData *)ob->modifiers.first; md; md = md->next) {
-			add_operation_node(&ob->id, DEPSNODE_TYPE_GEOMETRY,
-			                   DEPSOP_TYPE_EXEC, function_bind(BKE_object_eval_modifier, _1, scene, ob, md),
-			                   DEG_OPCODE_GEOMETRY_MODIFIER, md->name);
-		}
-	}
-
-	/* materials */
-	if (ob->totcol) {
-		int a;
-
-		for (a = 1; a <= ob->totcol; a++) {
-			Material *ma = give_current_material(ob, a);
-
-			if (ma) {
-				// XXX?!
-				ComponentDepsNode *geom_node = add_component_node(&ob->id, DEPSNODE_TYPE_GEOMETRY);
-				build_material(geom_node, ma);
-			}
-		}
-	}
-
-	/* geometry collision */
-	if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_LATTICE)) {
-		// add geometry collider relations
-	}
 }
 
 /* Cameras */
diff --git a/source/blender/depsgraph/intern/depsnode_component.cpp b/source/blender/depsgraph/intern/depsnode_component.cpp
index 83d984c..ac864a0 100644
--- a/source/blender/depsgraph/intern/depsnode_component.cpp
+++ b/source/blender/depsgraph/intern/depsnode_component.cpp
@@ -161,9 +161,9 @@ OperationDepsNode *ComponentDepsNode::add_operation(eDepsOperation_Type optype,
 		op_node->owner = this;
 	}
 	else {
-		/* we have a duplicate node! */
 		fprintf(stderr, "add_operation: Operation already exists - %s has %s at %p\n",
 		        this->identifier().c_str(), op_node->identifier().c_str(), op_node);
+		BLI_assert(!"Should not happen!");
 	}
 
 	/* attach extra data */




More information about the Bf-blender-cvs mailing list