Cache world in VisibilityNotifier3D to avoid crash
(cherry picked from commit 4d172f1fca
)
This commit is contained in:
parent
8c22d5a973
commit
7a6ab8c558
2 changed files with 8 additions and 3 deletions
|
@ -85,15 +85,18 @@ void VisibilityNotifier::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_WORLD: {
|
case NOTIFICATION_ENTER_WORLD: {
|
||||||
|
|
||||||
get_world()->_register_notifier(this, get_global_transform().xform(aabb));
|
world = get_world();
|
||||||
|
ERR_FAIL_COND(!world.is_valid());
|
||||||
|
world->_register_notifier(this, get_global_transform().xform(aabb));
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_TRANSFORM_CHANGED: {
|
case NOTIFICATION_TRANSFORM_CHANGED: {
|
||||||
|
|
||||||
get_world()->_update_notifier(this, get_global_transform().xform(aabb));
|
world->_update_notifier(this, get_global_transform().xform(aabb));
|
||||||
} break;
|
} break;
|
||||||
case NOTIFICATION_EXIT_WORLD: {
|
case NOTIFICATION_EXIT_WORLD: {
|
||||||
|
|
||||||
get_world()->_remove_notifier(this);
|
ERR_FAIL_COND(!world.is_valid());
|
||||||
|
world->_remove_notifier(this);
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,13 @@
|
||||||
|
|
||||||
#include "scene/3d/spatial.h"
|
#include "scene/3d/spatial.h"
|
||||||
|
|
||||||
|
class World;
|
||||||
class Camera;
|
class Camera;
|
||||||
class VisibilityNotifier : public Spatial {
|
class VisibilityNotifier : public Spatial {
|
||||||
|
|
||||||
GDCLASS(VisibilityNotifier, Spatial);
|
GDCLASS(VisibilityNotifier, Spatial);
|
||||||
|
|
||||||
|
Ref<World> world;
|
||||||
Set<Camera *> cameras;
|
Set<Camera *> cameras;
|
||||||
|
|
||||||
AABB aabb;
|
AABB aabb;
|
||||||
|
|
Loading…
Reference in a new issue