[Bf-blender-cvs] [2c9603c] depsgraph_refactor: Depsgraph: Initial support of dupligroups

Sergey Sharybin noreply at git.blender.org
Thu Feb 12 14:15:04 CET 2015


Commit: 2c9603c28acdd3aa38dd9e109e54264cf0fa974e
Author: Sergey Sharybin
Date:   Thu Feb 12 18:07:59 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rB2c9603c28acdd3aa38dd9e109e54264cf0fa974e

Depsgraph: Initial support of dupligroups

This is an attempt to bring the dupligroups support at least on the same
level as they used to work in the old dependency graph. This means we don't
bother with local storage, time offset etc for now and building the group
graph in the same scene graph (as opposed t ideal sub-graph),

The reason for that is that it'll allow to have working system sooner,
and even such a simplified approach seems to have issues with updates.

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

M	source/blender/blenkernel/BKE_armature.h
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

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

diff --git a/source/blender/blenkernel/BKE_armature.h b/source/blender/blenkernel/BKE_armature.h
index 9f38e0e..ac1b11b 100644
--- a/source/blender/blenkernel/BKE_armature.h
+++ b/source/blender/blenkernel/BKE_armature.h
@@ -188,7 +188,7 @@ void BKE_pose_eval_flush(struct EvaluationContext *eval_ctx,
                          struct Object *ob,
                          struct bPose *pose);
 
-void BKE_pose_eval_proxy_copy(struct EvaluationContext *UNUSED(eval_ctx),
+void BKE_pose_eval_proxy_copy(struct EvaluationContext *eval_ctx,
                               struct Object *ob);
 
 #ifdef __cplusplus
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 9a7c9d4..8c04c18 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -77,7 +77,7 @@ struct DepsgraphNodeBuilder {
 
 	void build_scene(Main *bmain, Scene *scene);
 	SubgraphDepsNode *build_subgraph(Group *group);
-	void build_group(Group *group);
+	void build_group(Scene *scene, Base *base, Object *object, Group *group);
 	void build_object(Scene *scene, Base *base, Object *ob);
 	void build_object_transform(Scene *scene, Object *ob);
 	void build_object_constraints(Scene *scene, Object *ob);
@@ -232,6 +232,7 @@ struct DepsgraphRelationBuilder
 	                              eDepsRelation_Type type, const string &description);
 
 	void build_scene(Main *bmain, Scene *scene);
+	void build_group(Scene *scene, Object *object, Group *group);
 	void build_object(Scene *scene, Object *ob);
 	void build_object_parent(Object *ob);
 	void build_constraints(Scene *scene, ID *id, eDepsNode_Type component_type, const char *component_subdata,
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 0c60c18..b7ceb58 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -137,21 +137,9 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
 			build_object(scene, base, 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...
-		 */
+		/* Object dupligroup. */
 		if (ob->dup_group) {
-			ob->dup_group->id.flag |= LIB_DOIT;
-		}
-	}
-
-	/* tagged groups */
-	for (Group *group = (Group *)m_bmain->group.first; group; group = (Group *)group->id.next) {
-		if (group->id.flag & LIB_DOIT) {
-			// TODO: we need to make this group reliant on the object that spawned it...
-			build_subgraph(group);
+			build_group(scene, base, ob, ob->dup_group);
 		}
 	}
 
@@ -184,19 +172,22 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
 	}
 }
 
-/* Build depsgraph for the given group
- * This is usually used for building subgraphs for groups to use
- */
-void DepsgraphNodeBuilder::build_group(Group *group)
+void DepsgraphNodeBuilder::build_group(Scene *scene,
+                                       Base *base,
+                                       Object *object,
+                                       Group *group)
 {
-	/* add group objects */
-	for (GroupObject *go = (GroupObject *)group->gobject.first; go; go = go->next) {
-		/*Object *ob = go->ob;*/
+	ID *group_id = &group->id;
+	if (group_id->flag & LIB_DOIT) {
+		return;
+	}
+	group_id->flag |= LIB_DOIT;
 
-		/* Each "group object" is effectively a separate instance of the underlying
-		 * object data. When the group is evaluated, the transform results and/or
-		 * some other attributes end up getting overridden by the group
-		 */
+	for (GroupObject *go = (GroupObject *)group->gobject.first;
+	     go != NULL;
+	     go = go->next)
+	{
+		build_object(scene, base, go->ob);
 	}
 }
 
@@ -210,7 +201,19 @@ SubgraphDepsNode *DepsgraphNodeBuilder::build_subgraph(Group *group)
 	Depsgraph *subgraph = DEG_graph_new();
 
 	DepsgraphNodeBuilder subgraph_builder(m_bmain, subgraph);
-	subgraph_builder.build_group(group);
+
+	/* add group objects */
+	for (GroupObject *go = (GroupObject *)group->gobject.first;
+	     go != NULL;
+	     go = go->next)
+	{
+		/*Object *ob = go->ob;*/
+
+		/* Each "group object" is effectively a separate instance of the underlying
+		 * object data. When the group is evaluated, the transform results and/or
+		 * some other attributes end up getting overridden by the group
+		 */
+	}
 
 	/* create a node for representing subgraph */
 	SubgraphDepsNode *subgraph_node = m_graph->add_subgraph_node(&group->id);
@@ -225,6 +228,12 @@ SubgraphDepsNode *DepsgraphNodeBuilder::build_subgraph(Group *group)
 
 void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
 {
+	if (ob->id.flag & LIB_DOIT) {
+		IDDepsNode *id_node = m_graph->find_id_node(&ob->id);
+		id_node->layers = base->lay;
+		return;
+	}
+
 	IDDepsNode *id_node = add_id_node(&ob->id);
 	id_node->layers = base->lay;
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 71d6507..93cb2b8 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -185,28 +185,12 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
 			add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy");
 		}
 
-#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...
-		 */
+		/* Object dupligroup. */
 		if (ob->dup_group) {
-			id_tag_set(ob->dup_group);
+			build_group(scene, ob, 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);
-		}
-	}
-#endif
-
 	/* rigidbody */
 	if (scene->rigidbody_world) {
 		build_rigidbody(scene);
@@ -233,8 +217,37 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene)
 	}
 }
 
+void DepsgraphRelationBuilder::build_group(Scene *scene,
+                                           Object *object,
+                                           Group *group)
+{
+	ID *group_id = &group->id;
+	bool group_done = (group_id->flag & LIB_DOIT) != 0;
+	OperationKey object_local_transform_key(&object->id,
+	                                        DEPSNODE_TYPE_TRANSFORM,
+	                                        DEG_OPCODE_TRANSFORM_LOCAL);
+	for (GroupObject *go = (GroupObject *)group->gobject.first;
+	     go != NULL;
+	     go = go->next)
+	{
+		if (!group_done) {
+			build_object(scene, go->ob);
+		}
+		ComponentKey dupli_transform_key(&go->ob->id, DEPSNODE_TYPE_TRANSFORM);
+		add_relation(dupli_transform_key,
+		             object_local_transform_key,
+		             DEPSREL_TYPE_TRANSFORM,
+		             "Dupligroup");
+	}
+	group_id->flag |= LIB_DOIT;
+}
+
 void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
 {
+	if (ob->id.flag & LIB_DOIT) {
+		return;
+	}
+
 	/* Object Transforms */
 	eDepsOperation_Code base_op = (ob->parent) ? DEG_OPCODE_TRANSFORM_PARENT : DEG_OPCODE_TRANSFORM_LOCAL;
 	OperationKey base_op_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, base_op);




More information about the Bf-blender-cvs mailing list