diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-06-06 17:18:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-06 17:18:24 +0200 |
commit | 7272ccb53e491c4c851cd0247ea6e3946dafcba7 (patch) | |
tree | f68579ed903460bc5ae5b6f0833d0e44d78dd616 /scene | |
parent | 4d2ecde3e22e2503715b0cec612dd8b767dce77a (diff) | |
parent | 83d931ad3cb2af295b2511fdfa29a00c9efb8c7a (diff) |
Merge pull request #61753 from timothyqiu/own-world
Diffstat (limited to 'scene')
-rw-r--r-- | scene/main/viewport.cpp | 16 | ||||
-rw-r--r-- | scene/main/viewport.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 590c73de0b..7c7809fd75 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3458,8 +3458,8 @@ void Viewport::_own_world_3d_changed() { _update_audio_listener_3d(); } -void Viewport::set_use_own_world_3d(bool p_world_3d) { - if (p_world_3d == own_world_3d.is_valid()) { +void Viewport::set_use_own_world_3d(bool p_use_own_world_3d) { + if (p_use_own_world_3d == own_world_3d.is_valid()) { return; } @@ -3467,18 +3467,18 @@ void Viewport::set_use_own_world_3d(bool p_world_3d) { _propagate_exit_world_3d(this); } - if (!p_world_3d) { - own_world_3d = Ref<World3D>(); - if (world_3d.is_valid()) { - world_3d->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); - } - } else { + if (p_use_own_world_3d) { if (world_3d.is_valid()) { own_world_3d = world_3d->duplicate(); world_3d->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); } else { own_world_3d = Ref<World3D>(memnew(World3D)); } + } else { + own_world_3d = Ref<World3D>(); + if (world_3d.is_valid()) { + world_3d->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &Viewport::_own_world_3d_changed)); + } } if (is_inside_tree()) { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 5bca5a2dda..833b302e97 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -676,7 +676,7 @@ public: Ref<World3D> get_world_3d() const; Ref<World3D> find_world_3d() const; void _own_world_3d_changed(); - void set_use_own_world_3d(bool p_world_3d); + void set_use_own_world_3d(bool p_use_own_world_3d); bool is_using_own_world_3d() const; void _propagate_enter_world_3d(Node *p_node); void _propagate_exit_world_3d(Node *p_node); |