mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 11:32:13 +00:00
Merge pull request #98706 from Nazarwadim/fix_capture_cache_was_not_cached
Fix `capture_cache.animation` was not cached
This commit is contained in:
commit
370c692bcb
@ -622,10 +622,11 @@ public:
|
||||
}
|
||||
|
||||
// Inserts an element without checking if it already exists.
|
||||
void insert_new(const TKey &p_key, const TValue &p_value) {
|
||||
Iterator insert_new(const TKey &p_key, const TValue &p_value) {
|
||||
DEV_ASSERT(!has(p_key));
|
||||
uint32_t hash = _hash(p_key);
|
||||
_insert_element(p_key, p_value, hash);
|
||||
uint32_t pos = _insert_element(p_key, p_value, hash);
|
||||
return Iterator(elements + pos, elements, elements + num_elements);
|
||||
}
|
||||
|
||||
/* Array methods. */
|
||||
|
@ -600,6 +600,22 @@ void AnimationMixer::_init_root_motion_cache() {
|
||||
root_motion_scale_accumulator = Vector3(1, 1, 1);
|
||||
}
|
||||
|
||||
void AnimationMixer::_create_track_num_to_track_cashe_for_animation(Ref<Animation> &p_animation) {
|
||||
ERR_FAIL_COND(animation_track_num_to_track_cashe.has(p_animation));
|
||||
LocalVector<TrackCache *> &track_num_to_track_cashe = animation_track_num_to_track_cashe.insert_new(p_animation, LocalVector<TrackCache *>())->value;
|
||||
const Vector<Animation::Track *> &tracks = p_animation->get_tracks();
|
||||
|
||||
track_num_to_track_cashe.resize(tracks.size());
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash);
|
||||
if (track_ptr == nullptr) {
|
||||
track_num_to_track_cashe[i] = nullptr;
|
||||
} else {
|
||||
track_num_to_track_cashe[i] = *track_ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool AnimationMixer::_update_caches() {
|
||||
setup_pass++;
|
||||
|
||||
@ -928,20 +944,9 @@ bool AnimationMixer::_update_caches() {
|
||||
}
|
||||
|
||||
animation_track_num_to_track_cashe.clear();
|
||||
LocalVector<TrackCache *> track_num_to_track_cashe;
|
||||
for (const StringName &E : sname_list) {
|
||||
Ref<Animation> anim = get_animation(E);
|
||||
const Vector<Animation::Track *> tracks = anim->get_tracks();
|
||||
track_num_to_track_cashe.resize(tracks.size());
|
||||
for (int i = 0; i < tracks.size(); i++) {
|
||||
TrackCache **track_ptr = track_cache.getptr(tracks[i]->thash);
|
||||
if (track_ptr == nullptr) {
|
||||
track_num_to_track_cashe[i] = nullptr;
|
||||
} else {
|
||||
track_num_to_track_cashe[i] = *track_ptr;
|
||||
}
|
||||
}
|
||||
animation_track_num_to_track_cashe.insert(anim, track_num_to_track_cashe);
|
||||
_create_track_num_to_track_cashe_for_animation(anim);
|
||||
}
|
||||
|
||||
track_count = idx;
|
||||
@ -1074,6 +1079,9 @@ void AnimationMixer::blend_capture(double p_delta) {
|
||||
|
||||
capture_cache.remain -= p_delta * capture_cache.step;
|
||||
if (Animation::is_less_or_equal_approx(capture_cache.remain, 0)) {
|
||||
if (capture_cache.animation.is_valid()) {
|
||||
animation_track_num_to_track_cashe.erase(capture_cache.animation);
|
||||
}
|
||||
capture_cache.clear();
|
||||
return;
|
||||
}
|
||||
@ -2205,6 +2213,9 @@ void AnimationMixer::capture(const StringName &p_name, double p_duration, Tween:
|
||||
capture_cache.step = 1.0 / p_duration;
|
||||
capture_cache.trans_type = p_trans_type;
|
||||
capture_cache.ease_type = p_ease_type;
|
||||
if (capture_cache.animation.is_valid()) {
|
||||
animation_track_num_to_track_cashe.erase(capture_cache.animation);
|
||||
}
|
||||
capture_cache.animation.instantiate();
|
||||
|
||||
bool is_valid = false;
|
||||
@ -2228,6 +2239,8 @@ void AnimationMixer::capture(const StringName &p_name, double p_duration, Tween:
|
||||
}
|
||||
if (!is_valid) {
|
||||
capture_cache.clear();
|
||||
} else {
|
||||
_create_track_num_to_track_cashe_for_animation(capture_cache.animation);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -321,6 +321,7 @@ protected:
|
||||
void _clear_playing_caches();
|
||||
void _init_root_motion_cache();
|
||||
bool _update_caches();
|
||||
void _create_track_num_to_track_cashe_for_animation(Ref<Animation> &p_animation);
|
||||
|
||||
/* ---- Audio ---- */
|
||||
AudioServer::PlaybackType playback_type;
|
||||
|
Loading…
Reference in New Issue
Block a user