Merge pull request #49670 from reduz/rename-visibility-notifiers

Rename VisibilityNotifier2D/3D to VisibleOnScreenNotifier2D/3D
This commit is contained in:
Rémi Verschelde 2021-06-17 15:14:44 +02:00 committed by GitHub
commit 085e1d3c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 164 additions and 156 deletions

View File

@ -1,30 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisibilityEnabler3D" inherits="VisibilityNotifier3D" version="4.0">
<brief_description>
Enables certain nodes only when approximately visible.
</brief_description>
<description>
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.
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="enable_mode" type="int" setter="set_enable_mode" getter="get_enable_mode" enum="VisibilityEnabler3D.EnableMode" default="0">
</member>
<member name="enable_node_path" type="NodePath" setter="set_enable_node_path" getter="get_enable_node_path" default="NodePath(&quot;..&quot;)">
</member>
</members>
<constants>
<constant name="ENABLE_MODE_INHERIT" value="0" enum="EnableMode">
</constant>
<constant name="ENABLE_MODE_ALWAYS" value="1" enum="EnableMode">
</constant>
<constant name="ENABLE_MODE_WHEN_PAUSED" value="2" enum="EnableMode">
</constant>
</constants>
</class>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisibilityEnabler2D" inherits="VisibilityNotifier2D" version="4.0">
<class name="VisibleOnScreenEnabler2D" inherits="VisibleOnScreenNotifier2D" version="4.0">
<brief_description>
</brief_description>
<description>
@ -9,7 +9,7 @@
<methods>
</methods>
<members>
<member name="enable_mode" type="int" setter="set_enable_mode" getter="get_enable_mode" enum="VisibilityEnabler2D.EnableMode" default="0">
<member name="enable_mode" type="int" setter="set_enable_mode" getter="get_enable_mode" enum="VisibleOnScreenEnabler2D.EnableMode" default="0">
</member>
<member name="enable_node_path" type="NodePath" setter="set_enable_node_path" getter="get_enable_node_path" default="NodePath(&quot;..&quot;)">
</member>

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisibleOnScreenEnabler3D" inherits="VisibleOnScreenNotifier3D" version="4.0">
<brief_description>
Enables certain nodes only when approximately visible.
</brief_description>
<description>
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.
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<members>
<member name="enable_mode" type="int" setter="set_enable_mode" getter="get_enable_mode" enum="VisibleOnScreenEnabler3D.EnableMode" default="0">
</member>
<member name="enable_node_path" type="NodePath" setter="set_enable_node_path" getter="get_enable_node_path" default="NodePath(&quot;..&quot;)">
</member>
</members>
<constants>
<constant name="ENABLE_MODE_INHERIT" value="0" enum="EnableMode">
</constant>
<constant name="ENABLE_MODE_ALWAYS" value="1" enum="EnableMode">
</constant>
<constant name="ENABLE_MODE_WHEN_PAUSED" value="2" enum="EnableMode">
</constant>
</constants>
</class>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisibilityNotifier2D" inherits="Node2D" version="4.0">
<class name="VisibleOnScreenNotifier2D" inherits="Node2D" version="4.0">
<brief_description>
Detects when the node extents are visible on screen.
</brief_description>
<description>
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.
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.
</description>
<tutorials>
<link title="2D Dodge The Creeps Demo">https://godotengine.org/asset-library/asset/515</link>
@ -22,18 +22,18 @@
</methods>
<members>
<member name="rect" type="Rect2" setter="set_rect" getter="get_rect" default="Rect2( -10, -10, 20, 20 )">
The VisibilityNotifier2D's bounding rectangle.
The VisibleOnScreenNotifier2D's bounding rectangle.
</member>
</members>
<signals>
<signal name="screen_entered">
<description>
Emitted when the VisibilityNotifier2D enters the screen.
Emitted when the VisibleOnScreenNotifier2D enters the screen.
</description>
</signal>
<signal name="screen_exited">
<description>
Emitted when the VisibilityNotifier2D exits the screen.
Emitted when the VisibleOnScreenNotifier2D exits the screen.
</description>
</signal>
</signals>

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VisibilityNotifier3D" inherits="VisualInstance3D" version="4.0">
<class name="VisibleOnScreenNotifier3D" inherits="VisualInstance3D" version="4.0">
<brief_description>
Detects approximately when the node is visible on screen.
</brief_description>
<description>
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].
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].
</description>
<tutorials>
</tutorials>
@ -22,18 +22,18 @@
</methods>
<members>
<member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb" default="AABB( -1, -1, -1, 2, 2, 2 )">
The VisibilityNotifier3D's bounding box.
The VisibleOnScreenNotifier3D's bounding box.
</member>
</members>
<signals>
<signal name="screen_entered">
<description>
Emitted when the VisibilityNotifier3D enters the screen.
Emitted when the VisibleOnScreenNotifier3D enters the screen.
</description>
</signal>
<signal name="screen_exited">
<description>
Emitted when the VisibilityNotifier3D exits the screen.
Emitted when the VisibleOnScreenNotifier3D exits the screen.
</description>
</signal>
</signals>

