summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-01-27 21:19:25 +0100
committerGitHub <noreply@github.com>2021-01-27 21:19:25 +0100
commit1ea133b6b58a4cf4ba5c077095a5b59266bac8e4 (patch)
tree406e89dae82c9a4f55364fb37f9ed0937f589acb /scene
parent976e768e71310766ac3927118b15eee03a15cfdb (diff)
parent4d172f1fcab6463f0afce3ed4715f67282523a49 (diff)
Merge pull request #45511 from KoBeWi/apocalypse_(world_crash)
Cache world in VisibilityNotifier3D to avoid crash
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/visibility_notifier_3d.cpp9
-rw-r--r--scene/3d/visibility_notifier_3d.h2
2 files changed, 8 insertions, 3 deletions
diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp
index 494709fe84..14c7659de4 100644
--- a/scene/3d/visibility_notifier_3d.cpp
+++ b/scene/3d/visibility_notifier_3d.cpp
@@ -80,13 +80,16 @@ AABB VisibilityNotifier3D::get_aabb() const {
void VisibilityNotifier3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_WORLD: {
- get_world_3d()->_register_notifier(this, get_global_transform().xform(aabb));
+ world = get_world_3d();
+ ERR_FAIL_COND(!world.is_valid());
+ world->_register_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
- get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb));
+ world->_update_notifier(this, get_global_transform().xform(aabb));
} break;
case NOTIFICATION_EXIT_WORLD: {
- get_world_3d()->_remove_notifier(this);
+ ERR_FAIL_COND(!world.is_valid());
+ world->_remove_notifier(this);
} break;
}
}
diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visibility_notifier_3d.h
index 29552510b7..d566b7e40b 100644
--- a/scene/3d/visibility_notifier_3d.h
+++ b/scene/3d/visibility_notifier_3d.h
@@ -33,10 +33,12 @@
#include "scene/3d/node_3d.h"
+class World3D;
class Camera3D;
class VisibilityNotifier3D : public Node3D {
GDCLASS(VisibilityNotifier3D, Node3D);
+ Ref<World3D> world;
Set<Camera3D *> cameras;
AABB aabb;