[Bf-blender-cvs] [d33f458] depsgraph_refactor: Depsgraph: Cleanup of time source relation a bit
Sergey Sharybin
noreply at git.blender.org
Wed Nov 12 13:51:24 CET 2014
Commit: d33f458e2c04cb6a236ea1a128223b715382550a
Author: Sergey Sharybin
Date: Wed Nov 12 13:50:05 2014 +0100
Branches: depsgraph_refactor
https://developer.blender.org/rBd33f458e2c04cb6a236ea1a128223b715382550a
Depsgraph: Cleanup of time source relation a bit
This way it is now possible to add a relation between TimeSourceKey and
OperationKey.
Some areas were trying to add such a relation already, but it just didn't
work.
Not totally happy with the implementation, but think the patch is good
enough for the first cleanup iteration.
===================================================================
M source/blender/depsgraph/intern/depsgraph.cpp
M source/blender/depsgraph/intern/depsgraph.h
M source/blender/depsgraph/intern/depsgraph_build.h
M source/blender/depsgraph/intern/depsgraph_build_relations.cpp
M source/blender/depsgraph/intern/depsgraph_debug.cpp
M source/blender/depsgraph/intern/depsnode.cpp
M source/blender/depsgraph/intern/depsnode.h
===================================================================
diff --git a/source/blender/depsgraph/intern/depsgraph.cpp b/source/blender/depsgraph/intern/depsgraph.cpp
index a66c21c..3e6b1a8 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -253,13 +253,6 @@ DepsRelation *Depsgraph::add_new_relation(OperationDepsNode *from, OperationDeps
return rel;
}
-/* Add new dependency between outer ID node and time. */
-void Depsgraph::add_new_time_relation(IDDepsNode *from)
-{
- TimeSourceDepsNode *time_src = find_time_source();
- time_src->add_time_dependency(from);
-}
-
/* 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 715086e..727ec0b 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -142,9 +142,6 @@ struct Depsgraph {
eDepsRelation_Type type,
const string &description);
- /* Add new dependency between outer ID node and time. */
- void add_new_time_relation(IDDepsNode *from);
-
/* 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.h b/source/blender/depsgraph/intern/depsgraph_build.h
index 3049d2f..19843f4 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -211,7 +211,11 @@ struct DepsgraphRelationBuilder {
template <typename KeyFrom, typename KeyTo>
void add_relation(const KeyFrom &key_from, const KeyTo &key_to,
eDepsRelation_Type type, const string &description);
-
+
+ template <typename KeyTo>
+ void add_relation(const TimeSourceKey &key_from, const KeyTo &key_to,
+ eDepsRelation_Type type, const string &description);
+
template <typename KeyType>
void add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle,
eDepsRelation_Type type, const string &description);
@@ -310,6 +314,19 @@ void DepsgraphRelationBuilder::add_relation(const KeyFrom &key_from, const KeyTo
}
}
+template <typename KeyTo>
+void DepsgraphRelationBuilder::add_relation(const TimeSourceKey &key_from, const KeyTo &key_to,
+ eDepsRelation_Type type, const string &description)
+{
+ BLI_assert(type == DEPSREL_TYPE_TIME);
+ TimeSourceDepsNode *time_from = find_node(key_from);
+ OperationDepsNode *op_to = get_entry_operation(find_node(key_to));
+ if (time_from && op_to) {
+ /* TODO(sergey): Store description as well. */
+ time_from->add_new_relation(op_to);
+ }
+}
+
template <typename KeyType>
void DepsgraphRelationBuilder::add_node_handle_relation(const KeyType &key_from, const DepsNodeHandle *handle,
eDepsRelation_Type type, const string &description)
diff --git a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
index 1644995..07523f9 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_relations.cpp
@@ -102,32 +102,28 @@ extern "C" {
#include "stubs.h" // XXX: REMOVE THIS INCLUDE ONCE DEPSGRAPH REFACTOR PROJECT IS DONE!!!
/* TODO(sergey): This is a stupid copy of function from depsgraph.c/ */
-static bool object_modifiers_use_time(Object *ob)
+static bool modifier_check_depends_on_time(Object *ob, ModifierData *md)
{
- ModifierData *md;
-
- /* check if a modifier in modifier stack needs time input */
- for (md = (ModifierData *)ob-> modifiers.first;
- md != NULL;
- md = (ModifierData *)md->next)
- {
- if (modifier_dependsOnTime(md)) {
- return true;
- }
+ if (modifier_dependsOnTime(md)) {
+ return true;
}
- /* check whether any modifiers are animated */
+ /* Check whether modifier is animated. */
if (ob->adt) {
AnimData *adt = ob->adt;
FCurve *fcu;
+ char pattern[MAX_NAME + 10];
+ /* TODO(sergey): Escape modifier name. */
+ BLI_snprintf(pattern, sizeof(pattern), "modifiers[%s", md->name);
+
/* action - check for F-Curves with paths containing 'modifiers[' */
if (adt->action) {
for (fcu = (FCurve *)adt->action->curves.first;
fcu != NULL;
fcu = (FCurve *)fcu->next)
{
- if (fcu->rna_path && strstr(fcu->rna_path, "modifiers["))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern))
return true;
}
}
@@ -142,7 +138,7 @@ static bool object_modifiers_use_time(Object *ob)
fcu != NULL;
fcu = (FCurve *)fcu->next)
{
- if (fcu->rna_path && strstr(fcu->rna_path, "modifiers["))
+ if (fcu->rna_path && strstr(fcu->rna_path, pattern))
return true;
}
@@ -204,15 +200,6 @@ void DepsgraphRelationBuilder::build_scene(Scene *scene)
void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
{
- /* TODO(sergey): This is mainly for the testing purposes, in the final
- * design we'll need to add relation between individual component to the
- * time source.
- */
- if (object_modifiers_use_time(ob)) {
- /* TODO(sergey): Replace with time relation. */
- m_graph->add_new_time_relation(m_graph->find_id_node(&ob->id));
- }
-
if (ob->parent)
build_object_parent(ob);
@@ -272,6 +259,12 @@ void DepsgraphRelationBuilder::build_object(Scene *scene, Object *ob)
build_particles(scene, ob);
}
+ if (ob->adt) {
+ ComponentKey adt_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
+ ComponentKey transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
+ add_relation(adt_key, local_transform_key, DEPSREL_TYPE_OPERATION, "Object Animation");
+ }
+
/* TODO(sergey): This is a temp solution for now only/ */
ComponentKey transform_key(&ob->id, DEPSNODE_TYPE_TRANSFORM);
ComponentKey geometry_key(&ob->id, DEPSNODE_TYPE_GEOMETRY);
@@ -452,11 +445,8 @@ void DepsgraphRelationBuilder::build_animdata(ID *id)
/* animation */
if (adt->action || adt->nla_tracks.first) {
/* wire up dependency to time source */
- //TimeSourceKey time_src_key;
- //add_relation(time_src_key, adt_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Animation] DepsRel");
-
- /* TODO(sergey): Replace with time relation. */
- m_graph->add_new_time_relation(m_graph->find_id_node(id));
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, adt_key, DEPSREL_TYPE_TIME, "[TimeSrc -> Animation] DepsRel");
// XXX: Hook up specific update callbacks for special properties which may need it...
}
@@ -964,7 +954,12 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
DepsNodeHandle handle = create_node_handle(mod_key);
mti->updateDepsgraph(md, scene, ob, &handle);
}
-
+
+ if (modifier_check_depends_on_time(ob, md)) {
+ TimeSourceKey time_src_key;
+ add_relation(time_src_key, mod_key, DEPSREL_TYPE_TIME, "Time Source");
+ }
+
prev_mod_key = mod_key;
}
}
@@ -999,11 +994,6 @@ void DepsgraphRelationBuilder::build_obdata_geom(Scene *scene, Object *ob)
else {
add_relation(geom_eval_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
}
-
- if (ob->adt) {
- ComponentKey adt_key(&ob->id, DEPSNODE_TYPE_ANIMATION);
- add_relation(adt_key, obdata_ubereval_key, DEPSREL_TYPE_OPERATION, "Object Geometry UberEval");
- }
}
/* Cameras */
diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cpp b/source/blender/depsgraph/intern/depsgraph_debug.cpp
index 69e84ae..cf61068 100644
--- a/source/blender/depsgraph/intern/depsgraph_debug.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_debug.cpp
@@ -602,6 +602,10 @@ static void deg_debug_graphviz_graph_nodes(const DebugContext &ctx, const Depsgr
DepsNode *node = it->second;
deg_debug_graphviz_node(ctx, node);
}
+ TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
+ if (time_source != NULL) {
+ deg_debug_graphviz_node(ctx, time_source);
+ }
}
static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const Depsgraph *graph)
@@ -629,6 +633,28 @@ static void deg_debug_graphviz_graph_relations(const DebugContext &ctx, const De
}
}
}
+
+ /* TODO(sergey): Cleen this up somehow? */
+ TimeSourceDepsNode *time_source = graph->find_time_source(NULL);
+ if (time_source != NULL) {
+ for (vector<OperationDepsNode*>::const_iterator link = time_source->outlinks.begin();
+ link != time_source->outlinks.end();
+ ++link)
+ {
+ OperationDepsNode *node = *link;
+ deg_debug_printf(ctx, "// %s -> %s\n", time_source->name.c_str(), node->name.c_str());
+ deg_debug_printf(ctx, "\"node_%p\"", time_source);
+ deg_debug_printf(ctx, " -> ");
+ deg_debug_printf(ctx, "\"node_%p\"", node);
+
+ deg_debug_printf(ctx, "[");
+ /* TODO(sergey): Use proper relation name here. */
+ deg_debug_printf(ctx, "label=\"%s\"", "Time Dependency");
+ deg_debug_printf(ctx, ",fontname=\"%s\"", deg_debug_graphviz_fontname);
+ deg_debug_printf(ctx, "];" NL);
+ deg_debug_printf(ctx, NL);
+ }
+ }
#endif
}
diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index 0a35661..439b2bd 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -34,6 +34,7 @@ extern "C" {
#include "depsnode.h" /* own include */
#include "depsnode_component.h"
+#include "depsnode_operation.h"
#include "depsgraph.h"
#include "depsgraph_intern.h"
@@ -71,18 +72,18 @@ DepsNode::~DepsNode()
void TimeSourceDepsNode::tag_update(Depsgraph *graph)
{
- for (vector<IDDepsNode*>::const_iterator it_id = id_nodes.begin();
- it_id != id_nodes.end();
- ++it_id)
+ for (vector<OperationDepsNode*>::const_iterator link = outlinks.begin();
+ link != outlinks.end();
+ ++link)
{
- IDDepsNode *id_node = *it_id;
- id_node->tag_update(graph);
+ OperationDepsNode *node = *link;
+ node->tag_update(graph);
}
}
-void TimeSourceDepsNode::add_time_dependency(IDDepsNode *from)
+void TimeSourceDepsNode::ad
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list