From afc923f4159bceb644c4117130ba10f6c50fd6c3 Mon Sep 17 00:00:00 2001 From: Nazarii Date: Sat, 26 Apr 2025 13:21:12 +0300 Subject: [PATCH] Use AHashMap for RBMap nodes and HashMap input_activity --- scene/animation/animation_blend_tree.h | 2 +- scene/animation/animation_tree.cpp | 14 ++++++-------- scene/animation/animation_tree.h | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index eb7eb6188a3..5b8b425d033 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -409,7 +409,7 @@ class AnimationNodeBlendTree : public AnimationRootNode { Vector connections; }; - RBMap nodes; + AHashMap nodes; Vector2 graph_offset; diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index d5de41fda40..d4cecd4f2fd 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -774,7 +774,7 @@ void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref plist; @@ -961,17 +961,15 @@ real_t AnimationTree::get_connection_activity(const StringName &p_path, int p_co if (!input_activity_map_get.has(p_path)) { return 0; } - const LocalVector *activity = input_activity_map_get[p_path]; - if (!activity || p_connection < 0 || p_connection >= (int64_t)activity->size()) { + int index = input_activity_map_get[p_path]; + const LocalVector &activity = input_activity_map.get_by_index(index).value; + + if (p_connection < 0 || p_connection >= (int64_t)activity.size() || activity[p_connection].last_pass != process_pass) { return 0; } - if ((*activity)[p_connection].last_pass != process_pass) { - return 0; - } - - return (*activity)[p_connection].activity; + return activity[p_connection].activity; } void AnimationTree::_bind_methods() { diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h index 2f068e0a16b..d732edfc754 100644 --- a/scene/animation/animation_tree.h +++ b/scene/animation/animation_tree.h @@ -305,8 +305,8 @@ private: uint64_t last_pass = 0; real_t activity = 0.0; }; - mutable HashMap> input_activity_map; - mutable HashMap *> input_activity_map_get; + mutable AHashMap> input_activity_map; + mutable AHashMap input_activity_map_get; NodePath animation_player;