Godot Engine – Multi-platform 2D and 3D game engine
Animation: Revert blend weight reference from unsafe to safe when blending
Ryan79639d6d64e5
diff --git a/scene/animation/animation_mixer.cpp b/scene/animation/animation_mixer.cppindex b20414c64e8..2f4fd117f72 100644--- a/scene/animation/animation_mixer.cpp+++ b/scene/animation/animation_mixer.cpp@@ -1177,7 +1177,7 @@ void AnimationMixer::_blend_calc_total_weight() {if (Math::is_zero_approx(weight)) {continue;}- Span<real_t> track_weights = ai.playback_info.track_weights != nullptr ? *ai.playback_info.track_weights : Span<real_t>();+ Span<real_t> track_weights = ai.playback_info.track_weights;LocalVector<TrackCache *> *t_cache = animation_track_num_to_track_cache.getptr(a);ERR_CONTINUE_EDMSG(!t_cache, "No animation in cache.");@@ -1271,7 +1271,7 @@ void AnimationMixer::_blend_process(double p_delta, bool p_update_only) {int blend_idx = track->blend_idx;ERR_CONTINUE(blend_idx < 0 || blend_idx >= track_count);real_t blend;- Span<real_t> track_weights = ai.playback_info.track_weights != nullptr ? *ai.playback_info.track_weights : Span<real_t>();+ Span<real_t> track_weights = ai.playback_info.track_weights;if (!track_weights.is_empty() && blend_idx < static_cast<int>(track_weights.size())) {blend = track_weights[blend_idx] * weight;} else {diff --git a/scene/animation/animation_mixer.h b/scene/animation/animation_mixer.hindex a57ffe2527f..fae5a7d482e 100644--- a/scene/animation/animation_mixer.h+++ b/scene/animation/animation_mixer.h@@ -90,7 +90,7 @@ public:bool is_external_seeking = false;Animation::LoopedFlag looped_flag = Animation::LOOPED_FLAG_NONE;real_t weight = 0.0;- LocalVector<real_t> *track_weights = nullptr;+ Vector<real_t> track_weights;};struct AnimationInstance {diff --git a/scene/animation/animation_node_state_machine.cpp b/scene/animation/animation_node_state_machine.cppindex be7a8a7a8c3..87b4378be55 100644--- a/scene/animation/animation_node_state_machine.cpp+++ b/scene/animation/animation_node_state_machine.cpp@@ -1132,7 +1132,7 @@ bool AnimationNodeStateMachinePlayback::_check_advance_condition(AnimationNode::StringName advance_condition_name = transition->get_advance_condition_name();- ERR_FAIL_COND_V(p_instance.resource != state_machine, false);+ ERR_FAIL_COND_V(advance_condition_name != StringName() && p_instance.resource != state_machine, false);if (advance_condition_name != StringName() && !bool(p_instance.get_parameter(advance_condition_name))) {return false;diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cppindex 2485e2b10d1..2712ea8cede 100644--- a/scene/animation/animation_tree.cpp+++ b/scene/animation/animation_tree.cpp@@ -106,7 +106,7 @@ void AnimationNode::get_child_nodes(LocalVector<ChildNode> *r_child_nodes) {}void AnimationNode::blend_animation(ProcessState &p_process_state, AnimationNodeInstance &p_instance, const StringName &p_animation, AnimationMixer::PlaybackInfo &p_playback_info) {- p_playback_info.track_weights = &p_instance.track_weights;+ p_playback_info.track_weights = Vector<real_t>(p_instance.track_weights);p_process_state.tree->make_animation_instance(p_animation, p_playback_info);}