From dd892a327d39c6df71e5e447b30488d7694501b5 Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 7 Dec 2017 12:13:20 -0300 Subject: [PATCH] Added some clean up in camera/viewport management. Fixes #12279, Fixes #12774 --- scene/3d/camera.cpp | 9 +++++---- scene/main/viewport.cpp | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index abc4a03498f..af210fff1c9 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -191,11 +191,12 @@ void Camera::_update_camera() { get_viewport()->_camera_transform_changed_notify(); */ - if (is_inside_tree() && is_current()) { - get_viewport()->_camera_transform_changed_notify(); - } + if (!is_inside_tree() || get_tree()->is_node_being_edited(this) || !is_current()) + return; - if (is_current() && get_world().is_valid()) { + get_viewport()->_camera_transform_changed_notify(); + + if (get_world().is_valid()) { get_world()->_update_camera(this); } } diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d864b0f7630..a785abbc65a 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -936,6 +936,9 @@ void Viewport::_camera_remove(Camera *p_camera) { cameras.erase(p_camera); if (camera == p_camera) { + if (camera && find_world().is_valid()) { + camera->notification(Camera::NOTIFICATION_LOST_CURRENT); + } camera = NULL; } }