You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Implement AnimationManager the base class of AnimationPlayer/Tree
This commit is contained in:
@@ -1701,16 +1701,19 @@ int EditorNode::_save_external_resources() {
|
||||
return saved;
|
||||
}
|
||||
|
||||
static void _reset_animation_players(Node *p_node, List<Ref<AnimatedValuesBackup>> *r_anim_backups) {
|
||||
static void _reset_animation_mixers(Node *p_node, List<Pair<AnimationMixer *, Ref<AnimatedValuesBackup>>> *r_anim_backups) {
|
||||
for (int i = 0; i < p_node->get_child_count(); i++) {
|
||||
AnimationPlayer *player = Object::cast_to<AnimationPlayer>(p_node->get_child(i));
|
||||
if (player && player->is_reset_on_save_enabled() && player->can_apply_reset()) {
|
||||
Ref<AnimatedValuesBackup> old_values = player->apply_reset();
|
||||
if (old_values.is_valid()) {
|
||||
r_anim_backups->push_back(old_values);
|
||||
AnimationMixer *mixer = Object::cast_to<AnimationMixer>(p_node->get_child(i));
|
||||
if (mixer && mixer->is_reset_on_save_enabled() && mixer->can_apply_reset()) {
|
||||
Ref<AnimatedValuesBackup> backup = mixer->apply_reset();
|
||||
if (backup.is_valid()) {
|
||||
Pair<AnimationMixer *, Ref<AnimatedValuesBackup>> pair;
|
||||
pair.first = mixer;
|
||||
pair.second = backup;
|
||||
r_anim_backups->push_back(pair);
|
||||
}
|
||||
}
|
||||
_reset_animation_players(p_node->get_child(i), r_anim_backups);
|
||||
_reset_animation_mixers(p_node->get_child(i), r_anim_backups);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1730,8 +1733,8 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
||||
scene->propagate_notification(NOTIFICATION_EDITOR_PRE_SAVE);
|
||||
|
||||
editor_data.apply_changes_in_editors();
|
||||
List<Ref<AnimatedValuesBackup>> anim_backups;
|
||||
_reset_animation_players(scene, &anim_backups);
|
||||
List<Pair<AnimationMixer *, Ref<AnimatedValuesBackup>>> anim_backups;
|
||||
_reset_animation_mixers(scene, &anim_backups);
|
||||
save_default_environment();
|
||||
|
||||
_save_editor_states(p_file, idx);
|
||||
@@ -1773,8 +1776,8 @@ void EditorNode::_save_scene(String p_file, int idx) {
|
||||
_save_external_resources();
|
||||
editor_data.save_editor_external_data();
|
||||
|
||||
for (Ref<AnimatedValuesBackup> &E : anim_backups) {
|
||||
E->restore();
|
||||
for (Pair<AnimationMixer *, Ref<AnimatedValuesBackup>> &E : anim_backups) {
|
||||
E.first->restore(E.second);
|
||||
}
|
||||
|
||||
if (err == OK) {
|
||||
|
||||
Reference in New Issue
Block a user