Skip to content

Commit

Permalink
Merge pull request #62335 from reduz/fix-editor-only-visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jun 23, 2022
2 parents cac4e39 + d69e379 commit 49d061f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions scene/2d/light_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions scene/2d/light_2d.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Light2D : public Node2D {

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);
Expand Down
5 changes: 5 additions & 0 deletions scene/3d/light_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions scene/3d/light_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class Light3D : public VisualInstance3D {

// bind helpers

virtual void owner_changed_notify() override;

protected:
RID light;

Expand Down
5 changes: 5 additions & 0 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ class Node : public Object {
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);

Expand Down

0 comments on commit 49d061f

Please sign in to comment.