diff options
Diffstat (limited to 'scene/3d/visibility_notifier_3d.cpp')
-rw-r--r-- | scene/3d/visibility_notifier_3d.cpp | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp index 2707a0a514..9c2035f1d8 100644 --- a/scene/3d/visibility_notifier_3d.cpp +++ b/scene/3d/visibility_notifier_3d.cpp @@ -37,7 +37,6 @@ #include "scene/scene_string_names.h" void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) { - ERR_FAIL_COND(cameras.has(p_camera)); cameras.insert(p_camera); if (cameras.size() == 1) { @@ -49,7 +48,6 @@ void VisibilityNotifier3D::_enter_camera(Camera3D *p_camera) { } void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) { - ERR_FAIL_COND(!cameras.has(p_camera)); cameras.erase(p_camera); @@ -62,7 +60,6 @@ void VisibilityNotifier3D::_exit_camera(Camera3D *p_camera) { } void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { - if (aabb == p_aabb) return; aabb = p_aabb; @@ -76,35 +73,28 @@ void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { } AABB VisibilityNotifier3D::get_aabb() const { - return aabb; } void VisibilityNotifier3D::_notification(int p_what) { - switch (p_what) { case NOTIFICATION_ENTER_WORLD: { - get_world_3d()->_register_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_TRANSFORM_CHANGED: { - get_world_3d()->_update_notifier(this, get_global_transform().xform(aabb)); } break; case NOTIFICATION_EXIT_WORLD: { - get_world_3d()->_remove_notifier(this); } break; } } bool VisibilityNotifier3D::is_on_screen() const { - return cameras.size() != 0; } void VisibilityNotifier3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier3D::set_aabb); ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier3D::get_aabb); ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier3D::is_on_screen); @@ -118,7 +108,6 @@ void VisibilityNotifier3D::_bind_methods() { } VisibilityNotifier3D::VisibilityNotifier3D() { - aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); set_notify_transform(true); } @@ -126,9 +115,7 @@ VisibilityNotifier3D::VisibilityNotifier3D() { ////////////////////////////////////// void VisibilityEnabler3D::_screen_enter() { - for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), true); } @@ -136,9 +123,7 @@ void VisibilityEnabler3D::_screen_enter() { } void VisibilityEnabler3D::_screen_exit() { - for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) { - _change_node_state(E->key(), false); } @@ -146,14 +131,12 @@ void VisibilityEnabler3D::_screen_exit() { } void VisibilityEnabler3D::_find_nodes(Node *p_node) { - bool add = false; Variant meta; { RigidBody3D *rb = Object::cast_to<RigidBody3D>(p_node); if (rb && ((rb->get_mode() == RigidBody3D::MODE_CHARACTER || rb->get_mode() == RigidBody3D::MODE_RIGID))) { - add = true; meta = rb->get_mode(); } @@ -167,7 +150,6 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) { } if (add) { - p_node->connect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed), varray(p_node), CONNECT_ONESHOT); nodes[p_node] = meta; _change_node_state(p_node, false); @@ -183,9 +165,7 @@ void VisibilityEnabler3D::_find_nodes(Node *p_node) { } void VisibilityEnabler3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; @@ -198,12 +178,10 @@ void VisibilityEnabler3D::_notification(int p_what) { } if (p_what == NOTIFICATION_EXIT_TREE) { - if (Engine::get_singleton()->is_editor_hint()) return; for (Map<Node *, Variant>::Element *E = nodes.front(); E; E = E->next()) { - if (!visible) _change_node_state(E->key(), true); E->key()->disconnect(SceneStringNames::get_singleton()->tree_exiting, callable_mp(this, &VisibilityEnabler3D::_node_removed)); @@ -214,7 +192,6 @@ void VisibilityEnabler3D::_notification(int p_what) { } void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) { - ERR_FAIL_COND(!nodes.has(p_node)); if (enabler[ENABLER_FREEZE_BODIES]) { @@ -228,21 +205,18 @@ void VisibilityEnabler3D::_change_node_state(Node *p_node, bool p_enabled) { AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node); if (ap) { - ap->set_active(p_enabled); } } } void VisibilityEnabler3D::_node_removed(Node *p_node) { - if (!visible) _change_node_state(p_node, true); nodes.erase(p_node); } void VisibilityEnabler3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enabler", "enabler", "enabled"), &VisibilityEnabler3D::set_enabler); ClassDB::bind_method(D_METHOD("is_enabler_enabled", "enabler"), &VisibilityEnabler3D::is_enabler_enabled); @@ -255,18 +229,15 @@ void VisibilityEnabler3D::_bind_methods() { } void VisibilityEnabler3D::set_enabler(Enabler p_enabler, bool p_enable) { - ERR_FAIL_INDEX(p_enabler, ENABLER_MAX); enabler[p_enabler] = p_enable; } bool VisibilityEnabler3D::is_enabler_enabled(Enabler p_enabler) const { - ERR_FAIL_INDEX_V(p_enabler, ENABLER_MAX, false); return enabler[p_enabler]; } VisibilityEnabler3D::VisibilityEnabler3D() { - for (int i = 0; i < ENABLER_MAX; i++) enabler[i] = true; |