[Bf-blender-cvs] [ccf6ee2] depsgraph_refactor: Depsgraph: Fix missing curve path in certain situations

Sergey Sharybin noreply at git.blender.org
Mon Feb 16 13:07:30 CET 2015


Commit: ccf6ee273d0c157a340d6eb98681f129d2c4e555
Author: Sergey Sharybin
Date:   Mon Feb 16 17:03:35 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBccf6ee273d0c157a340d6eb98681f129d2c4e555

Depsgraph: Fix missing curve path in certain situations

Basically this is a quick re-implementation of evaluation flags we
had in the old dependency graph. I know it is not the real solution
but it's not so bad as well and would allow us continue nailing all
the other bugs with current granularity level before we go more
advanced.

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

M	source/blender/blenkernel/intern/depsgraph.c
M	source/blender/depsgraph/DEG_depsgraph_build.h
M	source/blender/depsgraph/DEG_depsgraph_query.h
M	source/blender/depsgraph/intern/depsgraph_build.cpp
M	source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M	source/blender/depsgraph/intern/depsgraph_query.cpp
M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h
M	source/blender/modifiers/intern/MOD_array.c
M	source/blender/modifiers/intern/MOD_curve.c

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

diff --git a/source/blender/blenkernel/intern/depsgraph.c b/source/blender/blenkernel/intern/depsgraph.c
index 7708304..f6e40af 100644
--- a/source/blender/blenkernel/intern/depsgraph.c
+++ b/source/blender/blenkernel/intern/depsgraph.c
@@ -3225,6 +3225,10 @@ short DAG_get_eval_flags_for_object(Scene *scene, void *object)
 {
 	DagNode *node;
 
+	if (!DEG_depsgraph_use_legacy()) {
+		return DEG_get_eval_flags_for_id(scene->depsgraph, (ID*)object);
+	}
+
 	if (scene->theDag == NULL) {
 		/* Happens when converting objects to mesh from a python script
 		 * after modifying scene graph.
@@ -3439,13 +3443,6 @@ const char *DAG_get_node_name(Scene *UNUSED(scene), void *UNUSED(node_v))
 	return "INVALID";
 }
 
-short DAG_get_eval_flags_for_object(Scene *UNUSED(scene),
-                                    void *UNUSED(object))
-{
-	BLI_assert(!"Should not be used with new dependnecy graph");
-	return 0;
-}
-
 bool DAG_is_acyclic(Scene *UNUSED(scene))
 {
 	BLI_assert(!"Should not be used with new dependnecy graph");
@@ -3538,6 +3535,11 @@ void DAG_ids_clear_recalc(Main *bmain)
 	DEG_ids_clear_recalc(bmain);
 }
 
+short DAG_get_eval_flags_for_object(Scene *scene, void *object)
+{
+	return DEG_get_eval_flags_for_id(scene->depsgraph, (ID*)object);
+}
+
 /* ************************ DAG DEBUGGING ********************* */
 
 void DAG_print_dependencies(Main *UNUSED(bmain),
diff --git a/source/blender/depsgraph/DEG_depsgraph_build.h b/source/blender/depsgraph/DEG_depsgraph_build.h
index 097b175..6049fa0 100644
--- a/source/blender/depsgraph/DEG_depsgraph_build.h
+++ b/source/blender/depsgraph/DEG_depsgraph_build.h
@@ -105,6 +105,9 @@ void DEG_add_scene_relation(struct DepsNodeHandle *node, struct Scene *scene, eD
 void DEG_add_object_relation(struct DepsNodeHandle *node, struct Object *ob, eDepsObjectComponentType component, const char *description);
 void DEG_add_bone_relation(struct DepsNodeHandle *handle, struct Object *ob, const char *bone_name, eDepsObjectComponentType component, const char *description);
 
+/* TODO(sergey): Remove once all geometry update is granular. */
+void DEG_add_special_eval_flag(struct Depsgraph *graph, struct ID *id, short flag);
+
 /* ************************************************ */
 
 #ifdef __cplusplus
diff --git a/source/blender/depsgraph/DEG_depsgraph_query.h b/source/blender/depsgraph/DEG_depsgraph_query.h
index f883a84..a7459be 100644
--- a/source/blender/depsgraph/DEG_depsgraph_query.h
+++ b/source/blender/depsgraph/DEG_depsgraph_query.h
@@ -181,6 +181,9 @@ size_t DEG_query_required_ids(struct ListBase *result, const struct ID *id, cons
 /* Check if given ID type was tagged for update. */
 bool DEG_id_type_tagged(struct Main *bmain, short idtype);
 
+/* Get additional evaluation flags for the given ID. */
+short DEG_get_eval_flags_for_id(struct Depsgraph *graph, struct ID *id);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp b/source/blender/depsgraph/intern/depsgraph_build.cpp
index c63baf5..a8a39b3 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -152,6 +152,20 @@ void DEG_add_bone_relation(DepsNodeHandle *handle, struct Object *ob, const char
 	handle->builder->add_node_handle_relation(comp_key, handle, DEPSREL_TYPE_GEOMETRY_EVAL, string(description));
 }
 
+void DEG_add_special_eval_flag(Depsgraph *graph, ID *id, short flag)
+{
+	if (graph == NULL) {
+		BLI_assert(!"Graph should always be valid");
+		return;
+	}
+	IDDepsNode *id_node = graph->find_id_node(id);
+	if (id_node == NULL) {
+		BLI_assert(!"ID should always be valid");
+		return;
+	}
+	id_node->eval_flags |= flag;
+}
+
 /* ************************************************* */
 /* Utilities for Builders */
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index 51dec11..4e77157 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -64,6 +64,7 @@ extern "C" {
 #include "BKE_animsys.h"
 #include "BKE_constraint.h"
 #include "BKE_curve.h"
+#include "BKE_depsgraph.h"
 #include "BKE_effect.h"
 #include "BKE_fcurve.h"
 #include "BKE_group.h"
@@ -243,7 +244,6 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
 	/* AnimData */
 	build_animdata(&ob->id);
 
-
 	/* object data */
 	if (ob->data) {
 		ID *obdata = (ID *)ob->data;
@@ -260,6 +260,15 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Base *base, Object *ob)
 			case OB_LATTICE:
 			{
 				build_obdata_geom(scene, ob);
+				/* TODO(sergey): Only for until we support granular
+				 * update of curves.
+				 */
+				if (ob->type == OB_FONT) {
+					Curve *curve = (Curve *)ob->data;
+					if (curve->textoncurve) {
+						id_node->eval_flags |= DAG_EVAL_NEED_CURVE_PATH;
+					}
+				}
 			}
 			break;
 
diff --git a/source/blender/depsgraph/intern/depsgraph_query.cpp b/source/blender/depsgraph/intern/depsgraph_query.cpp
index 277d647..86e0e20 100644
--- a/source/blender/depsgraph/intern/depsgraph_query.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_query.cpp
@@ -188,3 +188,24 @@ bool DEG_id_type_tagged(Main *bmain, short idtype)
 {
 	return bmain->id_tag_update[((unsigned char *)&idtype)[0]] != 0;
 }
+
+short DEG_get_eval_flags_for_id(Depsgraph *graph, ID *id)
+{
+	if (graph == NULL) {
+		/* Happens when converting objects to mesh from a python script
+		 * after modifying scene graph.
+		 *
+		 * Currently harmless because it's only called for temporary
+		 * objects which are out of the DAG anyway.
+		 */
+		return 0;
+	}
+
+	IDDepsNode *id_node = graph->find_id_node(id);
+	if (id_node == NULL) {
+		/* TODO(sergey): Does it mean we need to check set scene? */
+		return 0;
+	}
+
+	return id_node->eval_flags;
+}
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index cc964b1..c618d54 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -142,6 +142,7 @@ void IDDepsNode::init(const ID *id, const string &UNUSED(subdata))
 	BLI_assert(id != NULL);
 	this->id = (ID *)id;
 	this->layers = (1 << 20) - 1;
+	this->eval_flags = 0;
 
 	/* NOTE: components themselves are created if/when needed.
 	 * This prevents problems with components getting added
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 96d7c04..1dd1379 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -191,6 +191,12 @@ struct IDDepsNode : public DepsNode {
 	/* Layers of this node with accumulated layers of it's output relations. */
 	int layers;
 
+	/* Additional flags needed for scene evaluation.
+	 * TODO(sergey): Only needed for until really granual updates
+	 * of all the entities.
+	 */
+	int eval_flags;
+
 	DEG_DEPSNODE_DECLARE;
 };
 
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 3b7150f..53390d4 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -134,7 +134,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
 }
 
 static void updateDepsgraph(ModifierData *md,
-                            struct Scene *UNUSED(scene),
+                            struct Scene *scene,
                             Object *UNUSED(ob),
                             struct DepsNodeHandle *node)
 {
@@ -146,10 +146,8 @@ static void updateDepsgraph(ModifierData *md,
 		DEG_add_object_relation(node, amd->end_cap, DEG_OB_COMP_TRANSFORM, "Hook Modifier End Cap");
 	}
 	if (amd->curve_ob) {
-		/* TODO(sergey): Need to do the same eval_flags trick for path
-		 * as happening in legacy depsgraph callback.
-		 */
 		DEG_add_object_relation(node, amd->end_cap, DEG_OB_COMP_GEOMETRY, "Hook Modifier Curve");
+		DEG_add_special_eval_flag(scene->depsgraph, &amd->curve_ob->id, DAG_EVAL_NEED_CURVE_PATH);
 	}
 	if (amd->offset_ob != NULL) {
 		DEG_add_object_relation(node, amd->offset_ob, DEG_OB_COMP_TRANSFORM, "Hook Modifier Offset");
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index 372c495..2fa9aca 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -109,7 +109,7 @@ static void updateDepgraph(ModifierData *md, DagForest *forest,
 }
 
 static void updateDepsgraph(ModifierData *md,
-                            struct Scene *UNUSED(scene),
+                            struct Scene *scene,
                             Object *UNUSED(ob),
                             struct DepsNodeHandle *node)
 {
@@ -122,6 +122,7 @@ static void updateDepsgraph(ModifierData *md,
 		 * might be changed in the future.
 		 */
 		DEG_add_object_relation(node, cmd->object, DEG_OB_COMP_GEOMETRY, "Curve Modifier");
+		DEG_add_special_eval_flag(scene->depsgraph, &cmd->object->id, DAG_EVAL_NEED_CURVE_PATH);
 	}
 }




More information about the Bf-blender-cvs mailing list