Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/depsgraph/intern/node/deg_node_id.cc')
-rw-r--r--source/blender/depsgraph/intern/node/deg_node_id.cc53
1 files changed, 9 insertions, 44 deletions
diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc
index 4b6120a6985..4a7e5c4568b 100644
--- a/source/blender/depsgraph/intern/node/deg_node_id.cc
+++ b/source/blender/depsgraph/intern/node/deg_node_id.cc
@@ -26,16 +26,13 @@
#include <cstring> /* required for STREQ later on. */
#include <stdio.h>
-#include "BLI_ghash.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
-extern "C" {
#include "DNA_ID.h"
#include "DNA_anim_types.h"
#include "BKE_lib_id.h"
-}
#include "DEG_depsgraph.h"
@@ -69,34 +66,6 @@ bool IDNode::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 IDNode::ComponentIDKey *key = reinterpret_cast<const IDNode::ComponentIDKey *>(key_v);
- const int type_as_int = static_cast<int>(key->type);
- return BLI_ghashutil_combine_hash(BLI_ghashutil_uinthash(type_as_int),
- BLI_ghashutil_strhash_p(key->name));
-}
-
-static bool id_deps_node_hash_key_cmp(const void *a, const void *b)
-{
- const IDNode::ComponentIDKey *key_a = reinterpret_cast<const IDNode::ComponentIDKey *>(a);
- const IDNode::ComponentIDKey *key_b = reinterpret_cast<const IDNode::ComponentIDKey *>(b);
- return !(*key_a == *key_b);
-}
-
-static void id_deps_node_hash_key_free(void *key_v)
-{
- typedef IDNode::ComponentIDKey ComponentIDKey;
- ComponentIDKey *key = reinterpret_cast<ComponentIDKey *>(key_v);
- OBJECT_GUARDED_DELETE(key, ComponentIDKey);
-}
-
-static void id_deps_node_hash_value_free(void *value_v)
-{
- ComponentNode *comp_node = reinterpret_cast<ComponentNode *>(value_v);
- OBJECT_GUARDED_DELETE(comp_node, ComponentNode);
-}
-
/* Initialize 'id' node - from pointer data given. */
void IDNode::init(const ID *id, const char *UNUSED(subdata))
{
@@ -116,9 +85,6 @@ void IDNode::init(const ID *id, const char *UNUSED(subdata))
visible_components_mask = 0;
previously_visible_components_mask = 0;
-
- components = BLI_ghash_new(
- id_deps_node_hash_key, id_deps_node_hash_key_cmp, "Depsgraph id components hash");
}
void IDNode::init_copy_on_write(ID *id_cow_hint)
@@ -158,7 +124,9 @@ void IDNode::destroy()
return;
}
- BLI_ghash_free(components, id_deps_node_hash_key_free, id_deps_node_hash_value_free);
+ for (ComponentNode *comp_node : components.values()) {
+ OBJECT_GUARDED_DELETE(comp_node, ComponentNode);
+ }
/* Free memory used by this CoW ID. */
if (id_cow != id_orig && id_cow != nullptr) {
@@ -185,7 +153,7 @@ string IDNode::identifier() const
ComponentNode *IDNode::find_component(NodeType type, const char *name) const
{
ComponentIDKey key(type, name);
- return reinterpret_cast<ComponentNode *>(BLI_ghash_lookup(components, &key));
+ return components.lookup_default(key, nullptr);
}
ComponentNode *IDNode::add_component(NodeType type, const char *name)
@@ -196,8 +164,8 @@ ComponentNode *IDNode::add_component(NodeType type, const char *name)
comp_node = (ComponentNode *)factory->create_node(this->id_orig, "", name);
/* Register. */
- ComponentIDKey *key = OBJECT_GUARDED_NEW(ComponentIDKey, type, name);
- BLI_ghash_insert(components, key, comp_node);
+ ComponentIDKey key(type, name);
+ components.add_new(key, comp_node);
comp_node->owner = this;
}
return comp_node;
@@ -205,7 +173,7 @@ ComponentNode *IDNode::add_component(NodeType type, const char *name)
void IDNode::tag_update(Depsgraph *graph, eUpdateSource source)
{
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) {
+ for (ComponentNode *comp_node : components.values()) {
/* Relations update does explicit animation update when needed. Here we ignore animation
* component to avoid loss of possible unkeyed changes. */
if (comp_node->type == NodeType::ANIMATION && source == DEG_UPDATE_SOURCE_RELATIONS) {
@@ -213,30 +181,27 @@ void IDNode::tag_update(Depsgraph *graph, eUpdateSource source)
}
comp_node->tag_update(graph, source);
}
- GHASH_FOREACH_END();
}
void IDNode::finalize_build(Depsgraph *graph)
{
/* Finalize build of all components. */
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) {
+ for (ComponentNode *comp_node : components.values()) {
comp_node->finalize_build(graph);
}
- GHASH_FOREACH_END();
visible_components_mask = get_visible_components_mask();
}
IDComponentsMask IDNode::get_visible_components_mask() const
{
IDComponentsMask result = 0;
- GHASH_FOREACH_BEGIN (ComponentNode *, comp_node, components) {
+ for (ComponentNode *comp_node : components.values()) {
if (comp_node->affects_directly_visible) {
const int component_type_as_int = static_cast<int>(comp_node->type);
BLI_assert(component_type_as_int < 64);
result |= (1ULL << component_type_as_int);
}
}
- GHASH_FOREACH_END();
return result;
}