summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/visible_on_screen_notifier_3d.cpp (renamed from scene/3d/visibility_notifier_3d.cpp)61
-rw-r--r--scene/3d/visible_on_screen_notifier_3d.h (renamed from scene/3d/visibility_notifier_3d.h)21
2 files changed, 44 insertions, 38 deletions
diff --git a/scene/3d/visibility_notifier_3d.cpp b/scene/3d/visible_on_screen_notifier_3d.cpp
index 39b17d195b..682bcec449 100644
--- a/scene/3d/visibility_notifier_3d.cpp
+++ b/scene/3d/visible_on_screen_notifier_3d.cpp
@@ -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() {
}
diff --git a/scene/3d/visibility_notifier_3d.h b/scene/3d/visible_on_screen_notifier_3d.h
index 878c97e35e..fb7137c4f0 100644
--- a/scene/3d/visibility_notifier_3d.h
+++ b/scene/3d/visible_on_screen_notifier_3d.h
@@ -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