[Bf-blender-cvs] [eb50caf] depsgraph_refactor: Depsgraph: Avoid duplicated relations from being created

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


Commit: eb50caf6ed285cc67c33f63a8546c860c479a05e
Author: Sergey Sharybin
Date:   Fri Feb 13 18:54:49 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBeb50caf6ed285cc67c33f63a8546c860c479a05e

Depsgraph: Avoid duplicated relations from being created

This is also not totally bad thing, but avoid duplicated relations
would help making depsgraph traversal more optimal at least. Plus
it'll give some memory save :)

Code which ensures there's no duplicated relations is commented out
still since IK solvers still needs more work for this.

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

M	source/blender/depsgraph/intern/depsgraph.cpp
M	source/blender/depsgraph/intern/depsgraph_build_relations.cpp

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

diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index 6baf6fb..cfb8b13 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -373,6 +373,24 @@ DepsRelation::DepsRelation(DepsNode *from,
 	this->name = description;
 	this->flag = 0;
 
+#ifndef NDEBUG
+/*
+	for (OperationDepsNode::Relations::const_iterator it = from->outlinks.begin();
+	     it != from->outlinks.end();
+	     ++it)
+	{
+		DepsRelation *rel = *it;
+		if (rel->from == from &&
+		    rel->to == to &&
+		    rel->type == type &&
+		    rel->name == description)
+		{
+			BLI_assert(!"Duplicated relation, should not happen!");
+		}
+	}
+*/
+#endif
+
 	/* Hook it up to the nodes which use it. */
 	from->outlinks.insert(this);
 	to->inlinks.insert(this);
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index c08eaeb..887df3b 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -1381,80 +1381,16 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
 {
 	ID *obdata = (ID *)ob->data;
 
+	/* Init operation of object-level geometry evaluation. */
+	OperationKey geom_init_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Init");
+
 	/* get nodes for result of obdata's evaluation, and geometry evaluation on object */
-	ComponentKey geom_key(&ob->id, DEPSNODE_TYPE_GEOMETRY);
 	ComponentKey obdata_geom_key(obdata, DEPSNODE_TYPE_GEOMETRY);
-
-	/* Link object data evaluation node to exit operation. */
-	OperationKey obdata_geom_eval_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Geometry Eval");
-	OperationKey obdata_geom_done_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Done");
-	add_relation(obdata_geom_eval_key, obdata_geom_done_key, DEPSREL_TYPE_DATABLOCK, "ObData Geom Eval Done");
+	ComponentKey geom_key(&ob->id, DEPSNODE_TYPE_GEOMETRY);
 
 	/* link components to each other */
 	add_relation(obdata_geom_key, geom_key, DEPSREL_TYPE_DATABLOCK, "Object Geometry Base Data");
 
-	/* Init operation of object-level geometry evaluation. */
-	OperationKey geom_init_key(&ob->id, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Init");
-
-	/* type-specific node/links */
-	switch (ob->type) {
-		case OB_MESH:
-			break;
-
-		case OB_MBALL:
-		{
-			Object *mom = BKE_mball_basis_find(scene, ob);
-
-			/* motherball - mom depends on children! */
-			if (mom != ob) {
-				/* non-motherball -> cannot be directly evaluated! */
-				ComponentKey mom_key(&mom->id, DEPSNODE_TYPE_GEOMETRY);
-				add_relation(geom_key, mom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Metaball Motherball");
-			}
-		}
-		break;
-
-		case OB_CURVE:
-		case OB_FONT:
-		{
-			Curve *cu = (Curve *)obdata;
-
-			/* curve's dependencies */
-			// XXX: these needs geom data, but where is geom stored?
-			if (cu->bevobj) {
-				ComponentKey bevob_key(&cu->bevobj->id, DEPSNODE_TYPE_GEOMETRY);
-				add_relation(bevob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Bevel");
-			}
-			if (cu->taperobj) {
-				ComponentKey taperob_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
-				add_relation(taperob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Taper");
-			}
-			if (ob->type == OB_FONT) {
-				if (cu->textoncurve) {
-					ComponentKey textoncurve_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
-					add_relation(textoncurve_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Text on Curve");
-				}
-			}
-		}
-		break;
-
-		case OB_SURF: /* Nurbs Surface */
-		{
-		}
-		break;
-
-		case OB_LATTICE: /* Lattice */
-		{
-		}
-		break;
-	}
-
-	/* ShapeKeys */
-	Key *key = BKE_key_from_object(ob);
-	if (key) {
-		build_shapekeys(obdata, key);
-	}
-
 	/* Modifiers */
 	if (ob->modifiers.first) {
 		ModifierData *md;
@@ -1520,6 +1456,75 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
 			add_relation(geom_init_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
 		}
 	}
+
+	if (obdata->flag & LIB_DOIT) {
+		return;
+	}
+	obdata->flag |= LIB_DOIT;
+
+	/* Link object data evaluation node to exit operation. */
+	OperationKey obdata_geom_eval_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Geometry Eval");
+	OperationKey obdata_geom_done_key(obdata, DEPSNODE_TYPE_GEOMETRY, DEG_OPCODE_PLACEHOLDER, "Eval Done");
+	add_relation(obdata_geom_eval_key, obdata_geom_done_key, DEPSREL_TYPE_DATABLOCK, "ObData Geom Eval Done");
+
+	/* type-specific node/links */
+	switch (ob->type) {
+		case OB_MESH:
+			break;
+
+		case OB_MBALL:
+		{
+			Object *mom = BKE_mball_basis_find(scene, ob);
+
+			/* motherball - mom depends on children! */
+			if (mom != ob) {
+				/* non-motherball -> cannot be directly evaluated! */
+				ComponentKey mom_key(&mom->id, DEPSNODE_TYPE_GEOMETRY);
+				add_relation(geom_key, mom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Metaball Motherball");
+			}
+		}
+		break;
+
+		case OB_CURVE:
+		case OB_FONT:
+		{
+			Curve *cu = (Curve *)obdata;
+
+			/* curve's dependencies */
+			// XXX: these needs geom data, but where is geom stored?
+			if (cu->bevobj) {
+				ComponentKey bevob_key(&cu->bevobj->id, DEPSNODE_TYPE_GEOMETRY);
+				add_relation(bevob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Bevel");
+			}
+			if (cu->taperobj) {
+				ComponentKey taperob_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
+				add_relation(taperob_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Curve Taper");
+			}
+			if (ob->type == OB_FONT) {
+				if (cu->textoncurve) {
+					ComponentKey textoncurve_key(&cu->taperobj->id, DEPSNODE_TYPE_GEOMETRY);
+					add_relation(textoncurve_key, geom_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Text on Curve");
+				}
+			}
+		}
+		break;
+
+		case OB_SURF: /* Nurbs Surface */
+		{
+		}
+		break;
+
+		case OB_LATTICE: /* Lattice */
+		{
+		}
+		break;
+	}
+
+	/* ShapeKeys */
+	Key *key = BKE_key_from_object(ob);
+	if (key) {
+		build_shapekeys(obdata, key);
+	}
 }
 
 /* Cameras */




More information about the Bf-blender-cvs mailing list