1 /**
2 Detects approximately when the node is visible on screen.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.visibilitynotifier;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.spatial;
25 import godot.node;
26 /**
27 Detects approximately when the node is visible on screen.
28 
29 The VisibilityNotifier detects when it is visible on the screen. It also notifies when its bounding rectangle enters or exits the screen or a $(D Camera)'s view.
30 If you want nodes to be disabled automatically when they exit the screen, use $(D VisibilityEnabler) instead.
31 $(B Note:) VisibilityNotifier 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 $(D Area) node as a child of a $(D Camera) node and/or $(D Vector3.dot).
32 */
33 @GodotBaseClass struct VisibilityNotifier
34 {
35 	package(godot) enum string _GODOT_internal_name = "VisibilityNotifier";
36 public:
37 @nogc nothrow:
38 	union { /** */ godot_object _godot_object; /** */ Spatial _GODOT_base; }
39 	alias _GODOT_base this;
40 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
41 	package(godot) __gshared bool _classBindingInitialized = false;
42 	package(godot) static struct GDNativeClassBinding
43 	{
44 		__gshared:
45 		@GodotName("get_aabb") GodotMethod!(AABB) getAabb;
46 		@GodotName("is_on_screen") GodotMethod!(bool) isOnScreen;
47 		@GodotName("set_aabb") GodotMethod!(void, AABB) setAabb;
48 	}
49 	/// 
50 	pragma(inline, true) bool opEquals(in VisibilityNotifier other) const
51 	{ return _godot_object.ptr is other._godot_object.ptr; }
52 	/// 
53 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
54 	{ _godot_object.ptr = n; return null; }
55 	/// 
56 	pragma(inline, true) bool opEquals(typeof(null) n) const
57 	{ return _godot_object.ptr is n; }
58 	/// 
59 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
60 	mixin baseCasts;
61 	/// Construct a new instance of VisibilityNotifier.
62 	/// Note: use `memnew!VisibilityNotifier` instead.
63 	static VisibilityNotifier _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("VisibilityNotifier");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(VisibilityNotifier)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/**
72 	
73 	*/
74 	AABB getAabb() const
75 	{
76 		checkClassBinding!(typeof(this))();
77 		return ptrcall!(AABB)(GDNativeClassBinding.getAabb, _godot_object);
78 	}
79 	/**
80 	If `true`, the bounding box is on the screen.
81 	$(B Note:) It takes one frame for the node's visibility to be assessed once added to the scene tree, so this method will return `false` right after it is instantiated, even if it will be on screen in the draw pass.
82 	*/
83 	bool isOnScreen() const
84 	{
85 		checkClassBinding!(typeof(this))();
86 		return ptrcall!(bool)(GDNativeClassBinding.isOnScreen, _godot_object);
87 	}
88 	/**
89 	
90 	*/
91 	void setAabb(in AABB rect)
92 	{
93 		checkClassBinding!(typeof(this))();
94 		ptrcall!(void)(GDNativeClassBinding.setAabb, _godot_object, rect);
95 	}
96 	/**
97 	The VisibilityNotifier's bounding box.
98 	*/
99 	@property AABB aabb()
100 	{
101 		return getAabb();
102 	}
103 	/// ditto
104 	@property void aabb(AABB v)
105 	{
106 		setAabb(v);
107 	}
108 }