1 | /**************************************************************************/ |
2 | /* navigation_region_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 | #ifndef NAVIGATION_REGION_3D_H |
32 | #define NAVIGATION_REGION_3D_H |
33 | |
34 | #include "scene/3d/node_3d.h" |
35 | #include "scene/resources/navigation_mesh.h" |
36 | |
37 | class NavigationRegion3D : public Node3D { |
38 | GDCLASS(NavigationRegion3D, Node3D); |
39 | |
40 | bool enabled = true; |
41 | bool use_edge_connections = true; |
42 | |
43 | RID region; |
44 | RID map_override; |
45 | uint32_t navigation_layers = 1; |
46 | real_t enter_cost = 0.0; |
47 | real_t travel_cost = 1.0; |
48 | Ref<NavigationMesh> navigation_mesh; |
49 | |
50 | Transform3D current_global_transform; |
51 | |
52 | void _navigation_mesh_changed(); |
53 | |
54 | #ifdef DEBUG_ENABLED |
55 | RID debug_instance; |
56 | RID debug_edge_connections_instance; |
57 | Ref<ArrayMesh> debug_mesh; |
58 | Ref<ArrayMesh> debug_edge_connections_mesh; |
59 | |
60 | private: |
61 | void _update_debug_mesh(); |
62 | void _update_debug_edge_connections_mesh(); |
63 | void _navigation_map_changed(RID p_map); |
64 | #endif // DEBUG_ENABLED |
65 | |
66 | protected: |
67 | void _notification(int p_what); |
68 | static void _bind_methods(); |
69 | |
70 | #ifndef DISABLE_DEPRECATED |
71 | bool _set(const StringName &p_name, const Variant &p_value); |
72 | bool _get(const StringName &p_name, Variant &r_ret) const; |
73 | #endif // DISABLE_DEPRECATED |
74 | |
75 | public: |
76 | void set_enabled(bool p_enabled); |
77 | bool is_enabled() const; |
78 | |
79 | void set_navigation_map(RID p_navigation_map); |
80 | RID get_navigation_map() const; |
81 | |
82 | void set_use_edge_connections(bool p_enabled); |
83 | bool get_use_edge_connections() const; |
84 | |
85 | void set_navigation_layers(uint32_t p_navigation_layers); |
86 | uint32_t get_navigation_layers() const; |
87 | |
88 | void set_navigation_layer_value(int p_layer_number, bool p_value); |
89 | bool get_navigation_layer_value(int p_layer_number) const; |
90 | |
91 | RID get_region_rid() const; |
92 | |
93 | void set_enter_cost(real_t p_enter_cost); |
94 | real_t get_enter_cost() const; |
95 | |
96 | void set_travel_cost(real_t p_travel_cost); |
97 | real_t get_travel_cost() const; |
98 | |
99 | void set_navigation_mesh(const Ref<NavigationMesh> &p_navigation_mesh); |
100 | Ref<NavigationMesh> get_navigation_mesh() const; |
101 | |
102 | /// Bakes the navigation mesh; once done, automatically |
103 | /// sets the new navigation mesh and emits a signal |
104 | void bake_navigation_mesh(bool p_on_thread); |
105 | void _bake_finished(Ref<NavigationMesh> p_navigation_mesh); |
106 | |
107 | PackedStringArray get_configuration_warnings() const override; |
108 | |
109 | NavigationRegion3D(); |
110 | ~NavigationRegion3D(); |
111 | |
112 | private: |
113 | void _region_enter_navigation_map(); |
114 | void _region_exit_navigation_map(); |
115 | void _region_update_transform(); |
116 | }; |
117 | |
118 | #endif // NAVIGATION_REGION_3D_H |
119 | |