[Bf-blender-cvs] [0e8246f] depsgraph_refactor: Splitting off main construction logic from depsgraph_build.cpp.

Lukas Tönne noreply at git.blender.org
Wed Apr 9 14:12:40 CEST 2014


Commit: 0e8246f8a0c0517d455f3a5e877c2bce7c581817
Author: Lukas Tönne
Date:   Wed Apr 9 14:01:43 2014 +0200
https://developer.blender.org/rB0e8246f8a0c0517d455f3a5e877c2bce7c581817

Splitting off main construction logic from depsgraph_build.cpp.

The original source file now only contains general functions for the
builder classes. The actual logic for building the nodes/relations from
a scene is in depsgraph_build_nodes/depsgraph_build_relations now. This
helps navigation and keeps the code in those files concerned only with
the actual inspection of DNA data.

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

M	source/blender/depsgraph/CMakeLists.txt
M	source/blender/depsgraph/intern/depsgraph_build.cpp
A	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
A	source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M	source/blender/depsgraph/util/depsgraph_util_rna.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt
index 7ac560c..71f9943 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -45,6 +45,8 @@ set(SRC
 	intern/depsnode_component.cpp
 	intern/depsnode_operation.cpp
 	intern/depsgraph_build.cpp
+	intern/depsgraph_build_nodes.cpp
+	intern/depsgraph_build_relations.cpp
 	intern/depsgraph_core.cpp
 	intern/depsgraph_debug.cpp
 	intern/depsgraph_eval.cpp
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 85e0b74..fbe903e 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -158,21 +158,6 @@ void DEG_add_object_relation(DepsNodeHandle *handle, struct Object *ob, eDepsObj
 /* ************************************************* */
 /* Node Builder */
 
-static bool is_id_tagged(ConstIDPtr id)
-{
-	return id->flag & LIB_DOIT;
-}
-
-static void id_tag_set(IDPtr id)
-{
-	id->flag |= LIB_DOIT;
-}
-
-static void id_tag_clear(IDPtr id)
-{
-	id->flag &= ~LIB_DOIT;
-}
-
 DepsgraphNodeBuilder::DepsgraphNodeBuilder(Main *bmain, Depsgraph *graph) :
     m_bmain(bmain),
     m_graph(graph)
@@ -253,264 +238,6 @@ OperationDepsNode *DepsgraphNodeBuilder::add_operation_node(ComponentDepsNode *c
 	return op_node;
 }
 
-IDDepsNode *DepsgraphNodeBuilder::build_scene(Scene *scene)
-{
-	IDDepsNode *scene_node = add_id_node(scene);
-	/* timesource */
-	add_time_source(scene);
-	
-	/* build subgraph for set, and link this in... */
-	// XXX: depending on how this goes, that scene itself could probably store its
-	//      own little partial depsgraph?
-	if (scene->set) {
-		build_scene(scene->set);
-	}
-	
-	/* scene objects */
-	for (Base *base = (Base *)scene->base.first; base; base = base->next) {
-		Object *ob = base->object;
-		
-		/* object itself */
-		build_object(ob);
-		
-		/* object that this is a proxy for */
-		// XXX: the way that proxies work needs to be completely reviewed!
-		if (ob->proxy) {
-			build_object(ob->proxy);
-		}
-		
-		/* handled in next loop... 
-		 * NOTE: in most cases, setting dupli-group means that we may want
-		 *       to instance existing data and/or reuse it with very few
-		 *       modifications...
-		 */
-		if (ob->dup_group) {
-			id_tag_set(ob->dup_group);
-		}
-	}
-	
-	/* tagged groups */
-	for (Group *group = (Group *)m_bmain->group.first; group; group = (Group *)group->id.next) {
-		if (is_id_tagged(group)) {
-			// TODO: we need to make this group reliant on the object that spawned it...
-			build_subgraph(group);
-			
-			id_tag_clear(group);
-		}
-	}
-	
-	/* rigidbody */
-	if (scene->rigidbody_world) {
-		build_rigidbody(scene);
-	}
-	
-	/* scene's animation and drivers */
-	if (scene->adt) {
-		build_animdata(scene_node);
-	}
-	
-	/* world */
-	if (scene->world) {
-		build_world(scene, scene->world);
-	}
-	
-	/* compo nodes */
-	if (scene->nodetree) {
-		build_compositor(scene);
-	}
-	
-	/* sequencer */
-	// XXX...
-	
-	return scene_node;
-}
-
-SubgraphDepsNode *DepsgraphNodeBuilder::build_subgraph(Group *group)
-{
-	
-}
-
-IDDepsNode *DepsgraphNodeBuilder::build_object(Object *ob)
-{
-	/* create node for object itself */
-	IDDepsNode *ob_node = add_id_node(ob);
-	
-	/* standard components */
-	ComponentDepsNode *params_node = add_component_node(ob_node, DEPSNODE_TYPE_OP_PARAMETER);
-	ComponentDepsNode *trans_node = build_object_transform(ob, ob_node);
-	
-	/* AnimData */
-	build_animdata(ob_node);
-	
-	/* object parent */
-	if (ob->parent) {
-		add_operation_node(trans_node, DEPSNODE_TYPE_OP_TRANSFORM, 
-		                   DEPSOP_TYPE_EXEC, BKE_object_eval_parent,
-		                   "BKE_object_eval_parent", make_rna_id_pointer(ob));
-	}
-	
-	/* object constraints */
-	if (ob->constraints.first) {
-		build_constraints(trans_node, DEPSNODE_TYPE_OP_TRANSFORM);
-	}
-	
-	/* object data */
-	if (ob->data) {
-		ID *obdata_id = (ID *)ob->data;
-		IDDepsNode *obdata_node = NULL;
-		
-#if 0
-		/* type-specific data... */
-		switch (ob->type) {
-			case OB_MESH:     /* Geometry */
-			case OB_CURVE:
-			case OB_FONT:
-			case OB_SURF:
-			case OB_MBALL:
-			case OB_LATTICE:
-			{
-				deg_build_obdata_geom_graph(graph, scene, ob);
-			}
-			break;
-			
-			
-			case OB_ARMATURE: /* Pose */
-				deg_build_rig_graph(graph, scene, ob);
-				break;
-			
-			
-			case OB_LAMP:   /* Lamp */
-				deg_build_lamp_graph(graph, scene, ob);
-				break;
-				
-			case OB_CAMERA: /* Camera */
-				deg_build_camera_graph(graph, scene, ob);
-				break;
-		}
-#endif
-		
-		if (obdata_node) {
-			/* ob data animation */
-			build_animdata(obdata_node);
-		}
-	}
-	
-#if 0
-	/* particle systems */
-	if (ob->particlesystem.first) {
-		deg_build_particles_graph(graph, scene, ob);
-	}
-#endif
-	
-	/* return object node... */
-	return ob_node;
-}
-
-ComponentDepsNode *DepsgraphNodeBuilder::build_object_transform(Object *ob, IDDepsNode *ob_node)
-{
-	/* component to hold all transform operations */
-	ComponentDepsNode *trans_node = add_component_node(ob_node, DEPSNODE_TYPE_TRANSFORM);
-	
-	/* init operation */
-	add_operation_node(trans_node, DEPSNODE_TYPE_OP_TRANSFORM,
-	                   DEPSOP_TYPE_INIT, BKE_object_eval_local_transform,
-	                   "BKE_object_eval_local_transform", make_rna_id_pointer(ob));
-	
-	/* return component created */
-	return trans_node;
-}
-
-void DepsgraphNodeBuilder::build_constraints(ComponentDepsNode *comp_node, eDepsNode_Type constraint_op_type)
-{
-	/* == Constraints Graph Notes ==
-	 * For constraints, we currently only add a operation node to the Transform
-	 * or Bone components (depending on whichever type of owner we have).
-	 * This represents the entire constraints stack, which is for now just
-	 * executed as a single monolithic block. At least initially, this should
-	 * be sufficient for ensuring that the porting/refactoring process remains
-	 * manageable. 
-	 * 
-	 * However, when the time comes for developing "node-based" constraints,
-	 * we'll need to split this up into pre/post nodes for "constraint stack
-	 * evaluation" + operation nodes for each constraint (i.e. the contents
-	 * of the loop body used in the current "solve_constraints()" operation).
-	 *
-	 * -- Aligorith, August 2013 
-	 */
-	
-	/* create node for constraint stack */
-	add_operation_node(comp_node, constraint_op_type, 
-	                   DEPSOP_TYPE_EXEC, BKE_constraints_evaluate,
-	                   deg_op_name_constraint_stack, make_rna_id_pointer(comp_node->owner->id));
-}
-
-void DepsgraphNodeBuilder::build_rigidbody(Scene *scene)
-{
-	
-}
-
-/* Build graph nodes for AnimData block 
- * < scene_node: Scene that ID-block this lives on belongs to
- * < id: ID-Block which hosts the AnimData
- */
-void DepsgraphNodeBuilder::build_animdata(IDDepsNode *id_node)
-{
-	AnimData *adt = BKE_animdata_from_id(id_node->id);
-	if (!adt)
-		return;
-	
-	/* animation */
-	if (adt->action || adt->nla_tracks.first || adt->drivers.first) {
-		/* create "animation" data node for this block */
-		ComponentDepsNode *adt_node = add_component_node(id_node, DEPSNODE_TYPE_ANIMATION);
-		
-		// XXX: Hook up specific update callbacks for special properties which may need it...
-		
-		/* drivers */
-		for (FCurve *fcu = (FCurve *)adt->drivers.first; fcu; fcu = fcu->next) {
-			/* create driver */
-			/*OperationDepsNode *driver_node =*/ build_driver(adt_node, fcu);
-			
-			/* hook up update callback associated with F-Curve */
-			// ...
-		}
-	}
-}
-
-/* Build graph node(s) for Driver
- * < id: ID-Block that driver is attached to
- * < fcu: Driver-FCurve
- */
-OperationDepsNode *DepsgraphNodeBuilder::build_driver(ComponentDepsNode *adt_node, FCurve *fcurve)
-{
-	IDPtr id = adt_node->owner->id;
-	ChannelDriver *driver = fcurve->driver;
-	
-	/* create data node for this driver ..................................... */
-	OperationDepsNode *driver_op = add_operation_node(adt_node, DEPSNODE_TYPE_OP_DRIVER,
-	                                                  DEPSOP_TYPE_EXEC, BKE_animsys_eval_driver,
-	                                                  deg_op_name_driver(driver),
-	                                                  make_rna_pointer(id, &RNA_FCurve, fcurve));
-	
-	/* tag "scripted expression" drivers as needing Python (due to GIL issues, etc.) */
-	if (driver->type == DRIVER_TYPE_PYTHON) {
-		driver_op->flag |= DEPSOP_FLAG_USES_PYTHON;
-	}
-	
-	/* return driver node created */
-	return driver_op;
-}
-
-void DepsgraphNodeBuilder::build_world(Scene *scene, World *world)
-{
-	
-}
-
-void DepsgraphNodeBuilder::build_compositor(Scene *scene)
-{
-	
-}
-
 /* ************************************************* */
 /* Relations Builder */
 
@@ -596,359 +323,6 @@ void DepsgraphRelationBuilder::add_node_relation(DepsNode *node_from, DepsNode *
 	m_graph->add_new_relation(node_from, node_to, type, description);
 }
 
-void DepsgraphRelationBuilder::build_scene(Scene *scene)
-{
-	if (scene->set) {
-		// TODO: link set to scene, especially our timesource...
-	}
-	
-	/* scene objects */
-	for (Base *base = (Base *)scene->base.first; base; base = base->next) {
-		Object *ob = base->object;
-		
-		/* object itself */
-		build_object(scene, ob);
-		
-#if 0
-		/* object that this is a proxy for */
-		// XXX: the way that proxies work needs to be completely reviewed!
-		if (ob->proxy) {
-			build_object(scene, ob->proxy);
-		}
-#endif
-		
-#if 0
-		/* handled in next loop... 
-		 * NOTE: in most cases, setting dupli-group means that we may want
-		 *       to instance existing data and/or reuse it with very few
-		 *       modifications...
-		 */
-		if (ob->dup_group) {
-			id_tag_set(ob->dup_group);
-		}
-#endif
-	}
-	
-#if 0
-	/* tagged groups */
-	for (Group *group = (Group *)m_bmain->group.first; group; group = (Group *)group->id.next) {
-		if (is_id_tagged(group)) {
-			// TODO: we need to make this group reliant on the object that spawned it...
-			build_subgraph_nodes(group);
-			
-			id_tag_clear(group);
-		}
-	}
-#endif
-}
-
-void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
-{
-	if (ob->parent)
-		build_object_parent(ob);
-	
-	/* AnimData */
-	bui

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list