diff options
Diffstat (limited to 'scene/3d/world_environment.cpp')
-rw-r--r-- | scene/3d/world_environment.cpp | 47 |
1 files changed, 26 insertions, 21 deletions
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; } } |