From ab2456b7406d34bb446033de6ce76096f4502c9e Mon Sep 17 00:00:00 2001 From: reduz Date: Wed, 16 Jun 2021 21:52:30 -0300 Subject: Rename VisibilityNotifierXD to VisibleOnScreenNotifierXD * Renames for 2D and 3D * Class name was confusing, given both 2D and 3D have a "visible" property that is unrelated to actual on-screen visibility. * New name makes it clear that this is about visibility on screen. --- doc/classes/VisibilityEnabler2D.xml | 25 ---- doc/classes/VisibilityEnabler3D.xml | 30 ---- doc/classes/VisibilityNotifier2D.xml | 42 ------ doc/classes/VisibilityNotifier3D.xml | 42 ------ doc/classes/VisibleOnScreenEnabler2D.xml | 25 ++++ doc/classes/VisibleOnScreenEnabler3D.xml | 30 ++++ doc/classes/VisibleOnScreenNotifier2D.xml | 42 ++++++ doc/classes/VisibleOnScreenNotifier3D.xml | 42 ++++++ editor/icons/VisibilityEnabler2D.svg | 1 - editor/icons/VisibilityEnabler3D.svg | 1 - editor/icons/VisibilityNotifier2D.svg | 1 - editor/icons/VisibilityNotifier3D.svg | 1 - editor/icons/VisibleOnScreenEnabler2D.svg | 1 + editor/icons/VisibleOnScreenEnabler3D.svg | 1 + editor/icons/VisibleOnScreenNotifier2D.svg | 1 + editor/icons/VisibleOnScreenNotifier3D.svg | 1 + editor/node_3d_editor_gizmos.cpp | 32 ++--- editor/node_3d_editor_gizmos.h | 6 +- editor/plugins/node_3d_editor_plugin.cpp | 2 +- scene/2d/visibility_notifier_2d.cpp | 213 ----------------------------- scene/2d/visibility_notifier_2d.h | 105 -------------- scene/2d/visible_on_screen_notifier_2d.cpp | 213 +++++++++++++++++++++++++++++ scene/2d/visible_on_screen_notifier_2d.h | 105 ++++++++++++++ scene/3d/visibility_notifier_3d.cpp | 198 --------------------------- scene/3d/visibility_notifier_3d.h | 100 -------------- scene/3d/visible_on_screen_notifier_3d.cpp | 203 +++++++++++++++++++++++++++ scene/3d/visible_on_screen_notifier_3d.h | 101 ++++++++++++++ scene/register_scene_types.cpp | 18 +-- scene/resources/world_2d.cpp | 2 +- scene/resources/world_2d.h | 2 +- scene/resources/world_3d.cpp | 2 +- scene/resources/world_3d.h | 2 +- 32 files changed, 799 insertions(+), 791 deletions(-) delete mode 100644 doc/classes/VisibilityEnabler2D.xml delete mode 100644 doc/classes/VisibilityEnabler3D.xml delete mode 100644 doc/classes/VisibilityNotifier2D.xml delete mode 100644 doc/classes/VisibilityNotifier3D.xml create mode 100644 doc/classes/VisibleOnScreenEnabler2D.xml create mode 100644 doc/classes/VisibleOnScreenEnabler3D.xml create mode 100644 doc/classes/VisibleOnScreenNotifier2D.xml create mode 100644 doc/classes/VisibleOnScreenNotifier3D.xml delete mode 100644 editor/icons/VisibilityEnabler2D.svg delete mode 100644 editor/icons/VisibilityEnabler3D.svg delete mode 100644 editor/icons/VisibilityNotifier2D.svg delete mode 100644 editor/icons/VisibilityNotifier3D.svg create mode 100644 editor/icons/VisibleOnScreenEnabler2D.svg create mode 100644 editor/icons/VisibleOnScreenEnabler3D.svg create mode 100644 editor/icons/VisibleOnScreenNotifier2D.svg create mode 100644 editor/icons/VisibleOnScreenNotifier3D.svg delete mode 100644 scene/2d/visibility_notifier_2d.cpp delete mode 100644 scene/2d/visibility_notifier_2d.h create mode 100644 scene/2d/visible_on_screen_notifier_2d.cpp create mode 100644 scene/2d/visible_on_screen_notifier_2d.h delete mode 100644 scene/3d/visibility_notifier_3d.cpp delete mode 100644 scene/3d/visibility_notifier_3d.h create mode 100644 scene/3d/visible_on_screen_notifier_3d.cpp create mode 100644 scene/3d/visible_on_screen_notifier_3d.h diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml deleted file mode 100644 index 8eb16ba075..0000000000 --- a/doc/classes/VisibilityEnabler2D.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doc/classes/VisibilityEnabler3D.xml b/doc/classes/VisibilityEnabler3D.xml deleted file mode 100644 index 4614859a44..0000000000 --- a/doc/classes/VisibilityEnabler3D.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - Enables certain nodes only when approximately visible. - - - The VisibilityEnabler3D will disable [RigidBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler3D itself. - If you just want to receive notifications, use [VisibilityNotifier3D] instead. - [b]Note:[/b] VisibilityEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. - [b]Note:[/b] VisibilityEnabler3D will not affect nodes added after scene initialization. - - - - - - - - - - - - - - - - - - - - diff --git a/doc/classes/VisibilityNotifier2D.xml b/doc/classes/VisibilityNotifier2D.xml deleted file mode 100644 index 78983e74ee..0000000000 --- a/doc/classes/VisibilityNotifier2D.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - Detects when the node extents are visible on screen. - - - The VisibilityNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport. - If you want nodes to be disabled automatically when they exit the screen, use [VisibilityEnabler2D] instead. - - - https://godotengine.org/asset-library/asset/515 - - - - - - - If [code]true[/code], the bounding rectangle is on the screen. - [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. - - - - - - The VisibilityNotifier2D's bounding rectangle. - - - - - - Emitted when the VisibilityNotifier2D enters the screen. - - - - - Emitted when the VisibilityNotifier2D exits the screen. - - - - - - diff --git a/doc/classes/VisibilityNotifier3D.xml b/doc/classes/VisibilityNotifier3D.xml deleted file mode 100644 index bd6c03ea20..0000000000 --- a/doc/classes/VisibilityNotifier3D.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - Detects approximately when the node is visible on screen. - - - The VisibilityNotifier3D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a [Camera3D]'s view. - If you want nodes to be disabled automatically when they exit the screen, use [VisibilityEnabler3D] instead. - [b]Note:[/b] VisibilityNotifier3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. - - - - - - - - - If [code]true[/code], the bounding box is on the screen. - [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. - - - - - - The VisibilityNotifier3D's bounding box. - - - - - - Emitted when the VisibilityNotifier3D enters the screen. - - - - - Emitted when the VisibilityNotifier3D exits the screen. - - - - - - diff --git a/doc/classes/VisibleOnScreenEnabler2D.xml b/doc/classes/VisibleOnScreenEnabler2D.xml new file mode 100644 index 0000000000..c6ae8227d2 --- /dev/null +++ b/doc/classes/VisibleOnScreenEnabler2D.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/VisibleOnScreenEnabler3D.xml b/doc/classes/VisibleOnScreenEnabler3D.xml new file mode 100644 index 0000000000..3205d6b415 --- /dev/null +++ b/doc/classes/VisibleOnScreenEnabler3D.xml @@ -0,0 +1,30 @@ + + + + Enables certain nodes only when approximately visible. + + + The VisibleOnScreenEnabler3D will disable [RigidBody3D] and [AnimationPlayer] nodes when they are not visible. It will only affect other nodes within the same scene as the VisibleOnScreenEnabler3D itself. + If you just want to receive notifications, use [VisibleOnScreenNotifier3D] instead. + [b]Note:[/b] VisibleOnScreenEnabler3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. + [b]Note:[/b] VisibleOnScreenEnabler3D will not affect nodes added after scene initialization. + + + + + + + + + + + + + + + + + + + + diff --git a/doc/classes/VisibleOnScreenNotifier2D.xml b/doc/classes/VisibleOnScreenNotifier2D.xml new file mode 100644 index 0000000000..f2f3bc9144 --- /dev/null +++ b/doc/classes/VisibleOnScreenNotifier2D.xml @@ -0,0 +1,42 @@ + + + + Detects when the node extents are visible on screen. + + + The VisibleOnScreenNotifier2D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a viewport. + If you want nodes to be disabled automatically when they exit the screen, use [VisibleOnScreenEnabler2D] instead. + + + https://godotengine.org/asset-library/asset/515 + + + + + + + If [code]true[/code], the bounding rectangle is on the screen. + [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. + + + + + + The VisibleOnScreenNotifier2D's bounding rectangle. + + + + + + Emitted when the VisibleOnScreenNotifier2D enters the screen. + + + + + Emitted when the VisibleOnScreenNotifier2D exits the screen. + + + + + + diff --git a/doc/classes/VisibleOnScreenNotifier3D.xml b/doc/classes/VisibleOnScreenNotifier3D.xml new file mode 100644 index 0000000000..859dacd716 --- /dev/null +++ b/doc/classes/VisibleOnScreenNotifier3D.xml @@ -0,0 +1,42 @@ + + + + Detects approximately when the node is visible on screen. + + + The VisibleOnScreenNotifier3D detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a [Camera3D]'s view. + If you want nodes to be disabled automatically when they exit the screen, use [VisibleOnScreenEnabler3D] instead. + [b]Note:[/b] VisibleOnScreenNotifier3D uses an approximate heuristic for performance reasons. It doesn't take walls and other occlusion into account. The heuristic is an implementation detail and may change in future versions. If you need precise visibility checking, use another method such as adding an [Area3D] node as a child of a [Camera3D] node and/or [method Vector3.dot]. + + + + + + + + + If [code]true[/code], the bounding box is on the screen. + [b]Note:[/b] It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return [code]false[/code] right after it is instantiated, even if it will be on screen in the draw pass. + + + + + + The VisibleOnScreenNotifier3D's bounding box. + + + + + + Emitted when the VisibleOnScreenNotifier3D enters the screen. + + + + + Emitted when the VisibleOnScreenNotifier3D exits the screen. + + + + + + diff --git a/editor/icons/VisibilityEnabler2D.svg b/editor/icons/VisibilityEnabler2D.svg deleted file mode 100644 index 989675f44f..0000000000 --- a/editor/icons/VisibilityEnabler2D.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/editor/icons/VisibilityEnabler3D.svg b/editor/icons/VisibilityEnabler3D.svg deleted file mode 100644 index 6923bcb46b..0000000000 --- a/editor/icons/VisibilityEnabler3D.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/editor/icons/VisibilityNotifier2D.svg b/editor/icons/VisibilityNotifier2D.svg deleted file mode 100644 index 13df19be56..0000000000 --- a/editor/icons/VisibilityNotifier2D.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/editor/icons/VisibilityNotifier3D.svg b/editor/icons/VisibilityNotifier3D.svg deleted file mode 100644 index 2fdf784701..0000000000 --- a/editor/icons/VisibilityNotifier3D.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/editor/icons/VisibleOnScreenEnabler2D.svg b/editor/icons/VisibleOnScreenEnabler2D.svg new file mode 100644 index 0000000000..989675f44f --- /dev/null +++ b/editor/icons/VisibleOnScreenEnabler2D.svg @@ -0,0 +1 @@ + diff --git a/editor/icons/VisibleOnScreenEnabler3D.svg b/editor/icons/VisibleOnScreenEnabler3D.svg new file mode 100644 index 0000000000..6923bcb46b --- /dev/null +++ b/editor/icons/VisibleOnScreenEnabler3D.svg @@ -0,0 +1 @@ + diff --git a/editor/icons/VisibleOnScreenNotifier2D.svg b/editor/icons/VisibleOnScreenNotifier2D.svg new file mode 100644 index 0000000000..13df19be56 --- /dev/null +++ b/editor/icons/VisibleOnScreenNotifier2D.svg @@ -0,0 +1 @@ + diff --git a/editor/icons/VisibleOnScreenNotifier3D.svg b/editor/icons/VisibleOnScreenNotifier3D.svg new file mode 100644 index 0000000000..2fdf784701 --- /dev/null +++ b/editor/icons/VisibleOnScreenNotifier3D.svg @@ -0,0 +1 @@ + diff --git a/editor/node_3d_editor_gizmos.cpp b/editor/node_3d_editor_gizmos.cpp index 5c69a1e975..19663e46e1 100644 --- a/editor/node_3d_editor_gizmos.cpp +++ b/editor/node_3d_editor_gizmos.cpp @@ -55,7 +55,7 @@ #include "scene/3d/spring_arm_3d.h" #include "scene/3d/sprite_3d.h" #include "scene/3d/vehicle_body_3d.h" -#include "scene/3d/visibility_notifier_3d.h" +#include "scene/3d/visible_on_screen_notifier_3d.h" #include "scene/3d/voxel_gi.h" #include "scene/resources/box_shape_3d.h" #include "scene/resources/capsule_shape_3d.h" @@ -2127,7 +2127,7 @@ bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_giz /////////// -VisibilityNotifier3DGizmoPlugin::VisibilityNotifier3DGizmoPlugin() { +VisibleOnScreenNotifier3DGizmoPlugin::VisibleOnScreenNotifier3DGizmoPlugin() { Color gizmo_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/visibility_notifier", Color(0.8, 0.5, 0.7)); create_material("visibility_notifier_material", gizmo_color); gizmo_color.a = 0.1; @@ -2135,19 +2135,19 @@ VisibilityNotifier3DGizmoPlugin::VisibilityNotifier3DGizmoPlugin() { create_handle_material("handles"); } -bool VisibilityNotifier3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { - return Object::cast_to(p_spatial) != nullptr; +bool VisibleOnScreenNotifier3DGizmoPlugin::has_gizmo(Node3D *p_spatial) { + return Object::cast_to(p_spatial) != nullptr; } -String VisibilityNotifier3DGizmoPlugin::get_gizmo_name() const { - return "VisibilityNotifier3D"; +String VisibleOnScreenNotifier3DGizmoPlugin::get_gizmo_name() const { + return "VisibleOnScreenNotifier3D"; } -int VisibilityNotifier3DGizmoPlugin::get_priority() const { +int VisibleOnScreenNotifier3DGizmoPlugin::get_priority() const { return -1; } -String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { +String VisibleOnScreenNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo *p_gizmo, int p_idx) const { switch (p_idx) { case 0: return "Size X"; @@ -2166,13 +2166,13 @@ String VisibilityNotifier3DGizmoPlugin::get_handle_name(const EditorNode3DGizmo return ""; } -Variant VisibilityNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { - VisibilityNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); +Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const { + VisibleOnScreenNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); return notifier->get_aabb(); } -void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { - VisibilityNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); +void VisibleOnScreenNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) { + VisibleOnScreenNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); Transform3D gt = notifier->get_global_transform(); @@ -2223,8 +2223,8 @@ void VisibilityNotifier3DGizmoPlugin::set_handle(EditorNode3DGizmo *p_gizmo, int } } -void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { - VisibilityNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); +void VisibleOnScreenNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel) { + VisibleOnScreenNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); if (p_cancel) { notifier->set_aabb(p_restore); @@ -2238,8 +2238,8 @@ void VisibilityNotifier3DGizmoPlugin::commit_handle(EditorNode3DGizmo *p_gizmo, ur->commit_action(); } -void VisibilityNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { - VisibilityNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); +void VisibleOnScreenNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) { + VisibleOnScreenNotifier3D *notifier = Object::cast_to(p_gizmo->get_spatial_node()); p_gizmo->clear(); diff --git a/editor/node_3d_editor_gizmos.h b/editor/node_3d_editor_gizmos.h index 8a0e10241a..6f071859ec 100644 --- a/editor/node_3d_editor_gizmos.h +++ b/editor/node_3d_editor_gizmos.h @@ -218,8 +218,8 @@ public: SoftBody3DGizmoPlugin(); }; -class VisibilityNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin { - GDCLASS(VisibilityNotifier3DGizmoPlugin, EditorNode3DGizmoPlugin); +class VisibleOnScreenNotifier3DGizmoPlugin : public EditorNode3DGizmoPlugin { + GDCLASS(VisibleOnScreenNotifier3DGizmoPlugin, EditorNode3DGizmoPlugin); public: bool has_gizmo(Node3D *p_spatial) override; @@ -232,7 +232,7 @@ public: void set_handle(EditorNode3DGizmo *p_gizmo, int p_idx, Camera3D *p_camera, const Point2 &p_point) override; void commit_handle(EditorNode3DGizmo *p_gizmo, int p_idx, const Variant &p_restore, bool p_cancel = false) override; - VisibilityNotifier3DGizmoPlugin(); + VisibleOnScreenNotifier3DGizmoPlugin(); }; class CPUParticles3DGizmoPlugin : public EditorNode3DGizmoPlugin { diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 60cc0a0a2a..726f74e67f 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6492,7 +6492,7 @@ void Node3DEditor::_register_all_gizmos() { add_gizmo_plugin(Ref(memnew(RayCast3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(SpringArm3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(VehicleWheel3DGizmoPlugin))); - add_gizmo_plugin(Ref(memnew(VisibilityNotifier3DGizmoPlugin))); + add_gizmo_plugin(Ref(memnew(VisibleOnScreenNotifier3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(GPUParticles3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(GPUParticlesCollision3DGizmoPlugin))); add_gizmo_plugin(Ref(memnew(CPUParticles3DGizmoPlugin))); diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp deleted file mode 100644 index a73d60ada5..0000000000 --- a/scene/2d/visibility_notifier_2d.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/*************************************************************************/ -/* visibility_notifier_2d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "visibility_notifier_2d.h" - -#include "core/config/engine.h" -#include "gpu_particles_2d.h" -#include "scene/2d/animated_sprite_2d.h" -#include "scene/2d/physics_body_2d.h" -#include "scene/animation/animation_player.h" -#include "scene/main/window.h" -#include "scene/scene_string_names.h" - -#ifdef TOOLS_ENABLED -Rect2 VisibilityNotifier2D::_edit_get_rect() const { - return rect; -} - -bool VisibilityNotifier2D::_edit_use_rect() const { - return true; -} -#endif - -void VisibilityNotifier2D::_visibility_enter() { - if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { - return; - } - - on_screen = true; - emit_signal(SceneStringNames::get_singleton()->screen_entered); - _screen_enter(); -} -void VisibilityNotifier2D::_visibility_exit() { - if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { - return; - } - - on_screen = false; - emit_signal(SceneStringNames::get_singleton()->screen_exited); - _screen_exit(); -} - -void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) { - rect = p_rect; - if (is_inside_tree()) { - RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit)); - } -} - -Rect2 VisibilityNotifier2D::get_rect() const { - return rect; -} - -void VisibilityNotifier2D::_notification(int p_what) { - switch (p_what) { - case NOTIFICATION_ENTER_TREE: { - //get_world_2d()-> - on_screen = false; - RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit)); - } break; - case NOTIFICATION_DRAW: { - if (Engine::get_singleton()->is_editor_hint()) { - draw_rect(rect, Color(1, 0.5, 1, 0.2)); - } - } break; - case NOTIFICATION_EXIT_TREE: { - on_screen = false; - RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), false, Rect2(), Callable(), Callable()); - } break; - } -} - -bool VisibilityNotifier2D::is_on_screen() const { - return on_screen; -} - -void VisibilityNotifier2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibilityNotifier2D::set_rect); - ClassDB::bind_method(D_METHOD("get_rect"), &VisibilityNotifier2D::get_rect); - ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier2D::is_on_screen); - - ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), "set_rect", "get_rect"); - - ADD_SIGNAL(MethodInfo("screen_entered")); - ADD_SIGNAL(MethodInfo("screen_exited")); -} - -VisibilityNotifier2D::VisibilityNotifier2D() { - rect = Rect2(-10, -10, 20, 20); -} - -////////////////////////////////////// - -void VisibilityEnabler2D::_screen_enter() { - _update_enable_mode(true); -} - -void VisibilityEnabler2D::_screen_exit() { - _update_enable_mode(false); -} - -void VisibilityEnabler2D::set_enable_mode(EnableMode p_mode) { - enable_mode = p_mode; - if (is_inside_tree()) { - _update_enable_mode(is_on_screen()); - } -} -VisibilityEnabler2D::EnableMode VisibilityEnabler2D::get_enable_mode() { - return enable_mode; -} - -void VisibilityEnabler2D::set_enable_node_path(NodePath p_path) { - if (enable_node_path == p_path) { - return; - } - enable_node_path = p_path; - if (is_inside_tree()) { - node_id = ObjectID(); - Node *node = get_node(enable_node_path); - if (node) { - node_id = node->get_instance_id(); - _update_enable_mode(is_on_screen()); - } - } -} -NodePath VisibilityEnabler2D::get_enable_node_path() { - return enable_node_path; -} - -void VisibilityEnabler2D::_update_enable_mode(bool p_enable) { - Node *node = static_cast(ObjectDB::get_instance(node_id)); - if (node) { - if (p_enable) { - switch (enable_mode) { - case ENABLE_MODE_INHERIT: { - node->set_process_mode(PROCESS_MODE_INHERIT); - } break; - case ENABLE_MODE_ALWAYS: { - node->set_process_mode(PROCESS_MODE_ALWAYS); - } break; - case ENABLE_MODE_WHEN_PAUSED: { - node->set_process_mode(PROCESS_MODE_WHEN_PAUSED); - } break; - } - } else { - node->set_process_mode(PROCESS_MODE_DISABLED); - } - } -} -void VisibilityEnabler2D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) { - return; - } - - node_id = ObjectID(); - Node *node = get_node(enable_node_path); - if (node) { - node_id = node->get_instance_id(); - node->set_process_mode(PROCESS_MODE_DISABLED); - } - } - - if (p_what == NOTIFICATION_EXIT_TREE) { - node_id = ObjectID(); - } -} - -void VisibilityEnabler2D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibilityEnabler2D::set_enable_mode); - ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibilityEnabler2D::get_enable_mode); - - ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibilityEnabler2D::set_enable_node_path); - ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibilityEnabler2D::get_enable_node_path); - - ADD_GROUP("Enabling", "enable_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "enable_mode", PROPERTY_HINT_ENUM, "Inherit,Always,WhenPaused"), "set_enable_mode", "get_enable_mode"); - ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "enable_node_path"), "set_enable_node_path", "get_enable_node_path"); - - BIND_ENUM_CONSTANT(ENABLE_MODE_INHERIT); - BIND_ENUM_CONSTANT(ENABLE_MODE_ALWAYS); - BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED); -} - -VisibilityEnabler2D::VisibilityEnabler2D() { -} diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h deleted file mode 100644 index 8cb0989787..0000000000 --- a/scene/2d/visibility_notifier_2d.h +++ /dev/null @@ -1,105 +0,0 @@ -/*************************************************************************/ -/* visibility_notifier_2d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef VISIBILITY_NOTIFIER_2D_H -#define VISIBILITY_NOTIFIER_2D_H - -#include "scene/2d/node_2d.h" - -class Viewport; -class VisibilityNotifier2D : public Node2D { - GDCLASS(VisibilityNotifier2D, Node2D); - - Set viewports; - - Rect2 rect; - -private: - bool on_screen = false; - void _visibility_enter(); - void _visibility_exit(); - -protected: - virtual void _screen_enter() {} - virtual void _screen_exit() {} - - void _notification(int p_what); - static void _bind_methods(); - -public: -#ifdef TOOLS_ENABLED - virtual Rect2 _edit_get_rect() const override; - virtual bool _edit_use_rect() const override; -#endif - - void set_rect(const Rect2 &p_rect); - Rect2 get_rect() const; - - bool is_on_screen() const; - - VisibilityNotifier2D(); -}; - -class VisibilityEnabler2D : public VisibilityNotifier2D { - GDCLASS(VisibilityEnabler2D, VisibilityNotifier2D); - -public: - enum EnableMode { - ENABLE_MODE_INHERIT, - ENABLE_MODE_ALWAYS, - ENABLE_MODE_WHEN_PAUSED, - }; - -protected: - ObjectID node_id; - virtual void _screen_enter() override; - virtual void _screen_exit() override; - - EnableMode enable_mode = ENABLE_MODE_INHERIT; - NodePath enable_node_path = NodePath(".."); - - void _notification(int p_what); - static void _bind_methods(); - - void _update_enable_mode(bool p_enable); - -public: - void set_enable_mode(EnableMode p_mode); - EnableMode get_enable_mode(); - - void set_enable_node_path(NodePath p_path); - NodePath get_enable_node_path(); - - VisibilityEnabler2D(); -}; - -VARIANT_ENUM_CAST(VisibilityEnabler2D::EnableMode); - -#endif // VISIBILITY_NOTIFIER_2D_H diff --git a/scene/2d/visible_on_screen_notifier_2d.cpp b/scene/2d/visible_on_screen_notifier_2d.cpp new file mode 100644 index 0000000000..25237edacf --- /dev/null +++ b/scene/2d/visible_on_screen_notifier_2d.cpp @@ -0,0 +1,213 @@ +/*************************************************************************/ +/* visible_on_screen_notifier_2d.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "visible_on_screen_notifier_2d.h" + +#include "core/config/engine.h" +#include "gpu_particles_2d.h" +#include "scene/2d/animated_sprite_2d.h" +#include "scene/2d/physics_body_2d.h" +#include "scene/animation/animation_player.h" +#include "scene/main/window.h" +#include "scene/scene_string_names.h" + +#ifdef TOOLS_ENABLED +Rect2 VisibleOnScreenNotifier2D::_edit_get_rect() const { + return rect; +} + +bool VisibleOnScreenNotifier2D::_edit_use_rect() const { + return true; +} +#endif + +void VisibleOnScreenNotifier2D::_visibility_enter() { + if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { + return; + } + + on_screen = true; + emit_signal(SceneStringNames::get_singleton()->screen_entered); + _screen_enter(); +} +void VisibleOnScreenNotifier2D::_visibility_exit() { + if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { + return; + } + + on_screen = false; + emit_signal(SceneStringNames::get_singleton()->screen_exited); + _screen_exit(); +} + +void VisibleOnScreenNotifier2D::set_rect(const Rect2 &p_rect) { + rect = p_rect; + if (is_inside_tree()) { + RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_exit)); + } +} + +Rect2 VisibleOnScreenNotifier2D::get_rect() const { + return rect; +} + +void VisibleOnScreenNotifier2D::_notification(int p_what) { + switch (p_what) { + case NOTIFICATION_ENTER_TREE: { + //get_world_2d()-> + on_screen = false; + RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), true, rect, callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier2D::_visibility_exit)); + } break; + case NOTIFICATION_DRAW: { + if (Engine::get_singleton()->is_editor_hint()) { + draw_rect(rect, Color(1, 0.5, 1, 0.2)); + } + } break; + case NOTIFICATION_EXIT_TREE: { + on_screen = false; + RS::get_singleton()->canvas_item_set_visibility_notifier(get_canvas_item(), false, Rect2(), Callable(), Callable()); + } break; + } +} + +bool VisibleOnScreenNotifier2D::is_on_screen() const { + return on_screen; +} + +void VisibleOnScreenNotifier2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_rect", "rect"), &VisibleOnScreenNotifier2D::set_rect); + ClassDB::bind_method(D_METHOD("get_rect"), &VisibleOnScreenNotifier2D::get_rect); + ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibleOnScreenNotifier2D::is_on_screen); + + ADD_PROPERTY(PropertyInfo(Variant::RECT2, "rect"), "set_rect", "get_rect"); + + ADD_SIGNAL(MethodInfo("screen_entered")); + ADD_SIGNAL(MethodInfo("screen_exited")); +} + +VisibleOnScreenNotifier2D::VisibleOnScreenNotifier2D() { + rect = Rect2(-10, -10, 20, 20); +} + +////////////////////////////////////// + +void VisibleOnScreenEnabler2D::_screen_enter() { + _update_enable_mode(true); +} + +void VisibleOnScreenEnabler2D::_screen_exit() { + _update_enable_mode(false); +} + +void VisibleOnScreenEnabler2D::set_enable_mode(EnableMode p_mode) { + enable_mode = p_mode; + if (is_inside_tree()) { + _update_enable_mode(is_on_screen()); + } +} +VisibleOnScreenEnabler2D::EnableMode VisibleOnScreenEnabler2D::get_enable_mode() { + return enable_mode; +} + +void VisibleOnScreenEnabler2D::set_enable_node_path(NodePath p_path) { + if (enable_node_path == p_path) { + return; + } + enable_node_path = p_path; + if (is_inside_tree()) { + node_id = ObjectID(); + Node *node = get_node(enable_node_path); + if (node) { + node_id = node->get_instance_id(); + _update_enable_mode(is_on_screen()); + } + } +} +NodePath VisibleOnScreenEnabler2D::get_enable_node_path() { + return enable_node_path; +} + +void VisibleOnScreenEnabler2D::_update_enable_mode(bool p_enable) { + Node *node = static_cast(ObjectDB::get_instance(node_id)); + if (node) { + if (p_enable) { + switch (enable_mode) { + case ENABLE_MODE_INHERIT: { + node->set_process_mode(PROCESS_MODE_INHERIT); + } break; + case ENABLE_MODE_ALWAYS: { + node->set_process_mode(PROCESS_MODE_ALWAYS); + } break; + case ENABLE_MODE_WHEN_PAUSED: { + node->set_process_mode(PROCESS_MODE_WHEN_PAUSED); + } break; + } + } else { + node->set_process_mode(PROCESS_MODE_DISABLED); + } + } +} +void VisibleOnScreenEnabler2D::_notification(int p_what) { + if (p_what == NOTIFICATION_ENTER_TREE) { + if (Engine::get_singleton()->is_editor_hint()) { + return; + } + + node_id = ObjectID(); + Node *node = get_node(enable_node_path); + if (node) { + node_id = node->get_instance_id(); + node->set_process_mode(PROCESS_MODE_DISABLED); + } + } + + if (p_what == NOTIFICATION_EXIT_TREE) { + node_id = ObjectID(); + } +} + +void VisibleOnScreenEnabler2D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibleOnScreenEnabler2D::set_enable_mode); + ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibleOnScreenEnabler2D::get_enable_mode); + + ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibleOnScreenEnabler2D::set_enable_node_path); + ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibleOnScreenEnabler2D::get_enable_node_path); + + ADD_GROUP("Enabling", "enable_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "enable_mode", PROPERTY_HINT_ENUM, "Inherit,Always,WhenPaused"), "set_enable_mode", "get_enable_mode"); + ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "enable_node_path"), "set_enable_node_path", "get_enable_node_path"); + + BIND_ENUM_CONSTANT(ENABLE_MODE_INHERIT); + BIND_ENUM_CONSTANT(ENABLE_MODE_ALWAYS); + BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED); +} + +VisibleOnScreenEnabler2D::VisibleOnScreenEnabler2D() { +} diff --git a/scene/2d/visible_on_screen_notifier_2d.h b/scene/2d/visible_on_screen_notifier_2d.h new file mode 100644 index 0000000000..9c236a138f --- /dev/null +++ b/scene/2d/visible_on_screen_notifier_2d.h @@ -0,0 +1,105 @@ +/*************************************************************************/ +/* visible_on_screen_notifier_2d.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef VISIBLE_ON_SCREEN_NOTIFIER_2D_H +#define VISIBLE_ON_SCREEN_NOTIFIER_2D_H + +#include "scene/2d/node_2d.h" + +class Viewport; +class VisibleOnScreenNotifier2D : public Node2D { + GDCLASS(VisibleOnScreenNotifier2D, Node2D); + + Set viewports; + + Rect2 rect; + +private: + bool on_screen = false; + void _visibility_enter(); + void _visibility_exit(); + +protected: + virtual void _screen_enter() {} + virtual void _screen_exit() {} + + void _notification(int p_what); + static void _bind_methods(); + +public: +#ifdef TOOLS_ENABLED + virtual Rect2 _edit_get_rect() const override; + virtual bool _edit_use_rect() const override; +#endif + + void set_rect(const Rect2 &p_rect); + Rect2 get_rect() const; + + bool is_on_screen() const; + + VisibleOnScreenNotifier2D(); +}; + +class VisibleOnScreenEnabler2D : public VisibleOnScreenNotifier2D { + GDCLASS(VisibleOnScreenEnabler2D, VisibleOnScreenNotifier2D); + +public: + enum EnableMode { + ENABLE_MODE_INHERIT, + ENABLE_MODE_ALWAYS, + ENABLE_MODE_WHEN_PAUSED, + }; + +protected: + ObjectID node_id; + virtual void _screen_enter() override; + virtual void _screen_exit() override; + + EnableMode enable_mode = ENABLE_MODE_INHERIT; + NodePath enable_node_path = NodePath(".."); + + void _notification(int p_what); + static void _bind_methods(); + + void _update_enable_mode(bool p_enable); + +public: + void set_enable_mode(EnableMode p_mode); + EnableMode get_enable_mode(); + + void set_enable_node_path(NodePath p_path); + NodePath get_enable_node_path(); + + VisibleOnScreenEnabler2D(); +}; + +VARIANT_ENUM_CAST(VisibleOnScreenEnabler2D::EnableMode); + +#endif // VISIBILITY_NOTIFIER_2D_H diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visibility_notifier_3d.cpp deleted file mode 100644 index 39b17d195b..0000000000 --- a/scene/3d/visibility_notifier_3d.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/*************************************************************************/ -/* visibility_notifier_3d.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "visibility_notifier_3d.h" - -#include "core/config/engine.h" -#include "scene/3d/camera_3d.h" -#include "scene/3d/physics_body_3d.h" -#include "scene/animation/animation_player.h" -#include "scene/scene_string_names.h" - -void VisibilityNotifier3D::_visibility_enter() { - if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { - return; - } - - on_screen = true; - emit_signal(SceneStringNames::get_singleton()->screen_entered); - _screen_enter(); -} -void VisibilityNotifier3D::_visibility_exit() { - if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { - return; - } - - on_screen = false; - emit_signal(SceneStringNames::get_singleton()->screen_exited); - _screen_exit(); -} - -void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) { - if (aabb == p_aabb) { - return; - } - aabb = p_aabb; - - RS::get_singleton()->visibility_notifier_set_aabb(get_base(), aabb); - - update_gizmo(); -} - -AABB VisibilityNotifier3D::get_aabb() const { - return aabb; -} - -bool VisibilityNotifier3D::is_on_screen() const { - return on_screen; -} - -void VisibilityNotifier3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_EXIT_TREE) { - on_screen = false; - } -} - -void VisibilityNotifier3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibilityNotifier3D::set_aabb); - ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier3D::is_on_screen); - - ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); - - ADD_SIGNAL(MethodInfo("screen_entered")); - ADD_SIGNAL(MethodInfo("screen_exited")); -} - -Vector VisibilityNotifier3D::get_faces(uint32_t p_usage_flags) const { - return Vector(); -} - -VisibilityNotifier3D::VisibilityNotifier3D() { - RID notifier = RS::get_singleton()->visibility_notifier_create(); - RS::get_singleton()->visibility_notifier_set_aabb(notifier, aabb); - RS::get_singleton()->visibility_notifier_set_callbacks(notifier, callable_mp(this, &VisibilityNotifier3D::_visibility_enter), callable_mp(this, &VisibilityNotifier3D::_visibility_exit)); - set_base(notifier); -} - -////////////////////////////////////// - -void VisibilityEnabler3D::_screen_enter() { - _update_enable_mode(true); -} - -void VisibilityEnabler3D::_screen_exit() { - _update_enable_mode(false); -} - -void VisibilityEnabler3D::set_enable_mode(EnableMode p_mode) { - enable_mode = p_mode; - if (is_inside_tree()) { - _update_enable_mode(is_on_screen()); - } -} -VisibilityEnabler3D::EnableMode VisibilityEnabler3D::get_enable_mode() { - return enable_mode; -} - -void VisibilityEnabler3D::set_enable_node_path(NodePath p_path) { - if (enable_node_path == p_path) { - return; - } - enable_node_path = p_path; - if (is_inside_tree()) { - node_id = ObjectID(); - Node *node = get_node(enable_node_path); - if (node) { - node_id = node->get_instance_id(); - _update_enable_mode(is_on_screen()); - } - } -} -NodePath VisibilityEnabler3D::get_enable_node_path() { - return enable_node_path; -} - -void VisibilityEnabler3D::_update_enable_mode(bool p_enable) { - Node *node = static_cast(ObjectDB::get_instance(node_id)); - if (node) { - if (p_enable) { - switch (enable_mode) { - case ENABLE_MODE_INHERIT: { - node->set_process_mode(PROCESS_MODE_INHERIT); - } break; - case ENABLE_MODE_ALWAYS: { - node->set_process_mode(PROCESS_MODE_ALWAYS); - } break; - case ENABLE_MODE_WHEN_PAUSED: { - node->set_process_mode(PROCESS_MODE_WHEN_PAUSED); - } break; - } - } else { - node->set_process_mode(PROCESS_MODE_DISABLED); - } - } -} -void VisibilityEnabler3D::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { - if (Engine::get_singleton()->is_editor_hint()) { - return; - } - - node_id = ObjectID(); - Node *node = get_node(enable_node_path); - if (node) { - node_id = node->get_instance_id(); - node->set_process_mode(PROCESS_MODE_DISABLED); - } - } - - if (p_what == NOTIFICATION_EXIT_TREE) { - node_id = ObjectID(); - } -} - -void VisibilityEnabler3D::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibilityEnabler3D::set_enable_mode); - ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibilityEnabler3D::get_enable_mode); - - ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibilityEnabler3D::set_enable_node_path); - ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibilityEnabler3D::get_enable_node_path); - - ADD_GROUP("Enabling", "enable_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "enable_mode", PROPERTY_HINT_ENUM, "Inherit,Always,WhenPaused"), "set_enable_mode", "get_enable_mode"); - ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "enable_node_path"), "set_enable_node_path", "get_enable_node_path"); - - BIND_ENUM_CONSTANT(ENABLE_MODE_INHERIT); - BIND_ENUM_CONSTANT(ENABLE_MODE_ALWAYS); - BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED); -} - -VisibilityEnabler3D::VisibilityEnabler3D() { -} diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visibility_notifier_3d.h deleted file mode 100644 index 878c97e35e..0000000000 --- a/scene/3d/visibility_notifier_3d.h +++ /dev/null @@ -1,100 +0,0 @@ -/*************************************************************************/ -/* visibility_notifier_3d.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef VISIBILITY_NOTIFIER_H -#define VISIBILITY_NOTIFIER_H - -#include "scene/3d/visual_instance_3d.h" - -class World3D; -class Camera3D; -class VisibilityNotifier3D : public VisualInstance3D { - GDCLASS(VisibilityNotifier3D, VisualInstance3D); - - AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); - -private: - bool on_screen = false; - void _visibility_enter(); - void _visibility_exit(); - -protected: - virtual void _screen_enter() {} - virtual void _screen_exit() {} - - void _notification(int p_what); - static void _bind_methods(); - -public: - void set_aabb(const AABB &p_aabb); - virtual AABB get_aabb() const override; - bool is_on_screen() const; - - virtual Vector get_faces(uint32_t p_usage_flags) const override; - - VisibilityNotifier3D(); -}; - -class VisibilityEnabler3D : public VisibilityNotifier3D { - GDCLASS(VisibilityEnabler3D, VisibilityNotifier3D); - -public: - enum EnableMode { - ENABLE_MODE_INHERIT, - ENABLE_MODE_ALWAYS, - ENABLE_MODE_WHEN_PAUSED, - }; - -protected: - ObjectID node_id; - virtual void _screen_enter() override; - virtual void _screen_exit() override; - - EnableMode enable_mode = ENABLE_MODE_INHERIT; - NodePath enable_node_path = NodePath(".."); - - void _notification(int p_what); - static void _bind_methods(); - - void _update_enable_mode(bool p_enable); - -public: - void set_enable_mode(EnableMode p_mode); - EnableMode get_enable_mode(); - - void set_enable_node_path(NodePath p_path); - NodePath get_enable_node_path(); - - VisibilityEnabler3D(); -}; - -VARIANT_ENUM_CAST(VisibilityEnabler3D::EnableMode); - -#endif // VISIBILITY_NOTIFIER_H diff --git a/scene/3d/visible_on_screen_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp new file mode 100644 index 0000000000..682bcec449 --- /dev/null +++ b/scene/3d/visible_on_screen_notifier_3d.cpp @@ -0,0 +1,203 @@ +/*************************************************************************/ +/* visible_on_screen_notifier_3d.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "visible_on_screen_notifier_3d.h" + +#include "core/config/engine.h" +#include "scene/3d/camera_3d.h" +#include "scene/3d/physics_body_3d.h" +#include "scene/animation/animation_player.h" +#include "scene/scene_string_names.h" + +void VisibleOnScreenNotifier3D::_visibility_enter() { + if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { + return; + } + + on_screen = true; + emit_signal(SceneStringNames::get_singleton()->screen_entered); + _screen_enter(); +} +void VisibleOnScreenNotifier3D::_visibility_exit() { + if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) { + return; + } + + on_screen = false; + emit_signal(SceneStringNames::get_singleton()->screen_exited); + _screen_exit(); +} + +void VisibleOnScreenNotifier3D::set_aabb(const AABB &p_aabb) { + if (aabb == p_aabb) { + return; + } + aabb = p_aabb; + + RS::get_singleton()->visibility_notifier_set_aabb(get_base(), aabb); + + update_gizmo(); +} + +AABB VisibleOnScreenNotifier3D::get_aabb() const { + return aabb; +} + +bool VisibleOnScreenNotifier3D::is_on_screen() const { + return on_screen; +} + +void VisibleOnScreenNotifier3D::_notification(int p_what) { + if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_EXIT_TREE) { + on_screen = false; + } +} + +void VisibleOnScreenNotifier3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_aabb", "rect"), &VisibleOnScreenNotifier3D::set_aabb); + ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibleOnScreenNotifier3D::is_on_screen); + + ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); + + ADD_SIGNAL(MethodInfo("screen_entered")); + ADD_SIGNAL(MethodInfo("screen_exited")); +} + +Vector VisibleOnScreenNotifier3D::get_faces(uint32_t p_usage_flags) const { + return Vector(); +} + +VisibleOnScreenNotifier3D::VisibleOnScreenNotifier3D() { + RID notifier = RS::get_singleton()->visibility_notifier_create(); + RS::get_singleton()->visibility_notifier_set_aabb(notifier, aabb); + RS::get_singleton()->visibility_notifier_set_callbacks(notifier, callable_mp(this, &VisibleOnScreenNotifier3D::_visibility_enter), callable_mp(this, &VisibleOnScreenNotifier3D::_visibility_exit)); + set_base(notifier); +} +VisibleOnScreenNotifier3D::~VisibleOnScreenNotifier3D() { + RID base = get_base(); + set_base(RID()); + RS::get_singleton()->free(base); +} + +////////////////////////////////////// + +void VisibleOnScreenEnabler3D::_screen_enter() { + _update_enable_mode(true); +} + +void VisibleOnScreenEnabler3D::_screen_exit() { + _update_enable_mode(false); +} + +void VisibleOnScreenEnabler3D::set_enable_mode(EnableMode p_mode) { + enable_mode = p_mode; + if (is_inside_tree()) { + _update_enable_mode(is_on_screen()); + } +} +VisibleOnScreenEnabler3D::EnableMode VisibleOnScreenEnabler3D::get_enable_mode() { + return enable_mode; +} + +void VisibleOnScreenEnabler3D::set_enable_node_path(NodePath p_path) { + if (enable_node_path == p_path) { + return; + } + enable_node_path = p_path; + if (is_inside_tree()) { + node_id = ObjectID(); + Node *node = get_node(enable_node_path); + if (node) { + node_id = node->get_instance_id(); + _update_enable_mode(is_on_screen()); + } + } +} +NodePath VisibleOnScreenEnabler3D::get_enable_node_path() { + return enable_node_path; +} + +void VisibleOnScreenEnabler3D::_update_enable_mode(bool p_enable) { + Node *node = static_cast(ObjectDB::get_instance(node_id)); + if (node) { + if (p_enable) { + switch (enable_mode) { + case ENABLE_MODE_INHERIT: { + node->set_process_mode(PROCESS_MODE_INHERIT); + } break; + case ENABLE_MODE_ALWAYS: { + node->set_process_mode(PROCESS_MODE_ALWAYS); + } break; + case ENABLE_MODE_WHEN_PAUSED: { + node->set_process_mode(PROCESS_MODE_WHEN_PAUSED); + } break; + } + } else { + node->set_process_mode(PROCESS_MODE_DISABLED); + } + } +} +void VisibleOnScreenEnabler3D::_notification(int p_what) { + if (p_what == NOTIFICATION_ENTER_TREE) { + if (Engine::get_singleton()->is_editor_hint()) { + return; + } + + node_id = ObjectID(); + Node *node = get_node(enable_node_path); + if (node) { + node_id = node->get_instance_id(); + node->set_process_mode(PROCESS_MODE_DISABLED); + } + } + + if (p_what == NOTIFICATION_EXIT_TREE) { + node_id = ObjectID(); + } +} + +void VisibleOnScreenEnabler3D::_bind_methods() { + ClassDB::bind_method(D_METHOD("set_enable_mode", "mode"), &VisibleOnScreenEnabler3D::set_enable_mode); + ClassDB::bind_method(D_METHOD("get_enable_mode"), &VisibleOnScreenEnabler3D::get_enable_mode); + + ClassDB::bind_method(D_METHOD("set_enable_node_path", "path"), &VisibleOnScreenEnabler3D::set_enable_node_path); + ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibleOnScreenEnabler3D::get_enable_node_path); + + ADD_GROUP("Enabling", "enable_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "enable_mode", PROPERTY_HINT_ENUM, "Inherit,Always,WhenPaused"), "set_enable_mode", "get_enable_mode"); + ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "enable_node_path"), "set_enable_node_path", "get_enable_node_path"); + + BIND_ENUM_CONSTANT(ENABLE_MODE_INHERIT); + BIND_ENUM_CONSTANT(ENABLE_MODE_ALWAYS); + BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED); +} + +VisibleOnScreenEnabler3D::VisibleOnScreenEnabler3D() { +} diff --git a/scene/3d/visible_on_screen_notifier_3d.h b/scene/3d/visible_on_screen_notifier_3d.h new file mode 100644 index 0000000000..fb7137c4f0 --- /dev/null +++ b/scene/3d/visible_on_screen_notifier_3d.h @@ -0,0 +1,101 @@ +/*************************************************************************/ +/* visible_on_screen_notifier_3d.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef VISIBLE_ON_SCREEN_NOTIFIER_3D_H +#define VISIBLE_ON_SCREEN_NOTIFIER_3D_H + +#include "scene/3d/visual_instance_3d.h" + +class World3D; +class Camera3D; +class VisibleOnScreenNotifier3D : public VisualInstance3D { + GDCLASS(VisibleOnScreenNotifier3D, VisualInstance3D); + + AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + +private: + bool on_screen = false; + void _visibility_enter(); + void _visibility_exit(); + +protected: + virtual void _screen_enter() {} + virtual void _screen_exit() {} + + void _notification(int p_what); + static void _bind_methods(); + +public: + void set_aabb(const AABB &p_aabb); + virtual AABB get_aabb() const override; + bool is_on_screen() const; + + virtual Vector get_faces(uint32_t p_usage_flags) const override; + + VisibleOnScreenNotifier3D(); + ~VisibleOnScreenNotifier3D(); +}; + +class VisibleOnScreenEnabler3D : public VisibleOnScreenNotifier3D { + GDCLASS(VisibleOnScreenEnabler3D, VisibleOnScreenNotifier3D); + +public: + enum EnableMode { + ENABLE_MODE_INHERIT, + ENABLE_MODE_ALWAYS, + ENABLE_MODE_WHEN_PAUSED, + }; + +protected: + ObjectID node_id; + virtual void _screen_enter() override; + virtual void _screen_exit() override; + + EnableMode enable_mode = ENABLE_MODE_INHERIT; + NodePath enable_node_path = NodePath(".."); + + void _notification(int p_what); + static void _bind_methods(); + + void _update_enable_mode(bool p_enable); + +public: + void set_enable_mode(EnableMode p_mode); + EnableMode get_enable_mode(); + + void set_enable_node_path(NodePath p_path); + NodePath get_enable_node_path(); + + VisibleOnScreenEnabler3D(); +}; + +VARIANT_ENUM_CAST(VisibleOnScreenEnabler3D::EnableMode); + +#endif // VISIBILITY_NOTIFIER_H diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 332976a18d..2a97ae3acf 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -65,7 +65,7 @@ #include "scene/2d/sprite_2d.h" #include "scene/2d/tile_map.h" #include "scene/2d/touch_screen_button.h" -#include "scene/2d/visibility_notifier_2d.h" +#include "scene/2d/visible_on_screen_notifier_2d.h" #include "scene/animation/animation_blend_space_1d.h" #include "scene/animation/animation_blend_space_2d.h" #include "scene/animation/animation_blend_tree.h" @@ -229,7 +229,7 @@ #include "scene/3d/spring_arm_3d.h" #include "scene/3d/sprite_3d.h" #include "scene/3d/vehicle_body_3d.h" -#include "scene/3d/visibility_notifier_3d.h" +#include "scene/3d/visible_on_screen_notifier_3d.h" #include "scene/3d/voxel_gi.h" #include "scene/3d/world_environment.h" #include "scene/3d/xr_nodes.h" @@ -513,8 +513,8 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -655,8 +655,8 @@ void register_scene_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); @@ -966,8 +966,8 @@ void register_scene_types() { ClassDB::add_compatibility_class("VehicleWheel", "VehicleWheel3D"); ClassDB::add_compatibility_class("ViewportContainer", "SubViewportContainer"); ClassDB::add_compatibility_class("Viewport", "SubViewport"); - ClassDB::add_compatibility_class("VisibilityEnabler", "VisibilityEnabler3D"); - ClassDB::add_compatibility_class("VisibilityNotifier", "VisibilityNotifier3D"); + ClassDB::add_compatibility_class("VisibilityEnabler", "VisibleOnScreenEnabler3D"); + ClassDB::add_compatibility_class("VisibilityNotifier", "VisibleOnScreenNotifier3D"); ClassDB::add_compatibility_class("VisualServer", "RenderingServer"); ClassDB::add_compatibility_class("VisualShaderNodeScalarConstant", "VisualShaderNodeFloatConstant"); ClassDB::add_compatibility_class("VisualShaderNodeScalarFunc", "VisualShaderNodeFloatFunc"); @@ -986,6 +986,8 @@ void register_scene_types() { ClassDB::add_compatibility_class("World", "World3D"); ClassDB::add_compatibility_class("StreamTexture", "StreamTexture2D"); ClassDB::add_compatibility_class("Light2D", "PointLight2D"); + ClassDB::add_compatibility_class("VisibilityNotifier2D", "VisibleOnScreenNotifier2D"); + ClassDB::add_compatibility_class("VisibilityNotifier3D", "VisibleOnScreenNotifier3D"); #endif /* DISABLE_DEPRECATED */ diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp index 9a7a47f884..8af4deda83 100644 --- a/scene/resources/world_2d.cpp +++ b/scene/resources/world_2d.cpp @@ -32,7 +32,7 @@ #include "core/config/project_settings.h" #include "scene/2d/camera_2d.h" -#include "scene/2d/visibility_notifier_2d.h" +#include "scene/2d/visible_on_screen_notifier_2d.h" #include "scene/main/window.h" #include "servers/navigation_server_2d.h" #include "servers/physics_server_2d.h" diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h index e31ac22351..65f89c8f64 100644 --- a/scene/resources/world_2d.h +++ b/scene/resources/world_2d.h @@ -35,7 +35,7 @@ #include "core/io/resource.h" #include "servers/physics_server_2d.h" -class VisibilityNotifier2D; +class VisibleOnScreenNotifier2D; class Viewport; struct SpatialIndexer2D; diff --git a/scene/resources/world_3d.cpp b/scene/resources/world_3d.cpp index a85bd8fdba..8d9b1fd6ec 100644 --- a/scene/resources/world_3d.cpp +++ b/scene/resources/world_3d.cpp @@ -33,7 +33,7 @@ #include "core/math/camera_matrix.h" #include "core/math/octree.h" #include "scene/3d/camera_3d.h" -#include "scene/3d/visibility_notifier_3d.h" +#include "scene/3d/visible_on_screen_notifier_3d.h" #include "scene/scene_string_names.h" #include "servers/navigation_server_3d.h" diff --git a/scene/resources/world_3d.h b/scene/resources/world_3d.h index da5ed486b0..2c5be35609 100644 --- a/scene/resources/world_3d.h +++ b/scene/resources/world_3d.h @@ -38,7 +38,7 @@ #include "servers/rendering_server.h" class Camera3D; -class VisibilityNotifier3D; +class VisibleOnScreenNotifier3D; struct SpatialIndexer; class World3D : public Resource { -- cgit v1.2.3