[Bf-blender-cvs] [adb9f25] depsgraph_refactor: Removed the build_operations methods and OperationBuilder class again.

Lukas Tönne noreply at git.blender.org
Tue May 13 18:41:10 CEST 2014


Commit: adb9f252bca0cea9423cb8f81a5724158fe5f6d3
Author: Lukas Tönne
Date:   Tue May 13 10:57:30 2014 +0200
https://developer.blender.org/rBadb9f252bca0cea9423cb8f81a5724158fe5f6d3

Removed the build_operations methods and OperationBuilder class again.

The few places where this has been used (pose and bone components) have
been integrated into the regular build functions.

Eventually we may want to do dispatching like this again, but for the
time being it's easier to keep these things in a central place until it
is clear how the build procedure is best organized.

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

M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph.h
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/depsgraph_build_relations.cpp
M	source/blender/depsgraph/intern/depsgraph_type_defines.cpp
M	source/blender/depsgraph/intern/depsgraph_types.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.h

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index c496e67..920e0b1 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -209,14 +209,6 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, OperationDeps
 	return rel;
 }
 
-void Depsgraph::build_operations(const OperationBuilder &builder) const
-{
-	for (Depsgraph::IDNodeMap::const_iterator it = this->id_hash.begin(); it != this->id_hash.end(); ++it) {
-		DepsNode *node = it->second;
-		node->build_operations(builder);
-	}
-}
-
 /* Sort nodes to determine evaluation order for operation nodes
  * where dependency relationships won't get violated.
  */
diff --git a/source/blender/depsgraph/intern/depsgraph.h b/source/blender/depsgraph/intern/depsgraph.h
index b07edb8..808f338 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -56,8 +56,6 @@ struct SubgraphDepsNode;
 struct ComponentDepsNode;
 struct OperationDepsNode;
 
-struct OperationBuilder;
-
 
 /* ************************************* */
 /* Relationships Between Nodes */
@@ -142,8 +140,6 @@ struct Depsgraph {
 	                               eDepsRelation_Type type, 
 	                               const string &description);
 	
-	void build_operations(const OperationBuilder &builder) const;
-	
 	/* Sort nodes to determine evaluation order for operation nodes
 	 * where dependency relationships won't get violated.
 	 */
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 23bb6be..78b60c2 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -236,30 +236,6 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(IDDepsNode *id_node,
 
 
 /* ************************************************* */
-/* Operation Builder */
-
-OperationBuilder::OperationBuilder(Depsgraph *graph) :
-    m_graph(graph)
-{
-}
-
-OperationDepsNode *OperationBuilder::add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type, eDepsOperation_Type optype,
-                                                        DepsEvalOperationCb op, const string &description,
-                                                        PointerRNA ptr) const
-{
-	OperationDepsNode *op_node = comp_node->add_operation(type, optype, op, description);
-	op_node->ptr = ptr;
-	return op_node;
-}
-
-void OperationBuilder::add_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
-                                    eDepsRelation_Type type, const string &description) const
-{
-	m_graph->add_new_relation(node_from, node_to, type, description);
-}
-
-
-/* ************************************************* */
 /* Relations Builder */
 
 RNAPathKey::RNAPathKey(IDPtr id, const string &path) :
@@ -384,10 +360,6 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
 	relation_builder.add_relation(RootKey(), IDKey(scene), DEPSREL_TYPE_ROOT_TO_ACTIVE, "Root to Active Scene");
 	relation_builder.build_scene(scene);
 	
-	/* add internal nodes (operations) for all components */
-	OperationBuilder op_builder(graph);
-	graph->build_operations(op_builder);
-	
 #if 0
 	/* sort nodes to determine evaluation order (in most cases) */
 	DEG_graph_sort(graph);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 5db7771..6f1ca14 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -103,20 +103,6 @@ private:
 	Depsgraph *m_graph;
 };
 
