From 3474db4b37e75150924d3cec73472ad3eadea4cb Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 20 Dec 2017 16:35:48 +0100 Subject: Depsgraph: Move ID node to own file --- source/blender/depsgraph/CMakeLists.txt | 2 + .../depsgraph/intern/builder/deg_builder.cc | 1 + .../depsgraph/intern/builder/deg_builder_nodes.cc | 2 + .../intern/builder/deg_builder_relations.cc | 1 + .../intern/builder/deg_builder_relations_scene.cc | 1 + .../depsgraph/intern/debug/deg_debug_graphviz.cc | 1 + source/blender/depsgraph/intern/depsgraph.cc | 1 + source/blender/depsgraph/intern/depsgraph_build.cc | 1 + source/blender/depsgraph/intern/depsgraph_debug.cc | 1 + source/blender/depsgraph/intern/depsgraph_query.cc | 1 + .../depsgraph/intern/depsgraph_query_foreach.cc | 1 + source/blender/depsgraph/intern/depsgraph_tag.cc | 1 + source/blender/depsgraph/intern/eval/deg_eval.cc | 1 + .../depsgraph/intern/eval/deg_eval_flush.cc | 1 + source/blender/depsgraph/intern/nodes/deg_node.cc | 132 +-------------- source/blender/depsgraph/intern/nodes/deg_node.h | 45 ----- .../depsgraph/intern/nodes/deg_node_component.cc | 1 + .../depsgraph/intern/nodes/deg_node_component.h | 1 + .../blender/depsgraph/intern/nodes/deg_node_id.cc | 183 +++++++++++++++++++++ .../blender/depsgraph/intern/nodes/deg_node_id.h | 79 +++++++++ .../depsgraph/intern/nodes/deg_node_operation.cc | 1 + .../depsgraph/intern/nodes/deg_node_operation.h | 2 + 22 files changed, 284 insertions(+), 176 deletions(-) create mode 100644 source/blender/depsgraph/intern/nodes/deg_node_id.cc create mode 100644 source/blender/depsgraph/intern/nodes/deg_node_id.h (limited to 'source/blender') diff --git a/source/blender/depsgraph/CMakeLists.txt b/source/blender/depsgraph/CMakeLists.txt index 868a26ae821..232fc93aeb4 100644 --- a/source/blender/depsgraph/CMakeLists.txt +++ b/source/blender/depsgraph/CMakeLists.txt @@ -56,6 +56,7 @@ set(SRC intern/eval/deg_eval_flush.cc intern/nodes/deg_node.cc intern/nodes/deg_node_component.cc + intern/nodes/deg_node_id.cc intern/nodes/deg_node_operation.cc intern/nodes/deg_node_time.cc intern/depsgraph.cc @@ -83,6 +84,7 @@ set(SRC intern/eval/deg_eval_flush.h intern/nodes/deg_node.h intern/nodes/deg_node_component.h + intern/nodes/deg_node_id.h intern/nodes/deg_node_operation.h intern/nodes/deg_node_time.h intern/depsgraph.h diff --git a/source/blender/depsgraph/intern/builder/deg_builder.cc b/source/blender/depsgraph/intern/builder/deg_builder.cc index c79716e5ea5..5713297d658 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder.cc @@ -42,6 +42,7 @@ #include "intern/depsgraph_types.h" #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "util/deg_util_foreach.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 6de6feb32f2..85e80f80d26 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -105,9 +105,11 @@ extern "C" { #include "intern/builder/deg_builder.h" #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_types.h" #include "intern/depsgraph_intern.h" + #include "util/deg_util_foreach.h" namespace DEG { diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 2266469c691..0546d43af72 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -103,6 +103,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/nodes/deg_node_time.h" diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index feb32442cb7..29c739bf784 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -58,6 +58,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_intern.h" diff --git a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc index 4f6b301bf9e..159e9bcf9a7 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug_graphviz.cc @@ -41,6 +41,7 @@ extern "C" { #include "DEG_depsgraph_debug.h" #include "intern/depsgraph_intern.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_time.h" #include "util/deg_util_foreach.h" diff --git a/source/blender/depsgraph/intern/depsgraph.cc b/source/blender/depsgraph/intern/depsgraph.cc index b71e1e1cd4e..c4841d6789e 100644 --- a/source/blender/depsgraph/intern/depsgraph.cc +++ b/source/blender/depsgraph/intern/depsgraph.cc @@ -58,6 +58,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/nodes/deg_node_time.h" diff --git a/source/blender/depsgraph/intern/depsgraph_build.cc b/source/blender/depsgraph/intern/depsgraph_build.cc index 4b3d4190dcd..3884cfe49e7 100644 --- a/source/blender/depsgraph/intern/depsgraph_build.cc +++ b/source/blender/depsgraph/intern/depsgraph_build.cc @@ -66,6 +66,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_types.h" diff --git a/source/blender/depsgraph/intern/depsgraph_debug.cc b/source/blender/depsgraph/intern/depsgraph_debug.cc index 4290ea12112..b7bf63e0cb0 100644 --- a/source/blender/depsgraph/intern/depsgraph_debug.cc +++ b/source/blender/depsgraph/intern/depsgraph_debug.cc @@ -42,6 +42,7 @@ extern "C" { #include "DEG_depsgraph_build.h" #include "intern/depsgraph_intern.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_time.h" #include "util/deg_util_foreach.h" diff --git a/source/blender/depsgraph/intern/depsgraph_query.cc b/source/blender/depsgraph/intern/depsgraph_query.cc index e58a7a32407..9b1961baa48 100644 --- a/source/blender/depsgraph/intern/depsgraph_query.cc +++ b/source/blender/depsgraph/intern/depsgraph_query.cc @@ -40,6 +40,7 @@ extern "C" { #include "DEG_depsgraph_query.h" #include "intern/depsgraph_intern.h" +#include "intern/nodes/deg_node_id.h" bool DEG_id_type_tagged(Main *bmain, short idtype) { diff --git a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc index f2a121f3d07..65d8f58b851 100644 --- a/source/blender/depsgraph/intern/depsgraph_query_foreach.cc +++ b/source/blender/depsgraph/intern/depsgraph_query_foreach.cc @@ -50,6 +50,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "util/deg_util_foreach.h" diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index 2979cf7270d..7f08f3f8052 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -61,6 +61,7 @@ extern "C" { #include "intern/eval/deg_eval_flush.h" #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_intern.h" diff --git a/source/blender/depsgraph/intern/eval/deg_eval.cc b/source/blender/depsgraph/intern/eval/deg_eval.cc index dfd2b723c01..16e5fc9b4a5 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval.cc @@ -50,6 +50,7 @@ extern "C" { #include "intern/eval/deg_eval_flush.h" #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/nodes/deg_node_time.h" #include "intern/depsgraph.h" diff --git a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc index 219ed981870..63d010849c3 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_flush.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_flush.cc @@ -47,6 +47,7 @@ extern "C" { #include "intern/nodes/deg_node.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_intern.h" diff --git a/source/blender/depsgraph/intern/nodes/deg_node.cc b/source/blender/depsgraph/intern/nodes/deg_node.cc index 82c67652435..c558777aa67 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node.cc @@ -46,6 +46,7 @@ extern "C" { #include "DEG_depsgraph.h" #include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/nodes/deg_node_time.h" #include "intern/depsgraph_intern.h" @@ -101,142 +102,11 @@ string DepsNode::identifier() const return string(typebuf) + " : " + name; } -/* ************* */ /* Generic Nodes */ -/* Time Source Node ======================================= */ - DEG_DEPSNODE_DEFINE(TimeSourceDepsNode, DEG_NODE_TYPE_TIMESOURCE, "Time Source"); static DepsNodeFactoryImpl DNTI_TIMESOURCE; -/* ID Node ================================================ */ - -IDDepsNode::ComponentIDKey::ComponentIDKey(eDepsNode_Type type, - const char *name) - : type(type), name(name) -{ -} - -bool IDDepsNode::ComponentIDKey::operator== (const ComponentIDKey &other) const -{ - return type == other.type && - STREQ(name, other.name); -} - -static unsigned int id_deps_node_hash_key(const void *key_v) -{ - const IDDepsNode::ComponentIDKey *key = - reinterpret_cast(key_v); - return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(key->type), - BLI_ghashutil_strhash_p(key->name)); -} - -static bool id_deps_node_hash_key_cmp(const void *a, const void *b) -{ - const IDDepsNode::ComponentIDKey *key_a = - reinterpret_cast(a); - const IDDepsNode::ComponentIDKey *key_b = - reinterpret_cast(b); - return !(*key_a == *key_b); -} - -static void id_deps_node_hash_key_free(void *key_v) -{ - typedef IDDepsNode::ComponentIDKey ComponentIDKey; - ComponentIDKey *key = reinterpret_cast(key_v); - OBJECT_GUARDED_DELETE(key, ComponentIDKey); -} - -static void id_deps_node_hash_value_free(void *value_v) -{ - ComponentDepsNode *comp_node = reinterpret_cast(value_v); - OBJECT_GUARDED_DELETE(comp_node, ComponentDepsNode); -} - -/* Initialize 'id' node - from pointer data given. */ -void IDDepsNode::init(const ID *id, const char *UNUSED(subdata)) -{ - /* Store ID-pointer. */ - BLI_assert(id != NULL); - this->id = (ID *)id; - this->layers = (1 << 20) - 1; - this->eval_flags = 0; - - /* For object we initialize layers to layer from base. */ - if (GS(id->name) == ID_OB) { - this->layers = 0; - } - - components = BLI_ghash_new(id_deps_node_hash_key, - id_deps_node_hash_key_cmp, - "Depsgraph id components hash"); - - /* NOTE: components themselves are created if/when needed. - * This prevents problems with components getting added - * twice if an ID-Ref needs to be created to house it... - */ -} - -/* Free 'id' node. */ -IDDepsNode::~IDDepsNode() -{ - BLI_ghash_free(components, - id_deps_node_hash_key_free, - id_deps_node_hash_value_free); -} - -ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type, - const char *name) const -{ - ComponentIDKey key(type, name); - return reinterpret_cast(BLI_ghash_lookup(components, &key)); -} - -ComponentDepsNode *IDDepsNode::add_component(eDepsNode_Type type, - const char *name) -{ - ComponentDepsNode *comp_node = find_component(type, name); - if (!comp_node) { - DepsNodeFactory *factory = deg_type_get_factory(type); - comp_node = (ComponentDepsNode *)factory->create_node(this->id, "", name); - - /* Register. */ - ComponentIDKey *key = OBJECT_GUARDED_NEW(ComponentIDKey, type, name); - BLI_ghash_insert(components, key, comp_node); - comp_node->owner = this; - } - return comp_node; -} - -void IDDepsNode::tag_update(Depsgraph *graph) -{ - GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components) - { - /* TODO(sergey): What about drievrs? */ - bool do_component_tag = comp_node->type != DEG_NODE_TYPE_ANIMATION; - if (comp_node->type == DEG_NODE_TYPE_ANIMATION) { - AnimData *adt = BKE_animdata_from_id(id); - /* Animation data might be null if relations are tagged for update. */ - if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM)) { - do_component_tag = true; - } - } - if (do_component_tag) { - comp_node->tag_update(graph); - } - } - GHASH_FOREACH_END(); -} - -void IDDepsNode::finalize_build() -{ - GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components) - { - comp_node->finalize_build(); - } - GHASH_FOREACH_END(); -} - DEG_DEPSNODE_DEFINE(IDDepsNode, DEG_NODE_TYPE_ID_REF, "ID Node"); static DepsNodeFactoryImpl DNTI_ID_REF; diff --git a/source/blender/depsgraph/intern/nodes/deg_node.h b/source/blender/depsgraph/intern/nodes/deg_node.h index 8f2cc3f374b..54042ae4a1b 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node.h +++ b/source/blender/depsgraph/intern/nodes/deg_node.h @@ -109,51 +109,6 @@ struct DepsNode { #define DEG_DEPSNODE_DEFINE(NodeType, type_, tname_) \ const DepsNode::TypeInfo NodeType::typeinfo = DepsNode::TypeInfo(type_, tname_) -/* Generic Nodes ======================= */ - -struct ComponentDepsNode; -struct IDDepsNode; - -/* ID-Block Reference */ -struct IDDepsNode : public DepsNode { - struct ComponentIDKey { - ComponentIDKey(eDepsNode_Type type, const char *name = ""); - bool operator==(const ComponentIDKey &other) const; - - eDepsNode_Type type; - const char *name; - }; - - void init(const ID *id, const char *subdata); - ~IDDepsNode(); - - ComponentDepsNode *find_component(eDepsNode_Type type, - const char *name = "") const; - ComponentDepsNode *add_component(eDepsNode_Type type, - const char *name = ""); - - void tag_update(Depsgraph *graph); - - void finalize_build(); - - /* ID Block referenced. */ - ID *id; - - /* Hash to make it faster to look up components. */ - GHash *components; - - /* Layers of this node with accumulated layers of it's output relations. */ - unsigned int layers; - - /* Additional flags needed for scene evaluation. - * TODO(sergey): Only needed for until really granular updates - * of all the entities. - */ - int eval_flags; - - DEG_DEPSNODE_DECLARE; -}; - void deg_register_base_depsnodes(); } // namespace DEG diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index 8ac73671678..9450ed7f17d 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -42,6 +42,7 @@ extern "C" { #include "BKE_action.h" } /* extern "C" */ +#include "intern/nodes/deg_node_id.h" #include "intern/nodes/deg_node_operation.h" #include "intern/depsgraph_intern.h" #include "util/deg_util_foreach.h" diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 702697eba3a..c6625e55857 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -46,6 +46,7 @@ namespace DEG { struct Depsgraph; struct OperationDepsNode; struct BoneComponentDepsNode; +struct IDDepsNode; /* ID Component - Base type for all components */ struct ComponentDepsNode : public DepsNode { diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.cc b/source/blender/depsgraph/intern/nodes/deg_node_id.cc new file mode 100644 index 00000000000..fc77879ec33 --- /dev/null +++ b/source/blender/depsgraph/intern/nodes/deg_node_id.cc @@ -0,0 +1,183 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): None Yet + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/depsgraph/intern/nodes/deg_node_id.cc + * \ingroup depsgraph + */ + +#include "intern/nodes/deg_node_id.h" + +#include +#include /* required for STREQ later on. */ + +#include "BLI_utildefines.h" +#include "BLI_ghash.h" + +extern "C" { +#include "DNA_ID.h" +#include "DNA_anim_types.h" + +#include "BKE_animsys.h" +} + +#include "DEG_depsgraph.h" + +#include "intern/nodes/deg_node_component.h" +#include "intern/nodes/deg_node_operation.h" +#include "intern/nodes/deg_node_time.h" +#include "intern/depsgraph_intern.h" + +#include "util/deg_util_foreach.h" + +namespace DEG { + +IDDepsNode::ComponentIDKey::ComponentIDKey(eDepsNode_Type type, + const char *name) + : type(type), name(name) +{ +} + +bool IDDepsNode::ComponentIDKey::operator== (const ComponentIDKey &other) const +{ + return type == other.type && + STREQ(name, other.name); +} + +static unsigned int id_deps_node_hash_key(const void *key_v) +{ + const IDDepsNode::ComponentIDKey *key = + reinterpret_cast(key_v); + return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(key->type), + BLI_ghashutil_strhash_p(key->name)); +} + +static bool id_deps_node_hash_key_cmp(const void *a, const void *b) +{ + const IDDepsNode::ComponentIDKey *key_a = + reinterpret_cast(a); + const IDDepsNode::ComponentIDKey *key_b = + reinterpret_cast(b); + return !(*key_a == *key_b); +} + +static void id_deps_node_hash_key_free(void *key_v) +{ + typedef IDDepsNode::ComponentIDKey ComponentIDKey; + ComponentIDKey *key = reinterpret_cast(key_v); + OBJECT_GUARDED_DELETE(key, ComponentIDKey); +} + +static void id_deps_node_hash_value_free(void *value_v) +{ + ComponentDepsNode *comp_node = reinterpret_cast(value_v); + OBJECT_GUARDED_DELETE(comp_node, ComponentDepsNode); +} + +/* Initialize 'id' node - from pointer data given. */ +void IDDepsNode::init(const ID *id, const char *UNUSED(subdata)) +{ + /* Store ID-pointer. */ + BLI_assert(id != NULL); + this->id = (ID *)id; + this->layers = (1 << 20) - 1; + this->eval_flags = 0; + + /* For object we initialize layers to layer from base. */ + if (GS(id->name) == ID_OB) { + this->layers = 0; + } + + components = BLI_ghash_new(id_deps_node_hash_key, + id_deps_node_hash_key_cmp, + "Depsgraph id components hash"); + + /* NOTE: components themselves are created if/when needed. + * This prevents problems with components getting added + * twice if an ID-Ref needs to be created to house it... + */ +} + +/* Free 'id' node. */ +IDDepsNode::~IDDepsNode() +{ + BLI_ghash_free(components, + id_deps_node_hash_key_free, + id_deps_node_hash_value_free); +} + +ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type, + const char *name) const +{ + ComponentIDKey key(type, name); + return reinterpret_cast(BLI_ghash_lookup(components, &key)); +} + +ComponentDepsNode *IDDepsNode::add_component(eDepsNode_Type type, + const char *name) +{ + ComponentDepsNode *comp_node = find_component(type, name); + if (!comp_node) { + DepsNodeFactory *factory = deg_type_get_factory(type); + comp_node = (ComponentDepsNode *)factory->create_node(this->id, "", name); + + /* Register. */ + ComponentIDKey *key = OBJECT_GUARDED_NEW(ComponentIDKey, type, name); + BLI_ghash_insert(components, key, comp_node); + comp_node->owner = this; + } + return comp_node; +} + +void IDDepsNode::tag_update(Depsgraph *graph) +{ + GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components) + { + /* TODO(sergey): What about drievrs? */ + bool do_component_tag = comp_node->type != DEG_NODE_TYPE_ANIMATION; + if (comp_node->type == DEG_NODE_TYPE_ANIMATION) { + AnimData *adt = BKE_animdata_from_id(id); + /* Animation data might be null if relations are tagged for update. */ + if (adt != NULL && (adt->recalc & ADT_RECALC_ANIM)) { + do_component_tag = true; + } + } + if (do_component_tag) { + comp_node->tag_update(graph); + } + } + GHASH_FOREACH_END(); +} + +void IDDepsNode::finalize_build() +{ + GHASH_FOREACH_BEGIN(ComponentDepsNode *, comp_node, components) + { + comp_node->finalize_build(); + } + GHASH_FOREACH_END(); +} + +} // namespace DEG diff --git a/source/blender/depsgraph/intern/nodes/deg_node_id.h b/source/blender/depsgraph/intern/nodes/deg_node_id.h new file mode 100644 index 00000000000..55022916c4d --- /dev/null +++ b/source/blender/depsgraph/intern/nodes/deg_node_id.h @@ -0,0 +1,79 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2013 Blender Foundation. + * All rights reserved. + * + * Original Author: Joshua Leung + * Contributor(s): None Yet + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file depsgraph/intern/nodes/deg_node_id.h + * \ingroup depsgraph + */ + +#pragma once + +#include "intern/nodes/deg_node.h" + +namespace DEG { + +struct ComponentDepsNode; + +/* ID-Block Reference */ +struct IDDepsNode : public DepsNode { + struct ComponentIDKey { + ComponentIDKey(eDepsNode_Type type, const char *name = ""); + bool operator==(const ComponentIDKey &other) const; + + eDepsNode_Type type; + const char *name; + }; + + void init(const ID *id, const char *subdata); + ~IDDepsNode(); + + ComponentDepsNode *find_component(eDepsNode_Type type, + const char *name = "") const; + ComponentDepsNode *add_component(eDepsNode_Type type, + const char *name = ""); + + void tag_update(Depsgraph *graph); + + void finalize_build(); + + /* ID Block referenced. */ + ID *id; + + /* Hash to make it faster to look up components. */ + GHash *components; + + /* Layers of this node with accumulated layers of it's output relations. */ + unsigned int layers; + + /* Additional flags needed for scene evaluation. + * TODO(sergey): Only needed for until really granular updates + * of all the entities. + */ + int eval_flags; + + DEG_DEPSNODE_DECLARE; +}; + +} // namespace DEG diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc index 7467264f612..0fc87a52005 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.cc @@ -37,6 +37,7 @@ #include "intern/depsgraph.h" #include "intern/depsgraph_intern.h" +#include "intern/nodes/deg_node_id.h" namespace DEG { diff --git a/source/blender/depsgraph/intern/nodes/deg_node_operation.h b/source/blender/depsgraph/intern/nodes/deg_node_operation.h index d8203540fc5..ffb95a53b5d 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_operation.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_operation.h @@ -38,6 +38,8 @@ struct Depsgraph; namespace DEG { +struct ComponentDepsNode; + /* Flags for Depsgraph Nodes */ typedef enum eDepsOperation_Flag { /* node needs to be updated */ -- cgit v1.2.3