Skip to content

Commit

Permalink
add bone filtering to AnimationNodeBlend3
Browse files Browse the repository at this point in the history
  • Loading branch information
DMDoom committed May 15, 2024
1 parent 1d47561 commit ef01922
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scene/animation/animation_blend_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}
Expand Down
2 changes: 2 additions & 0 deletions scene/animation/animation_blend_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};

Expand Down

0 comments on commit ef01922

Please sign in to comment.