-struct OperationBuilder {
-	OperationBuilder(Depsgraph *graph);
-	
-	OperationDepsNode *add_operation_node(ComponentDepsNode *comp_node, eDepsNode_Type type, eDepsOperation_Type optype,
-	                                      DepsEvalOperationCb op, const string &description,
-	                                      PointerRNA ptr) const;
-	
-	void add_relation(OperationDepsNode *node_from, OperationDepsNode *node_to,
-	                  eDepsRelation_Type type, const string &description) const;
-	
-private:
-	Depsgraph *m_graph;
-};
-
 struct RootKey
 {
 	RootKey() {}
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 158cce6..5aac136 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -585,10 +585,20 @@ void DepsgraphNodeBuilder::build_rig(IDDepsNode *ob_node, Object *ob)
 	 */
 	// TODO: rest pose/editmode handling!
 	
-	/* pose eval context 
-	 * NOTE: init/cleanup steps for this are handled as part of the node's code
-	 */
-	/*PoseComponentDepsNode *pose_node = (PoseComponentDepsNode *)*/add_component_node(ob_node, DEPSNODE_TYPE_EVAL_POSE);
+	/* pose eval context */
+	PoseComponentDepsNode *pose_node = (PoseComponentDepsNode *)add_component_node(ob_node, DEPSNODE_TYPE_EVAL_POSE);
+	
+	add_operation_node(pose_node, DEPSNODE_TYPE_OP_POSE,
+	                   DEPSOP_TYPE_REBUILD, BKE_pose_rebuild_op, deg_op_name_pose_rebuild,
+	                   make_rna_pointer(ob, &RNA_Pose, ob->pose));
+	
+	add_operation_node(pose_node, DEPSNODE_TYPE_OP_POSE,
+	                   DEPSOP_TYPE_INIT, BKE_pose_eval_init, deg_op_name_pose_eval_init,
+	                   make_rna_pointer(ob, &RNA_Pose, ob->pose));
+	
+	add_operation_node(pose_node, DEPSNODE_TYPE_OP_POSE,
+	                   DEPSOP_TYPE_POST, BKE_pose_eval_flush, deg_op_name_pose_eval_flush,
+	                   make_rna_pointer(ob, &RNA_Pose, ob->pose));
 	
 	/* bones */
 	for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index c01ed43..1b85c13 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -714,6 +714,14 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
 	// TODO: we need a bit of an exception here to redirect drivers to posebones?
 	build_animdata(arm);
 	
+	/* attach links between base operations */
+	OperationKey rebuild_key(ob, DEPSNODE_TYPE_EVAL_POSE, deg_op_name_pose_rebuild);
+	OperationKey init_key(ob, DEPSNODE_TYPE_EVAL_POSE, deg_op_name_pose_eval_init);
+	OperationKey flush_key(ob, DEPSNODE_TYPE_EVAL_POSE, deg_op_name_pose_eval_flush);
+	
+	add_relation(rebuild_key, init_key, DEPSREL_TYPE_COMPONENT_ORDER, "[Pose Rebuild -> Pose Init] DepsRel");
+	add_relation(init_key, flush_key, DEPSREL_TYPE_COMPONENT_ORDER, "[Pose Init -> Pose Cleanup] DepsRel");
+	
 	/* bones */
 	for (bPoseChannel *pchan = (bPoseChannel *)ob->pose->chanbase.first; pchan; pchan = pchan->next) {
 		ComponentKey bone_key(ob, DEPSNODE_TYPE_BONE, pchan->name);
@@ -723,6 +731,10 @@ void DepsgraphRelationBuilder::build_rig(Scene *scene, Object *ob)
 			ComponentKey parent_key(ob, DEPSNODE_TYPE_BONE, pchan->parent->name);
 			add_relation(parent_key, bone_key, DEPSREL_TYPE_TRANSFORM, "[Parent Bone -> Child Bone]");
 		}
+		else {
+			/* link bone/component to pose "sources" if it doesn't have any obvious dependencies */
+			add_relation(init_key, bone_key, DEPSREL_TYPE_OPERATION, "PoseEval Source-Bone Link");
+		}
 		
 		/* constraints */
 		build_constraints(scene, ob, pchan->name, DEPSNODE_TYPE_OP_BONE, &pchan->constraints);
diff --git a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
index 3368140..95ca9d2 100644
--- a/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_type_defines.cpp
@@ -94,6 +94,9 @@ const string deg_op_name_constraint_stack = "Constraint Stack";
 const string deg_op_name_rigidbody_world_rebuild = "Rigidbody World Rebuild";
 const string deg_op_name_rigidbody_world_simulate = "Rigidbody World Do Simulation";
 const string deg_op_name_rigidbody_object_sync = "RigidBodyObject Sync";
+const string deg_op_name_pose_rebuild = "Rebuild Pose";
+const string deg_op_name_pose_eval_init = "Init Pose Eval";
+const string deg_op_name_pose_eval_flush = "Flush Pose Eval";
 const string deg_op_name_ik_solver = "IK Solver";
 const string deg_op_name_spline_ik_solver = "Spline IK Solver";
 const string deg_op_name_psys_eval = "PSys Eval";
diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h
index 938b298..57fd8d8 100644
--- a/source/blender/depsgraph/intern/depsgraph_types.h
+++ b/source/blender/depsgraph/intern/depsgraph_types.h
@@ -108,6 +108,9 @@ extern const string deg_op_name_constraint_stack;
 extern const string deg_op_name_rigidbody_world_rebuild;
 extern const string deg_op_name_rigidbody_world_simulate;
 extern const string deg_op_name_rigidbody_object_sync;
+extern const string deg_op_name_pose_rebuild;
+extern const string deg_op_name_pose_eval_init;
+extern const string deg_op_name_pose_eval_flush;
 extern const string deg_op_name_ik_solver;
 extern const string deg_op_name_spline_ik_solver;
 extern const string deg_op_name_psys_eval;
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index 3db7a44..a35253b 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -82,22 +82,11 @@ TimeSourceDepsNode *RootDepsNode::add_time_source(const string &name)
 	return time_source;
 }
 
-void RootDepsNode::build_operations(const OperationBuilder &builder)
-{
-	if (time_source)
-		time_source->build_operations(builder);
-}
-
 DEG_DEPSNODE_DEFINE(RootDepsNode, DEPSNODE_TYPE_ROOT, "Root DepsNode");
 static DepsNodeFactoryImpl<RootDepsNode> DNTI_ROOT;
 
 /* Time Source Node ======================================= */
 
-void TimeSourceDepsNode::build_operations(const OperationBuilder &builder)
-{
-	/* TODO */
-}
-
 DEG_DEPSNODE_DEFINE(TimeSourceDepsNode, DEPSNODE_TYPE_TIMES

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list