From 0f5455230c8955be0c6533574bd3d5b6f50792b6 Mon Sep 17 00:00:00 2001 From: Rémi Verschelde Date: Tue, 15 Feb 2022 18:06:48 +0100 Subject: Use `switch` consistently in `_notification` (`scene` folder) --- scene/3d/world_environment.cpp | 47 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'scene/3d/world_environment.cpp') diff --git a/scene/3d/world_environment.cpp b/scene/3d/world_environment.cpp index 98f28a8cff..300e761f39 100644 --- a/scene/3d/world_environment.cpp +++ b/scene/3d/world_environment.cpp @@ -34,27 +34,32 @@ #include "scene/main/window.h" void WorldEnvironment::_notification(int p_what) { - if (p_what == Node3D::NOTIFICATION_ENTER_WORLD || p_what == Node3D::NOTIFICATION_ENTER_TREE) { - if (environment.is_valid()) { - add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_environment(); - } - - if (camera_effects.is_valid()) { - add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_camera_effects(); - } - - } else if (p_what == Node3D::NOTIFICATION_EXIT_WORLD || p_what == Node3D::NOTIFICATION_EXIT_TREE) { - if (environment.is_valid()) { - remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_environment(); - } - - if (camera_effects.is_valid()) { - remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); - _update_current_camera_effects(); - } + switch (p_what) { + case Node3D::NOTIFICATION_ENTER_WORLD: + case Node3D::NOTIFICATION_ENTER_TREE: { + if (environment.is_valid()) { + add_to_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_environment(); + } + + if (camera_effects.is_valid()) { + add_to_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_camera_effects(); + } + } break; + + case Node3D::NOTIFICATION_EXIT_WORLD: + case Node3D::NOTIFICATION_EXIT_TREE: { + if (environment.is_valid()) { + remove_from_group("_world_environment_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_environment(); + } + + if (camera_effects.is_valid()) { + remove_from_group("_world_camera_effects_" + itos(get_viewport()->find_world_3d()->get_scenario().get_id())); + _update_current_camera_effects(); + } + } break; } } -- cgit v1.2.3