Ported: Fix editor-only visibility for lights

* Update visibility again for editor-only lights if owner changes.
Fixes #26399, supersedes #52327
- reduz
995281ca90
This commit is contained in:
Relintai 2022-07-29 19:28:33 +02:00
parent 9d76074b58
commit e0e4d0e51d
6 changed files with 20 additions and 0 deletions

View File

@ -81,6 +81,11 @@ Rect2 Light2D::get_anchorable_rect() const {
return Rect2(texture_offset - s / 2.0, s);
}
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;

View File

@ -78,6 +78,8 @@ private:
void _update_light_visibility();
virtual void owner_changed_notify();
protected:
void _notification(int p_what);
static void _bind_methods();

View File

@ -134,6 +134,11 @@ PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const {
return PoolVector<Face3>();
}
void Light::owner_changed_notify() {
// For cases where owner changes _after_ entering tree (as example, editor editing).
_update_visibility();
}
void Light::_update_visibility() {
if (!is_inside_tree()) {
return;

View File

@ -72,6 +72,8 @@ private:
// bind helpers
virtual void owner_changed_notify();
protected:
RID light;

View File

@ -462,6 +462,9 @@ void Node::move_child_notify(Node *p_child) {
// to be used when not wanted
}
void Node::owner_changed_notify() {
}
void Node::_physics_interpolated_changed() {}
void Node::set_physics_process(bool p_process) {
@ -1610,6 +1613,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() {

View File

@ -237,6 +237,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();
virtual void _physics_interpolated_changed();