Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove differences of the code between old AnimationTree and AnimationMixer #85794

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scene/animation/animation_node_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ double AnimationNodeStateMachinePlayback::_process(const String &p_base_path, An
pi.time = 0;
pi.seeked = true;
}
fading_from_rem = p_state_machine->blend_node(p_state_machine->states[fading_from].node, fading_from, pi, AnimationNode::FILTER_IGNORE, true); // Blend values must be more than CMP_EPSILON to process discrete keys in edge.
fading_from_rem = p_state_machine->blend_node(p_state_machine->states[fading_from].node, fading_from, pi, AnimationNode::FILTER_IGNORE, true, p_test_only); // Blend values must be more than CMP_EPSILON to process discrete keys in edge.

// Guess playback position.
if (fading_from_rem > len_fade_from) { /// Weird but ok.
Expand Down Expand Up @@ -976,7 +976,7 @@ bool AnimationNodeStateMachinePlayback::_transition_to_next_recursive(AnimationT
pi.seeked = true;
pi.is_external_seeking = false;
pi.weight = 0;
p_state_machine->blend_node(p_state_machine->states[current].node, current, pi, AnimationNode::FILTER_IGNORE, true);
p_state_machine->blend_node(p_state_machine->states[current].node, current, pi, AnimationNode::FILTER_IGNORE, true, p_test_only);
}

// Just get length to find next recursive.
Expand Down
18 changes: 9 additions & 9 deletions scene/animation/animation_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ void AnimationNode::blend_animation(const StringName &p_animation, AnimationMixe
process_state->tree->make_animation_instance(p_animation, p_playback_info);
}

double AnimationNode::_pre_process(ProcessState *p_process_state, AnimationMixer::PlaybackInfo p_playback_info) {
double AnimationNode::_pre_process(ProcessState *p_process_state, AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
process_state = p_process_state;
double t = process(p_playback_info);
double t = process(p_playback_info, p_test_only);
process_state = nullptr;
return t;
}
Expand Down Expand Up @@ -152,7 +152,7 @@ double AnimationNode::blend_input(int p_input, AnimationMixer::PlaybackInfo p_pl
}

double AnimationNode::blend_node(Ref<AnimationNode> p_node, const StringName &p_subpath, AnimationMixer::PlaybackInfo p_playback_info, FilterAction p_filter, bool p_sync, bool p_test_only) {
node_state.connections.clear();
p_node->node_state.connections.clear();
return _blend_node(p_node, p_subpath, this, p_playback_info, p_filter, p_sync, p_test_only, nullptr);
}

Expand Down Expand Up @@ -269,9 +269,9 @@ double AnimationNode::_blend_node(Ref<AnimationNode> p_node, const StringName &p
p_node->node_state.parent = new_parent;
if (!p_playback_info.seeked && !p_sync && !any_valid) {
p_playback_info.time = 0.0;
return p_node->_pre_process(process_state, p_playback_info);
return p_node->_pre_process(process_state, p_playback_info, p_test_only);
}
return p_node->_pre_process(process_state, p_playback_info);
return p_node->_pre_process(process_state, p_playback_info, p_test_only);
}

String AnimationNode::get_caption() const {
Expand Down Expand Up @@ -565,12 +565,12 @@ bool AnimationTree::_blend_pre_process(double p_delta, int p_track_count, const
if (started) {
// If started, seek.
pi.seeked = true;
root_animation_node->_pre_process(&process_state, pi);
root_animation_node->_pre_process(&process_state, pi, false);
started = false;
} else {
pi.time = p_delta;
root_animation_node->_pre_process(&process_state, pi);
}
pi.seeked = false;
pi.time = p_delta;
root_animation_node->_pre_process(&process_state, pi, false);
Comment on lines +568 to +573
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we supposed to call pre-process (and thus process) twice here when started is true?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before 4.1, it handled both the current position immediately after playback and the delta afterwards, so the purpose is to revert the behavior for now. If there is a problem, it should already be a problem with AnimationTree in 4.1, so this probably won't be a problem.

}

if (!process_state.valid) {
Expand Down
2 changes: 1 addition & 1 deletion scene/animation/animation_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class AnimationNode : public Resource {
void _set_filters(const Array &p_filters);
friend class AnimationNodeBlendTree;
double _blend_node(Ref<AnimationNode> p_node, const StringName &p_subpath, AnimationNode *p_new_parent, AnimationMixer::PlaybackInfo p_playback_info, FilterAction p_filter = FILTER_IGNORE, bool p_sync = true, bool p_test_only = false, real_t *r_activity = nullptr);
double _pre_process(ProcessState *p_process_state, AnimationMixer::PlaybackInfo p_playback_info);
double _pre_process(ProcessState *p_process_state, AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false);

protected:
virtual double _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false);
Expand Down