diff options
author | reduz <reduzio@gmail.com> | 2022-06-23 08:19:18 +0200 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2022-06-23 08:19:18 +0200 |
commit | d69e3791bf41dca6c29a9eb24bb92648cce2d692 (patch) | |
tree | a8ca3ff213aad1d5d8210a608092d4ed33b9f637 | |
parent | abb92861f44427e9376fab9ee2f414f14848d6b5 (diff) |
Fix editor-only visibility for lights
* Update visibility again for editor-only lights if owner changes.
Fixes #26399, supersedes #52327
-rw-r--r-- | scene/2d/light_2d.cpp | 5 | ||||
-rw-r--r-- | scene/2d/light_2d.h | 2 | ||||
-rw-r--r-- | scene/3d/light_3d.cpp | 5 | ||||
-rw-r--r-- | scene/3d/light_3d.h | 2 | ||||
-rw-r--r-- | scene/main/node.cpp | 5 | ||||
-rw-r--r-- | scene/main/node.h | 1 |
6 files changed, 20 insertions, 0 deletions
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 28d9b284e6..0481a58431 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -30,6 +30,11 @@ #include "light_2d.h" +void Light2D::owner_changed_notify() { + // For cases where owner changes _after_ entering tree (as example, editor editing). + _update_light_visibility(); +} + void Light2D::_update_light_visibility() { if (!is_inside_tree()) { return; diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index f7b1f420e3..a84b6516c0 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -73,6 +73,8 @@ private: void _update_light_visibility(); + virtual void owner_changed_notify() override; + protected: _FORCE_INLINE_ RID _get_light() const { return canvas_light; } void _notification(int p_what); diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 28614d7cae..6c999d85e2 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -176,6 +176,11 @@ Ref<Texture2D> Light3D::get_projector() const { return projector; } +void Light3D::owner_changed_notify() { + // For cases where owner changes _after_ entering tree (as example, editor editing). + _update_visibility(); +} + void Light3D::_update_visibility() { if (!is_inside_tree()) { return; diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index 383fa644e5..6ff332df5a 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -85,6 +85,8 @@ private: // bind helpers + virtual void owner_changed_notify() override; + protected: RID light; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index b5caec3fc3..a30eb036db 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -420,6 +420,9 @@ void Node::move_child_notify(Node *p_child) { // to be used when not wanted } +void Node::owner_changed_notify() { +} + void Node::set_physics_process(bool p_process) { if (data.physics_process == p_process) { return; @@ -1544,6 +1547,8 @@ void Node::_set_owner_nocheck(Node *p_owner) { data.owner = p_owner; data.owner->data.owned.push_back(this); data.OW = data.owner->data.owned.back(); + + owner_changed_notify(); } void Node::_release_unique_name_in_owner() { diff --git a/scene/main/node.h b/scene/main/node.h index 8de6c1ce69..5b7bc0a587 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -208,6 +208,7 @@ protected: virtual void add_child_notify(Node *p_child); virtual void remove_child_notify(Node *p_child); virtual void move_child_notify(Node *p_child); + virtual void owner_changed_notify(); void _propagate_replace_owner(Node *p_owner, Node *p_by_owner); |