summaryrefslogtreecommitdiff
path: root/scene/animation/animation_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_tree.cpp')
-rw-r--r--scene/animation/animation_tree.cpp48
1 files changed, 28 insertions, 20 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index f2f69fc439..a50618182d 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -1586,29 +1586,37 @@ void AnimationTree::advance(real_t p_time) {
}
void AnimationTree::_notification(int p_what) {
- if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_callback == ANIMATION_PROCESS_PHYSICS) {
- _process_graph(get_physics_process_delta_time());
- }
-
- if (active && p_what == NOTIFICATION_INTERNAL_PROCESS && process_callback == ANIMATION_PROCESS_IDLE) {
- _process_graph(get_process_delta_time());
- }
+ switch (p_what) {
+ case NOTIFICATION_ENTER_TREE: {
+ if (last_animation_player.is_valid()) {
+ Object *player = ObjectDB::get_instance(last_animation_player);
+ if (player) {
+ player->connect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
+ }
+ }
+ } break;
+
+ case NOTIFICATION_EXIT_TREE: {
+ _clear_caches();
+ if (last_animation_player.is_valid()) {
+ Object *player = ObjectDB::get_instance(last_animation_player);
+ if (player) {
+ player->disconnect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
+ }
+ }
+ } break;
- if (p_what == NOTIFICATION_EXIT_TREE) {
- _clear_caches();
- if (last_animation_player.is_valid()) {
- Object *player = ObjectDB::get_instance(last_animation_player);
- if (player) {
- player->disconnect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
+ case NOTIFICATION_INTERNAL_PROCESS: {
+ if (active && process_callback == ANIMATION_PROCESS_IDLE) {
+ _process_graph(get_process_delta_time());
}
- }
- } else if (p_what == NOTIFICATION_ENTER_TREE) {
- if (last_animation_player.is_valid()) {
- Object *player = ObjectDB::get_instance(last_animation_player);
- if (player) {
- player->connect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
+ } break;
+
+ case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
+ if (active && process_callback == ANIMATION_PROCESS_PHYSICS) {
+ _process_graph(get_physics_process_delta_time());
}
- }
+ } break;
}
}