visibility_notifier.h
1 /*************************************************************************/
2 /* visibility_notifier.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
9 /* */
10 /* Permission is hereby granted, free of charge, to any person obtaining */
11 /* a copy of this software and associated documentation files (the */
12 /* "Software"), to deal in the Software without restriction, including */
13 /* without limitation the rights to use, copy, modify, merge, publish, */
14 /* distribute, sublicense, and/or sell copies of the Software, and to */
15 /* permit persons to whom the Software is furnished to do so, subject to */
16 /* the following conditions: */
17 /* */
18 /* The above copyright notice and this permission notice shall be */
19 /* included in all copies or substantial portions of the Software. */
20 /* */
21 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
22 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
23 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
24 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
25 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
26 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
27 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
28 /*************************************************************************/
29 #ifndef VISIBILITY_NOTIFIER_H
30 #define VISIBILITY_NOTIFIER_H
31 
32 #include "scene/3d/spatial.h"
33 
34 class Camera;
35 class VisibilityNotifier : public Spatial {
36 
37  OBJ_TYPE(VisibilityNotifier,Spatial);
38 
39  Set<Camera*> cameras;
40 
41  AABB aabb;
42 
43 protected:
44 
45  virtual void _screen_enter() {}
46  virtual void _screen_exit() {}
47 
48  void _notification(int p_what);
49  static void _bind_methods();
50 friend class SpatialIndexer;
51 
52  void _enter_camera(Camera* p_camera);
53  void _exit_camera(Camera* p_camera);
54 
55 public:
56 
57  void set_aabb(const AABB& p_aabb);
58  AABB get_aabb() const;
59  bool is_on_screen() const;
60 
62 };
63 
64 
66 
68 public:
69 
70  enum Enabler {
71  ENABLER_PAUSE_ANIMATIONS,
72  ENABLER_FREEZE_BODIES,
73  ENABLER_MAX
74  };
75 
76 protected:
77 
78  virtual void _screen_enter();
79  virtual void _screen_exit();
80 
81  bool visible;
82 
83  void _find_nodes(Node* p_node);
84 
85  Map<Node*,Variant> nodes;
86  void _node_removed(Node* p_node);
87  bool enabler[ENABLER_MAX];
88 
89  void _change_node_state(Node* p_node,bool p_enabled);
90 
91  void _notification(int p_what);
92  static void _bind_methods();
93 
94 public:
95 
96  void set_enabler(Enabler p_enabler,bool p_enable);
97  bool is_enabler_enabled(Enabler p_enabler) const;
98 
100 
101 };
102 
103 VARIANT_ENUM_CAST(VisibilityEnabler::Enabler);
104 
105 
106 #endif // VISIBILITY_NOTIFIER_H
Definition: node.h:42
Definition: aabb.h:43
Definition: camera.h:39
Definition: visibility_notifier.h:65
Definition: visibility_notifier.h:35
Definition: world.cpp:37
Definition: spatial.h:56