[Bf-blender-cvs] [0fb55310b38] master: Depsgraph: Cleanup, use dedicated function to ensure node exists

Sergey Sharybin noreply at git.blender.org
Fri Mar 2 16:36:28 CET 2018


Commit: 0fb55310b3829b3b12963ab8925fab63e735e192
Author: Sergey Sharybin
Date:   Fri Mar 2 14:35:19 2018 +0100
Branches: master
https://developer.blender.org/rB0fb55310b3829b3b12963ab8925fab63e735e192

Depsgraph: Cleanup, use dedicated function to ensure node exists

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

M	source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
M	source/blender/depsgraph/intern/builder/deg_builder_nodes.h

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

diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
index c0afec08a00..6245c514ddb 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
@@ -239,6 +239,22 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(
 	                          name_tag);
 }
 
+OperationDepsNode *DepsgraphNodeBuilder::ensure_operation_node(
+        ID *id,
+        eDepsNode_Type comp_type,
+        const DepsEvalOperationCb& op,
+        eDepsOperation_Code opcode,
+        const char *name,
+        int name_tag)
+{
+	OperationDepsNode *operation =
+	        find_operation_node(id, comp_type, opcode, name, name_tag);
+	if (operation != NULL) {
+		return operation;
+	}
+	return add_operation_node(id, comp_type, op, opcode, name, name_tag);
+}
+
 bool DepsgraphNodeBuilder::has_operation_node(ID *id,
                                               eDepsNode_Type comp_type,
                                               const char *comp_name,
@@ -519,23 +535,12 @@ void DepsgraphNodeBuilder::build_animdata(ID *id)
 void DepsgraphNodeBuilder::build_driver(ID *id, FCurve *fcu)
 {
 	/* Create data node for this driver */
-	/* TODO(sergey): Avoid creating same operation multiple times,
-	 * in the future we need to avoid lookup of the operation as well
-	 * and use some tagging magic instead.
-	 */
-	OperationDepsNode *driver_op = find_operation_node(id,
-	                                                   DEG_NODE_TYPE_PARAMETERS,
-	                                                   DEG_OPCODE_DRIVER,
-	                                                   fcu->rna_path ? fcu->rna_path : "",
-	                                                   fcu->array_index);
-	if (driver_op == NULL) {
-		add_operation_node(id,
-		                   DEG_NODE_TYPE_PARAMETERS,
-		                   function_bind(BKE_animsys_eval_driver, _1, id, fcu),
-		                   DEG_OPCODE_DRIVER,
-		                   fcu->rna_path ? fcu->rna_path : "",
-		                   fcu->array_index);
-	}
+	ensure_operation_node(id,
+	                      DEG_NODE_TYPE_PARAMETERS,
+	                      function_bind(BKE_animsys_eval_driver, _1, id, fcu),
+	                      DEG_OPCODE_DRIVER,
+	                      fcu->rna_path ? fcu->rna_path : "",
+	                      fcu->array_index);
 }
 
 /* Recursively build graph for world */
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
index a18bb4dab6a..ecaece6a3ac 100644
--- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
+++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.h
@@ -99,6 +99,13 @@ struct DepsgraphNodeBuilder {
 	                                      const char *name = "",
 	                                      int name_tag = -1);
 
+	OperationDepsNode *ensure_operation_node(ID *id,
+	                                         eDepsNode_Type comp_type,
+	                                         const DepsEvalOperationCb& op,
+	                                         eDepsOperation_Code opcode,
+	                                         const char *name = "",
+	                                         int name_tag = -1);
+
 	bool has_operation_node(ID *id,
 	                        eDepsNode_Type comp_type,
 	                        const char *comp_name,



More information about the Bf-blender-cvs mailing list