Browse Source

Merge pull request #104419 from Ryan-000/fix_animation_mixer_errors

Remove incorrect errors in AnimationMixer
Rémi Verschelde 2 months ago
parent
commit
b7f75578db
1 changed files with 5 additions and 1 deletions
  1. 5 1
      scene/animation/animation_mixer.cpp

+ 5 - 1
scene/animation/animation_mixer.cpp

@@ -611,7 +611,11 @@ void AnimationMixer::_init_root_motion_cache() {
 }
 }
 
 
 void AnimationMixer::_create_track_num_to_track_cache_for_animation(Ref<Animation> &p_animation) {
 void AnimationMixer::_create_track_num_to_track_cache_for_animation(Ref<Animation> &p_animation) {
-	ERR_FAIL_COND(animation_track_num_to_track_cache.has(p_animation));
+	if (animation_track_num_to_track_cache.has(p_animation)) {
+		// In AnimationMixer::_update_caches, it retrieves all animations via AnimationMixer::get_animation_list
+		// Since multiple AnimationLibraries can share the same Animation, it is possible that the cache is already created.
+		return;
+	}
 	LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache.insert_new(p_animation, LocalVector<TrackCache *>())->value;
 	LocalVector<TrackCache *> &track_num_to_track_cache = animation_track_num_to_track_cache.insert_new(p_animation, LocalVector<TrackCache *>())->value;
 	const Vector<Animation::Track *> &tracks = p_animation->get_tracks();
 	const Vector<Animation::Track *> &tracks = p_animation->get_tracks();