View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

View File

Before

Width:  |  Height:  |  Size: 511 B

After

Width:  |  Height:  |  Size: 511 B

View File

Before

Width:  |  Height:  |  Size: 533 B

After

Width:  |  Height:  |  Size: 533 B

View File

@ -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<VisibilityNotifier3D>(p_spatial) != nullptr;
bool VisibleOnScreenNotifier3DGizmoPlugin::has_gizmo(Node3D *p_spatial) {
return Object::cast_to<VisibleOnScreenNotifier3D>(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<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
Variant VisibleOnScreenNotifier3DGizmoPlugin::get_handle_value(EditorNode3DGizmo *p_gizmo, int p_idx) const {
VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(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<VisibilityNotifier3D>(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<VisibleOnScreenNotifier3D>(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<VisibilityNotifier3D>(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<VisibleOnScreenNotifier3D>(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<VisibilityNotifier3D>(p_gizmo->get_spatial_node());
void VisibleOnScreenNotifier3DGizmoPlugin::redraw(EditorNode3DGizmo *p_gizmo) {
VisibleOnScreenNotifier3D *notifier = Object::cast_to<VisibleOnScreenNotifier3D>(p_gizmo->get_spatial_node());
p_gizmo->clear();

View File

@ -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 {

View File

@ -6492,7 +6492,7 @@ void Node3DEditor::_register_all_gizmos() {
add_gizmo_plugin(Ref<RayCast3DGizmoPlugin>(memnew(RayCast3DGizmoPlugin)));
add_gizmo_plugin(Ref<SpringArm3DGizmoPlugin>(memnew(SpringArm3DGizmoPlugin)));
add_gizmo_plugin(Ref<VehicleWheel3DGizmoPlugin>(memnew(VehicleWheel3DGizmoPlugin)));
add_gizmo_plugin(Ref<VisibilityNotifier3DGizmoPlugin>(memnew(VisibilityNotifier3DGizmoPlugin)));
add_gizmo_plugin(Ref<VisibleOnScreenNotifier3DGizmoPlugin>(memnew(VisibleOnScreenNotifier3DGizmoPlugin)));
add_gizmo_plugin(Ref<GPUParticles3DGizmoPlugin>(memnew(GPUParticles3DGizmoPlugin)));
add_gizmo_plugin(Ref<GPUParticlesCollision3DGizmoPlugin>(memnew(GPUParticlesCollision3DGizmoPlugin)));
add_gizmo_plugin(Ref<CPUParticles3DGizmoPlugin>(memnew(CPUParticles3DGizmoPlugin)));

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* visibility_notifier_2d.cpp */
/* visible_on_screen_notifier_2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visibility_notifier_2d.h"
#include "visible_on_screen_notifier_2d.h"
#include "core/config/engine.h"
#include "gpu_particles_2d.h"
@ -39,16 +39,16 @@
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
Rect2 VisibilityNotifier2D::_edit_get_rect() const {
Rect2 VisibleOnScreenNotifier2D::_edit_get_rect() const {
return rect;
}
bool VisibilityNotifier2D::_edit_use_rect() const {
bool VisibleOnScreenNotifier2D::_edit_use_rect() const {
return true;
}
#endif
void VisibilityNotifier2D::_visibility_enter() {
void VisibleOnScreenNotifier2D::_visibility_enter() {
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
return;
}
@ -57,7 +57,7 @@ void VisibilityNotifier2D::_visibility_enter() {
emit_signal(SceneStringNames::get_singleton()->screen_entered);
_screen_enter();
}
void VisibilityNotifier2D::_visibility_exit() {
void VisibleOnScreenNotifier2D::_visibility_exit() {
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
return;
}
@ -67,23 +67,23 @@ void VisibilityNotifier2D::_visibility_exit() {
_screen_exit();
}
void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) {
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, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit));
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 VisibilityNotifier2D::get_rect() const {
Rect2 VisibleOnScreenNotifier2D::get_rect() const {
return rect;
}
void VisibilityNotifier2D::_notification(int p_what) {
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, &VisibilityNotifier2D::_visibility_enter), callable_mp(this, &VisibilityNotifier2D::_visibility_exit));
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()) {
@ -97,14 +97,14 @@ void VisibilityNotifier2D::_notification(int p_what) {
}
}
bool VisibilityNotifier2D::is_on_screen() const {
bool VisibleOnScreenNotifier2D::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);
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");
@ -112,31 +112,31 @@ void VisibilityNotifier2D::_bind_methods() {
ADD_SIGNAL(MethodInfo("screen_exited"));
}
VisibilityNotifier2D::VisibilityNotifier2D() {
VisibleOnScreenNotifier2D::VisibleOnScreenNotifier2D() {
rect = Rect2(-10, -10, 20, 20);
}
//////////////////////////////////////
void VisibilityEnabler2D::_screen_enter() {
void VisibleOnScreenEnabler2D::_screen_enter() {
_update_enable_mode(true);
}
void VisibilityEnabler2D::_screen_exit() {
void VisibleOnScreenEnabler2D::_screen_exit() {
_update_enable_mode(false);
}
void VisibilityEnabler2D::set_enable_mode(EnableMode p_mode) {
void VisibleOnScreenEnabler2D::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() {
VisibleOnScreenEnabler2D::EnableMode VisibleOnScreenEnabler2D::get_enable_mode() {
return enable_mode;
}
void VisibilityEnabler2D::set_enable_node_path(NodePath p_path) {
void VisibleOnScreenEnabler2D::set_enable_node_path(NodePath p_path) {
if (enable_node_path == p_path) {
return;
}
@ -150,11 +150,11 @@ void VisibilityEnabler2D::set_enable_node_path(NodePath p_path) {
}
}
}
NodePath VisibilityEnabler2D::get_enable_node_path() {
NodePath VisibleOnScreenEnabler2D::get_enable_node_path() {
return enable_node_path;
}
void VisibilityEnabler2D::_update_enable_mode(bool p_enable) {
void VisibleOnScreenEnabler2D::_update_enable_mode(bool p_enable) {
Node *node = static_cast<Node *>(ObjectDB::get_instance(node_id));
if (node) {
if (p_enable) {
@ -174,7 +174,7 @@ void VisibilityEnabler2D::_update_enable_mode(bool p_enable) {
}
}
}
void VisibilityEnabler2D::_notification(int p_what) {
void VisibleOnScreenEnabler2D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
if (Engine::get_singleton()->is_editor_hint()) {
return;
@ -193,12 +193,12 @@ void VisibilityEnabler2D::_notification(int p_what) {
}
}
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);
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"), &VisibilityEnabler2D::set_enable_node_path);
ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibilityEnabler2D::get_enable_node_path);
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");
@ -209,5 +209,5 @@ void VisibilityEnabler2D::_bind_methods() {
BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED);
}
VisibilityEnabler2D::VisibilityEnabler2D() {
VisibleOnScreenEnabler2D::VisibleOnScreenEnabler2D() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* visibility_notifier_2d.h */
/* visible_on_screen_notifier_2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISIBILITY_NOTIFIER_2D_H
#define VISIBILITY_NOTIFIER_2D_H
#ifndef VISIBLE_ON_SCREEN_NOTIFIER_2D_H
#define VISIBLE_ON_SCREEN_NOTIFIER_2D_H
#include "scene/2d/node_2d.h"
class Viewport;
class VisibilityNotifier2D : public Node2D {
GDCLASS(VisibilityNotifier2D, Node2D);
class VisibleOnScreenNotifier2D : public Node2D {
GDCLASS(VisibleOnScreenNotifier2D, Node2D);
Set<Viewport *> viewports;
@ -64,11 +64,11 @@ public:
bool is_on_screen() const;
VisibilityNotifier2D();
VisibleOnScreenNotifier2D();
};
class VisibilityEnabler2D : public VisibilityNotifier2D {
GDCLASS(VisibilityEnabler2D, VisibilityNotifier2D);
class VisibleOnScreenEnabler2D : public VisibleOnScreenNotifier2D {
GDCLASS(VisibleOnScreenEnabler2D, VisibleOnScreenNotifier2D);
public:
enum EnableMode {
@ -97,9 +97,9 @@ public:
void set_enable_node_path(NodePath p_path);
NodePath get_enable_node_path();
VisibilityEnabler2D();
VisibleOnScreenEnabler2D();
};
VARIANT_ENUM_CAST(VisibilityEnabler2D::EnableMode);
VARIANT_ENUM_CAST(VisibleOnScreenEnabler2D::EnableMode);
#endif // VISIBILITY_NOTIFIER_2D_H

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* visibility_notifier_3d.cpp */
/* visible_on_screen_notifier_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "visibility_notifier_3d.h"
#include "visible_on_screen_notifier_3d.h"
#include "core/config/engine.h"
#include "scene/3d/camera_3d.h"
@ -36,7 +36,7 @@
#include "scene/animation/animation_player.h"
#include "scene/scene_string_names.h"
void VisibilityNotifier3D::_visibility_enter() {
void VisibleOnScreenNotifier3D::_visibility_enter() {
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
return;
}
@ -45,7 +45,7 @@ void VisibilityNotifier3D::_visibility_enter() {
emit_signal(SceneStringNames::get_singleton()->screen_entered);
_screen_enter();
}
void VisibilityNotifier3D::_visibility_exit() {
void VisibleOnScreenNotifier3D::_visibility_exit() {
if (!is_inside_tree() || Engine::get_singleton()->is_editor_hint()) {
return;
}
@ -55,7 +55,7 @@ void VisibilityNotifier3D::_visibility_exit() {
_screen_exit();
}
void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
void VisibleOnScreenNotifier3D::set_aabb(const AABB &p_aabb) {
if (aabb == p_aabb) {
return;
}
@ -66,23 +66,23 @@ void VisibilityNotifier3D::set_aabb(const AABB &p_aabb) {
update_gizmo();
}
AABB VisibilityNotifier3D::get_aabb() const {
AABB VisibleOnScreenNotifier3D::get_aabb() const {
return aabb;
}
bool VisibilityNotifier3D::is_on_screen() const {
bool VisibleOnScreenNotifier3D::is_on_screen() const {
return on_screen;
}
void VisibilityNotifier3D::_notification(int p_what) {
void VisibleOnScreenNotifier3D::_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);
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");
@ -90,38 +90,43 @@ void VisibilityNotifier3D::_bind_methods() {
ADD_SIGNAL(MethodInfo("screen_exited"));
}
Vector<Face3> VisibilityNotifier3D::get_faces(uint32_t p_usage_flags) const {
Vector<Face3> VisibleOnScreenNotifier3D::get_faces(uint32_t p_usage_flags) const {
return Vector<Face3>();
}
VisibilityNotifier3D::VisibilityNotifier3D() {
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, &VisibilityNotifier3D::_visibility_enter), callable_mp(this, &VisibilityNotifier3D::_visibility_exit));
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 VisibilityEnabler3D::_screen_enter() {
void VisibleOnScreenEnabler3D::_screen_enter() {
_update_enable_mode(true);
}
void VisibilityEnabler3D::_screen_exit() {
void VisibleOnScreenEnabler3D::_screen_exit() {
_update_enable_mode(false);
}
void VisibilityEnabler3D::set_enable_mode(EnableMode p_mode) {
void VisibleOnScreenEnabler3D::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() {
VisibleOnScreenEnabler3D::EnableMode VisibleOnScreenEnabler3D::get_enable_mode() {
return enable_mode;
}
void VisibilityEnabler3D::set_enable_node_path(NodePath p_path) {
void VisibleOnScreenEnabler3D::set_enable_node_path(NodePath p_path) {
if (enable_node_path == p_path) {
return;
}
@ -135,11 +140,11 @@ void VisibilityEnabler3D::set_enable_node_path(NodePath p_path) {
}
}
}
NodePath VisibilityEnabler3D::get_enable_node_path() {
NodePath VisibleOnScreenEnabler3D::get_enable_node_path() {
return enable_node_path;
}
void VisibilityEnabler3D::_update_enable_mode(bool p_enable) {
void VisibleOnScreenEnabler3D::_update_enable_mode(bool p_enable) {
Node *node = static_cast<Node *>(ObjectDB::get_instance(node_id));
if (node) {
if (p_enable) {
@ -159,7 +164,7 @@ void VisibilityEnabler3D::_update_enable_mode(bool p_enable) {
}
}
}
void VisibilityEnabler3D::_notification(int p_what) {
void VisibleOnScreenEnabler3D::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
if (Engine::get_singleton()->is_editor_hint()) {
return;
@ -178,12 +183,12 @@ void VisibilityEnabler3D::_notification(int p_what) {
}
}
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);
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"), &VisibilityEnabler3D::set_enable_node_path);
ClassDB::bind_method(D_METHOD("get_enable_node_path"), &VisibilityEnabler3D::get_enable_node_path);
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");
@ -194,5 +199,5 @@ void VisibilityEnabler3D::_bind_methods() {
BIND_ENUM_CONSTANT(ENABLE_MODE_WHEN_PAUSED);
}
VisibilityEnabler3D::VisibilityEnabler3D() {
VisibleOnScreenEnabler3D::VisibleOnScreenEnabler3D() {
}

View File

@ -1,5 +1,5 @@
/*************************************************************************/
/* visibility_notifier_3d.h */
/* visible_on_screen_notifier_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@ -28,15 +28,15 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef VISIBILITY_NOTIFIER_H
#define VISIBILITY_NOTIFIER_H
#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 VisibilityNotifier3D : public VisualInstance3D {
GDCLASS(VisibilityNotifier3D, VisualInstance3D);
class VisibleOnScreenNotifier3D : public VisualInstance3D {
GDCLASS(VisibleOnScreenNotifier3D, VisualInstance3D);
AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
@ -59,11 +59,12 @@ public:
virtual Vector<Face3> get_faces(uint32_t p_usage_flags) const override;
VisibilityNotifier3D();
VisibleOnScreenNotifier3D();
~VisibleOnScreenNotifier3D();
};
class VisibilityEnabler3D : public VisibilityNotifier3D {
GDCLASS(VisibilityEnabler3D, VisibilityNotifier3D);
class VisibleOnScreenEnabler3D : public VisibleOnScreenNotifier3D {
GDCLASS(VisibleOnScreenEnabler3D, VisibleOnScreenNotifier3D);
public:
enum EnableMode {
@ -92,9 +93,9 @@ public:
void set_enable_node_path(NodePath p_path);
NodePath get_enable_node_path();
VisibilityEnabler3D();
VisibleOnScreenEnabler3D();
};
VARIANT_ENUM_CAST(VisibilityEnabler3D::EnableMode);
VARIANT_ENUM_CAST(VisibleOnScreenEnabler3D::EnableMode);
#endif // VISIBILITY_NOTIFIER_H

View File

@ -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<Curve3D>();
ClassDB::register_class<Path3D>();
ClassDB::register_class<PathFollow3D>();
ClassDB::register_class<VisibilityNotifier3D>();
ClassDB::register_class<VisibilityEnabler3D>();
ClassDB::register_class<VisibleOnScreenNotifier3D>();
ClassDB::register_class<VisibleOnScreenEnabler3D>();
ClassDB::register_class<WorldEnvironment>();
ClassDB::register_class<RemoteTransform3D>();
@ -655,8 +655,8 @@ void register_scene_types() {
ClassDB::register_class<CollisionShape2D>();
ClassDB::register_class<CollisionPolygon2D>();
ClassDB::register_class<RayCast2D>();
ClassDB::register_class<VisibilityNotifier2D>();
ClassDB::register_class<VisibilityEnabler2D>();
ClassDB::register_class<VisibleOnScreenNotifier2D>();
ClassDB::register_class<VisibleOnScreenEnabler2D>();
ClassDB::register_class<Polygon2D>();
ClassDB::register_class<Skeleton2D>();
ClassDB::register_class<Bone2D>();
@ -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 */

View File

@ -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"

View File

@ -35,7 +35,7 @@
#include "core/io/resource.h"
#include "servers/physics_server_2d.h"
class VisibilityNotifier2D;
class VisibleOnScreenNotifier2D;
class Viewport;
struct SpatialIndexer2D;

View File

@ -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"

View File

@ -38,7 +38,7 @@
#include "servers/rendering_server.h"
class Camera3D;
class VisibilityNotifier3D;
class VisibleOnScreenNotifier3D;
struct SpatialIndexer;
class World3D : public Resource {