Skip to content

Commit 9eda898

Browse files
committed
Merge pull request #118791 from Ryan-000/fix-118701
Move dirty filter state from `AnimationNode` to `AnimationNodeInstance`
2 parents 38fd04d + cd87488 commit 9eda898

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

scene/animation/animation_tree.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,18 +349,25 @@ void AnimationNode::set_filter_path(const NodePath &p_path, bool p_enable) {
349349
} else {
350350
filter.erase(p_path);
351351
}
352-
filters_dirty = true;
352+
_mark_filters_dirty();
353353
}
354354

355355
void AnimationNode::set_filter_enabled(bool p_enable) {
356356
filter_enabled = p_enable;
357-
filters_dirty = true;
357+
_mark_filters_dirty();
358358
}
359359

360360
bool AnimationNode::is_filter_enabled() const {
361361
return filter_enabled;
362362
}
363363

364+
void AnimationNode::_mark_filters_dirty() {
365+
filters_version++;
366+
if (unlikely(filters_version == 0)) {
367+
filters_version = 1;
368+
}
369+
}
370+
364371
void AnimationNode::set_deletable(bool p_closable) {
365372
closable = p_closable;
366373
}
@@ -408,6 +415,7 @@ void AnimationNode::_set_filters(const Array &p_filters) {
408415
}
409416

410417
void AnimationNode::_update_filter_cache(const ProcessState &p_process_state, const AnimationNodeInstance &p_instance) {
418+
bool filters_dirty = p_instance.filters_version != filters_version;
411419
if (!p_process_state.track_map_updated && !filters_dirty) {
412420
return; // Cache is valid.
413421
}
@@ -422,7 +430,7 @@ void AnimationNode::_update_filter_cache(const ProcessState &p_process_state, co
422430
p_instance.filtered_track_indices_cache.push_back(*p);
423431
}
424432
}
425-
filters_dirty = false;
433+
p_instance.filters_version = filters_version;
426434
}
427435

428436
void AnimationNode::_validate_property(PropertyInfo &p_property) const {

scene/animation/animation_tree.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ class AnimationNode : public Resource {
6666
LocalVector<Input> inputs;
6767
HashSet<NodePath> filter;
6868
bool filter_enabled = false;
69-
bool filters_dirty = true;
7069

7170
// To propagate information from upstream for use in estimation of playback progress.
7271
// These values must be taken from the result of blend_node() or blend_input() and must be essentially read-only.
@@ -179,6 +178,9 @@ class AnimationNode : public Resource {
179178
GDVIRTUAL4R(double, _process, double, bool, bool, bool)
180179
GDVIRTUAL0RC(String, _get_caption)
181180
GDVIRTUAL0RC(bool, _has_filter)
181+
private:
182+
mutable uint32_t filters_version = 1;
183+
void _mark_filters_dirty();
182184

183185
public:
184186
virtual void get_parameter_list(LocalVector<PropertyInfo> *r_list) const;
@@ -266,6 +268,7 @@ struct AnimationNodeInstance {
266268
mutable LocalVector<AnimationNodeInstance *> connection_instances; // AnimationNodeInstance* | nullptr
267269
mutable LocalVector<real_t> track_weights;
268270
mutable LocalVector<int> filtered_track_indices_cache;
271+
mutable uint32_t filters_version = 0;
269272
mutable AHashMap<StringName, AnimationNodeInstance *> child_instances; // Child Name -> AnimationNodeInstance*
270273

271274
// Multiple AnimationNodeInstances can share the same resource btw.

0 commit comments

Comments
 (0)