From ef01922e0f60a04f8b8a885b37c553e2dcc5aa44 Mon Sep 17 00:00:00 2001 From: DMDoom Date: Wed, 15 May 2024 11:52:52 +0200 Subject: [PATCH] add bone filtering to AnimationNodeBlend3 --- scene/animation/animation_blend_tree.cpp | 10 +++++++--- scene/animation/animation_blend_tree.h | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scene/animation/animation_blend_tree.cpp b/scene/animation/animation_blend_tree.cpp index 6e33a1b27ccc..0b4af9a28079 100644 --- a/scene/animation/animation_blend_tree.cpp +++ b/scene/animation/animation_blend_tree.cpp @@ -876,16 +876,20 @@ String AnimationNodeBlend3::get_caption() const { return "Blend3"; } +bool AnimationNodeBlend3::has_filter() const { + return true; +} + AnimationNode::NodeTimeInfo AnimationNodeBlend3::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) { double amount = get_parameter(blend_amount); AnimationMixer::PlaybackInfo pi = p_playback_info; pi.weight = MAX(0, -amount); - NodeTimeInfo nti0 = blend_input(0, pi, FILTER_IGNORE, sync, p_test_only); + NodeTimeInfo nti0 = blend_input(0, pi, FILTER_PASS, sync, p_test_only); pi.weight = 1.0 - ABS(amount); - NodeTimeInfo nti1 = blend_input(1, pi, FILTER_IGNORE, sync, p_test_only); + NodeTimeInfo nti1 = blend_input(1, pi, FILTER_BLEND, sync, p_test_only); pi.weight = MAX(0, amount); - NodeTimeInfo nti2 = blend_input(2, pi, FILTER_IGNORE, sync, p_test_only); + NodeTimeInfo nti2 = blend_input(2, pi, FILTER_PASS, sync, p_test_only); return amount > 0.5 ? nti2 : (amount < -0.5 ? nti0 : nti1); // Hacky but good enough. } diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h index c7ef7ed62489..89a23ebc9967 100644 --- a/scene/animation/animation_blend_tree.h +++ b/scene/animation/animation_blend_tree.h @@ -269,6 +269,8 @@ class AnimationNodeBlend3 : public AnimationNodeSync { virtual String get_caption() const override; virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override; + + virtual bool has_filter() const override; AnimationNodeBlend3(); };