Debian Codegraph @

scene/3d/visible_on_screen_notifier_3d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* visible_on_screen_notifier_3d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/3d/visual_instance_3d.h"
34
35 class VisibleOnScreenNotifier3D : public VisualInstance3D {
36 GDCLASS(VisibleOnScreenNotifier3D, VisualInstance3D);
37
38 AABB aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2));
39
40 private:
41 bool on_screen = false;
42 void _visibility_enter();
43 void _visibility_exit();
44
45 protected:
46 virtual void _screen_enter() {}
47 virtual void _screen_exit() {}
48
49 void _notification(int p_what);
50 static void _bind_methods();
51
52 public:
53 void set_aabb(const AABB &p_aabb);
54 virtual AABB get_aabb() const override;
55 bool is_on_screen() const;
56
57 VisibleOnScreenNotifier3D();
58 ~VisibleOnScreenNotifier3D();
59 };
60
61 class VisibleOnScreenEnabler3D : public VisibleOnScreenNotifier3D {
62 GDCLASS(VisibleOnScreenEnabler3D, VisibleOnScreenNotifier3D);
63
64 public:
65 enum EnableMode {
66 ENABLE_MODE_INHERIT,
67 ENABLE_MODE_ALWAYS,
68 ENABLE_MODE_WHEN_PAUSED,
69 };
70
71 protected:
72 ObjectID node_id;
73 virtual void _screen_enter() override;
74 virtual void _screen_exit() override;
75
76 EnableMode enable_mode = ENABLE_MODE_INHERIT;
77 NodePath enable_node_path = NodePath("..");
78
79 void _notification(int p_what);
80 static void _bind_methods();
81
82 void _update_enable_mode(bool p_enable);
83
84 public:
85 void set_enable_mode(EnableMode p_mode);
86 EnableMode get_enable_mode();
87
88 void set_enable_node_path(NodePath p_path);
89 NodePath get_enable_node_path();
90
91 VisibleOnScreenEnabler3D();
92 };
93
94 VARIANT_ENUM_CAST(VisibleOnScreenEnabler3D::EnableMode);