From cd8748873f556f689a534f92cb0aed64fc1701cf Mon Sep 17 00:00:00 2001
From: Ryan <73148864+Ryan-000@users.noreply.github.com>
Date: Mon, 20 Apr 2026 16:05:02 -0400
Subject: [PATCH] Move dirty filter state from AnimationNode to
AnimationNodeInstance
---
scene/animation/animation_tree.cpp | 14 +++++++++++---
scene/animation/animation_tree.h | 5 ++++-
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 7addfb6252..4d0558196a 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -349,18 +349,25 @@ void AnimationNode::set_filter_path(const NodePath &p_path, bool p_enable) {
} else {
filter.erase(p_path);
}
- filters_dirty = true;
+ _mark_filters_dirty();
}
void AnimationNode::set_filter_enabled(bool p_enable) {
filter_enabled = p_enable;
- filters_dirty = true;
+ _mark_filters_dirty();
}
bool AnimationNode::is_filter_enabled() const {
return filter_enabled;
}
+void AnimationNode::_mark_filters_dirty() {
+ filters_version++;
+ if (unlikely(filters_version == 0)) {
+ filters_version = 1;
+ }
+}
+
void AnimationNode::set_deletable(bool p_closable) {
closable = p_closable;
}
@@ -408,6 +415,7 @@ void AnimationNode::_set_filters(const Array &p_filters) {
}
void AnimationNode::_update_filter_cache(const ProcessState &p_process_state, const AnimationNodeInstance &p_instance) {
+ bool filters_dirty = p_instance.filters_version != filters_version;
if (!p_process_state.track_map_updated && !filters_dirty) {
return; // Cache is valid.
}
@@ -422,7 +430,7 @@ void AnimationNode::_update_filter_cache(const ProcessState &p_process_state, co
p_instance.filtered_track_indices_cache.push_back(*p);
}
}
- filters_dirty = false;
+ p_instance.filters_version = filters_version;
}
void AnimationNode::_validate_property(PropertyInfo &p_property) const {
diff --git a/scene/animation/animation_tree.h b/scene/animation/animation_tree.h
index 6e46adc454..a57f9ca969 100644
--- a/scene/animation/animation_tree.h
+++ b/scene/animation/animation_tree.h
@@ -66,7 +66,6 @@ public:
LocalVector inputs;
HashSet filter;
bool filter_enabled = false;
- bool filters_dirty = true;
// To propagate information from upstream for use in estimation of playback progress.
// These values must be taken from the result of blend_node() or blend_input() and must be essentially read-only.
@@ -179,6 +178,9 @@ protected:
GDVIRTUAL4R(double, _process, double, bool, bool, bool)
GDVIRTUAL0RC(String, _get_caption)
GDVIRTUAL0RC(bool, _has_filter)
+private:
+ mutable uint32_t filters_version = 1;
+ void _mark_filters_dirty();
public:
virtual void get_parameter_list(LocalVector *r_list) const;
@@ -266,6 +268,7 @@ struct AnimationNodeInstance {
mutable LocalVector connection_instances; // AnimationNodeInstance* | nullptr
mutable LocalVector track_weights;
mutable LocalVector filtered_track_indices_cache;
+ mutable uint32_t filters_version = 0;
mutable AHashMap child_instances; // Child Name -> AnimationNodeInstance*
// Multiple AnimationNodeInstances can share the same resource btw.