Commit: ad0208263c191c6b68ec5e44077688a4ef83456f
Author: Sergey Sharybin
Date:   Thu Feb 12 17:34:24 2015 +0500
Branches: depsgraph_refactor
https://developer.blender.org/rBad0208263c191c6b68ec5e44077688a4ef83456f

Depsgraph: Change to how id tagging happens

Basically the idea is:

- Builder re-sets the LIB_DOIT flag, so it's guaranteed no left over
  flags happened (it's not guaranteed LIB_DOIT is reset everywhere).

- Functions checks this flag directly, without using wrapping the check
  with functions which kinda hides actual logic (that wouldn't be a
  problem if this flag was only used by depsgraph).

- Removed flag check/set wrapping functions. Found them being rather
  obscure and not really necessary from the beginning.

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

M       source/blender/depsgraph/CMakeLists.txt
M       source/blender/depsgraph/intern/depsgraph.cpp
M       source/blender/depsgraph/intern/depsgraph.h
M       source/blender/depsgraph/intern/depsgraph_build.cpp
M       source/blender/depsgraph/intern/depsgraph_build.h
M       source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
M       source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
M       source/blender/depsgraph/intern/depsgraph_build_relations.cpp
D       source/blender/depsgraph/util/depsgraph_util_id.h

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

diff --git a/source/blender/depsgraph/CMakeLists.txt 
b/source/blender/depsgraph/CMakeLists.txt
index 1de5dc3..951a536 100644
--- a/source/blender/depsgraph/CMakeLists.txt
+++ b/source/blender/depsgraph/CMakeLists.txt
@@ -77,7 +77,6 @@ set(SRC
 
        util/depsgraph_util_function.h
        util/depsgraph_util_hash.h
-       util/depsgraph_util_id.h
        util/depsgraph_util_map.h
        util/depsgraph_util_pchanmap.h
        util/depsgraph_util_set.h
diff --git a/source/blender/depsgraph/intern/depsgraph.cpp 
b/source/blender/depsgraph/intern/depsgraph.cpp
index 035b178..6baf6fb 100644
--- a/source/blender/depsgraph/intern/depsgraph.cpp
+++ b/source/blender/depsgraph/intern/depsgraph.cpp
@@ -303,13 +303,13 @@ IDDepsNode *Depsgraph::find_id_node(const ID *id) const
        return it != this->id_hash.end() ? it->second : NULL;
 }
 
-IDDepsNode *Depsgraph::add_id_node(const ID *id, const string &name)
+IDDepsNode *Depsgraph::add_id_node(ID *id, const string &name)
 {
        IDDepsNode *id_node = find_id_node(id);
        if (!id_node) {
                DepsNodeFactory *factory = 
DEG_get_node_factory(DEPSNODE_TYPE_ID_REF);
                id_node = (IDDepsNode *)factory->create_node(id, "", name);
-
+               id->flag |= LIB_DOIT;
                /* register */
                this->id_hash[id] = id_node;
        }
diff --git a/source/blender/depsgraph/intern/depsgraph.h 
b/source/blender/depsgraph/intern/depsgraph.h
index 13f3764..11dbf10 100644
--- a/source/blender/depsgraph/intern/depsgraph.h
+++ b/source/blender/depsgraph/intern/depsgraph.h
@@ -132,7 +132,7 @@ struct Depsgraph {
        void clear_subgraph_nodes();
 
        IDDepsNode *find_id_node(const ID *id) const;
-       IDDepsNode *add_id_node(const ID *id, const string &name = "");
+       IDDepsNode *add_id_node(ID *id, const string &name = "");
        void remove_id_node(const ID *id);
        void clear_id_nodes();
 
diff --git a/source/blender/depsgraph/intern/depsgraph_build.cpp 
b/source/blender/depsgraph/intern/depsgraph_build.cpp
index 497f42c..f5c5630 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build.cpp
@@ -662,14 +662,6 @@ static void deg_graph_detect_cycles(Depsgraph *graph)
 // XXX: assume that this is called from outside, given the current scene as 
the "main" scene
 void DEG_graph_build_from_scene(Depsgraph *graph, Main *bmain, Scene *scene)
 {
-       /* clear "LIB_DOIT" flag from all materials, etc.
-        * to prevent infinite recursion problems later [#32017]
-        */
-       BKE_main_id_tag_idcode(bmain, ID_MA, false);
-       BKE_main_id_tag_idcode(bmain, ID_LA, false);
-       BKE_main_id_tag_idcode(bmain, ID_WO, false);
-       BKE_main_id_tag_idcode(bmain, ID_TE, false);
-
        /* 1) Generate all the nodes in the graph first */
        DepsgraphNodeBuilder node_builder(bmain, graph);
        /* create root node for scene first
@@ -677,14 +669,14 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main 
*bmain, Scene *scene)
         *   reflecting its role as the entrypoint
         */
        node_builder.add_root_node();
-       node_builder.build_scene(scene);
+       node_builder.build_scene(bmain, scene);
 
        /* 2) Generate relationships between ID nodes and/or components, to 
make it easier to keep track
         *    of which datablocks use which ones (e.g. for checking which 
objects share the same geometry
         *    when we only know the shared datablock)
         */
        DepsgraphIDUsersBuilder users_builder(graph);
-       users_builder.build_scene(scene);
+       users_builder.build_scene(bmain, scene);
 
        /* 3) Hook up relationships between operations - to determine 
evaluation order */
        DepsgraphRelationBuilder relation_builder(graph);
@@ -693,7 +685,7 @@ void DEG_graph_build_from_scene(Depsgraph *graph, Main 
*bmain, Scene *scene)
         * it doesnt add any operations anyway and is not clear what part of 
the scene is to be connected.
         */
        //relation_builder.add_relation(RootKey(), IDKey(scene), 
DEPSREL_TYPE_ROOT_TO_ACTIVE, "Root to Active Scene");
-       relation_builder.build_scene(scene);
+       relation_builder.build_scene(bmain, scene);
 
        /* Detect and solve cycles. */
        deg_graph_detect_cycles(graph);
diff --git a/source/blender/depsgraph/intern/depsgraph_build.h 
b/source/blender/depsgraph/intern/depsgraph_build.h
index 96f317f..9a7c9d4 100644
--- a/source/blender/depsgraph/intern/depsgraph_build.h
+++ b/source/blender/depsgraph/intern/depsgraph_build.h
@@ -27,8 +27,6 @@
 #ifndef __DEPSGRAPH_BUILD_H__
 #define __DEPSGRAPH_BUILD_H__
 
-#include "depsgraph_util_id.h"
-
 struct ListBase;
 struct GHash;
 struct ID;
@@ -77,7 +75,7 @@ struct DepsgraphNodeBuilder {
                return add_operation_node(id, comp_type, "", optype, op, 
opcode, description);
        }
 
-       void build_scene(Scene *scene);
+       void build_scene(Main *bmain, Scene *scene);
        SubgraphDepsNode *build_subgraph(Group *group);
        void build_group(Group *group);
        void build_object(Scene *scene, Base *base, Object *ob);
@@ -233,7 +231,7 @@ struct DepsgraphRelationBuilder
        void add_node_handle_relation(const KeyType &key_from, const 
DepsNodeHandle *handle,
                                      eDepsRelation_Type type, const string 
&description);
 
-       void build_scene(Scene *scene);
+       void build_scene(Main *bmain, Scene *scene);
        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,
@@ -282,7 +280,7 @@ struct DepsgraphIDUsersBuilder {
        void add_relation(const ID *from_id, const ID *to_id,
                          eDepsRelation_Type type, const string &description);
 
-       void build_scene(Scene *scene);
+       void build_scene(Main *bmain, Scene *scene);
        void build_object(Scene *scene, Object *ob);
 
 private:
diff --git a/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp 
b/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
index 821440e..3c03e6f 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_idusers.cpp
@@ -107,7 +107,7 @@ extern "C" {
  *       For example, "ob.data" becomes "obdata -> object"
  */
 
-void DepsgraphIDUsersBuilder::build_scene(Scene *scene)
+void DepsgraphIDUsersBuilder::build_scene(Main *bmain, Scene *scene)
 {
        /* scene set - do links to other scenes */
        if (scene->set) {
diff --git a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp 
b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
index e552839..0c60c18 100644
--- a/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
+++ b/source/blender/depsgraph/intern/depsgraph_build_nodes.cpp
@@ -102,8 +102,15 @@ extern "C" {
 /* ************************************************* */
 /* Node Builder */
 
-void DepsgraphNodeBuilder::build_scene(Scene *scene)
+void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene)
 {
+       /* LIB_DOIT is used to indicate whether node for given ID was already
+        * created or not. This flag is being set in add_id_node(), so functions
+        * shouldn't bother with setting it, they only might query this flag 
when
+        * needed.
+        */
+       BKE_main_id_tag_all(bmain, false);
+
        /* scene ID block */
        add_id_node(&scene->id);
 
@@ -114,7 +121,7 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene)
        // XXX: depending on how this goes, that scene itself could probably 
store its
        //      own little partial depsgraph?
        if (scene->set) {
-               build_scene(scene->set);
+               build_scene(bmain, scene->set);
        }
 
        /* scene objects */
@@ -136,17 +143,15 @@ void DepsgraphNodeBuilder::build_scene(Scene *scene)
                 *       modifications...
                 */
                if (ob->dup_group) {
-                       id_tag_set(&ob->dup_group->id);
+                       ob->dup_group->id.flag |= LIB_DOIT;
                }
        }
 
        /* tagged groups */
        for (Group *group = (Group *)m_bmain->group.first; group; group = 
(Group *)group->id.next) {
-               if (id_is_tagged(&group->id)) {
+               if (group->id.flag & LIB_DOIT) {
                        // TODO: we need to make this group reliant on the 
object that spawned it...
                        build_subgraph(group);
-
-                       id_tag_clear(&group->id);
                }
        }
 
@@ -405,14 +410,10 @@ OperationDepsNode *DepsgraphNodeBuilder::build_driver(ID 
*id, FCurve *fcu)
 /* Recursively build graph for world */
 void DepsgraphNodeBuilder::build_world(World *world)
 {
-       /* Prevent infinite recursion by checking (and tagging the world) as 
having been visited
-        * already. This assumes wo->id.flag & LIB_DOIT isn't set by anything 
else
-        * in the meantime... [#32017]
-        */
        ID *world_id = &world->id;
-       if (id_is_tagged(world_id))
+       if (world_id->flag & LIB_DOIT) {
                return;
-       id_tag_set(world_id);
+       }
 
        /* world itself */
        IDDepsNode *world_node = add_id_node(world_id); /* world 
shading/params? */
@@ -428,8 +429,6 @@ void DepsgraphNodeBuilder::build_world(World *world)
        if (world->nodetree) {
                build_nodetree(world_node, world->nodetree);
        }
-
-       id_tag_clear(world_id);
 }
 
 /* Rigidbody Simulation - Scene Level */
@@ -828,14 +827,9 @@ void DepsgraphNodeBuilder::build_lamp(Object *ob)
 {
        Lamp *la = (Lamp *)ob->data;
        ID *lamp_id = &la->id;
-
-       /* Prevent infinite recursion by checking (and tagging the lamp) as 
having been visited
-        * already. This assumes la->id.flag & LIB_DOIT isn't set by anything 
else
-        * in the meantime... [#32017]
-        */
-       if (id_is_tagged(lamp_id))
+       if (lamp_id->flag & LIB_DOIT) {
                return;
-       id_tag_set(lamp_id);
+       }
 
        /* node for obdata */
        ComponentDepsNode *param_node = add_component_node(lamp_id, 
DEPSNODE_TYPE_PARAMETERS);
@@ -847,8 +841,6 @@ void DepsgraphNodeBuilder::build_lamp(Object *ob)
 
        /* textures */
        build_texture_stack(param_node, la->mtex);
-
-       id_tag_clear(lamp_id);
 }
 
 void DepsgraphNodeBuilder::build_nodetree(DepsNode *owner_node, bNodeTree 
*ntree)
@@ -881,14 +873,10 @@ void DepsgraphNodeBuilder::build_nodetree(DepsNode 
*owner_node, bNodeTree *ntree
 /* Recursively build graph for material */
 void DepsgraphNodeBuilder::build_material(DepsNode *owner_node, Material *ma)
 {
-       /* Prevent infinite recursion by checking (and tagging the material) as 
having been visited
-        * already. This assumes ma->id.flag & LIB_DOIT isn't set by anything 
else
-        * in the meantime... [#32017]
-        */
        ID *ma_id = &ma->id;
-       if (id_is_tagged(ma_id))
+       if (ma_id->flag & LIB_DOIT) {
                return;
-       id_tag_set(ma_id);
+       }
 
        /* material itself */
        add_id_node(ma_id);
@@ -905,8 +893,6 @@ void DepsgraphNodeBuilder::build_material(DepsNode *ow

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to