Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/servers/navigation_server_3d.cpp
9887 views
1
/**************************************************************************/
2
/* navigation_server_3d.cpp */
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
#include "navigation_server_3d.h"
32
#include "navigation_server_3d.compat.inc"
33
34
#include "core/config/project_settings.h"
35
#include "scene/main/node.h"
36
#include "servers/navigation/navigation_globals.h"
37
#include "servers/navigation_server_3d_dummy.h"
38
39
NavigationServer3D *NavigationServer3D::singleton = nullptr;
40
41
RWLock NavigationServer3D::geometry_parser_rwlock;
42
RID_Owner<NavMeshGeometryParser3D> NavigationServer3D::geometry_parser_owner;
43
LocalVector<NavMeshGeometryParser3D *> NavigationServer3D::generator_parsers;
44
45
void NavigationServer3D::_bind_methods() {
46
ClassDB::bind_method(D_METHOD("get_maps"), &NavigationServer3D::get_maps);
47
48
ClassDB::bind_method(D_METHOD("map_create"), &NavigationServer3D::map_create);
49
ClassDB::bind_method(D_METHOD("map_set_active", "map", "active"), &NavigationServer3D::map_set_active);
50
ClassDB::bind_method(D_METHOD("map_is_active", "map"), &NavigationServer3D::map_is_active);
51
ClassDB::bind_method(D_METHOD("map_set_up", "map", "up"), &NavigationServer3D::map_set_up);
52
ClassDB::bind_method(D_METHOD("map_get_up", "map"), &NavigationServer3D::map_get_up);
53
ClassDB::bind_method(D_METHOD("map_set_cell_size", "map", "cell_size"), &NavigationServer3D::map_set_cell_size);
54
ClassDB::bind_method(D_METHOD("map_get_cell_size", "map"), &NavigationServer3D::map_get_cell_size);
55
ClassDB::bind_method(D_METHOD("map_set_cell_height", "map", "cell_height"), &NavigationServer3D::map_set_cell_height);
56
ClassDB::bind_method(D_METHOD("map_get_cell_height", "map"), &NavigationServer3D::map_get_cell_height);
57
ClassDB::bind_method(D_METHOD("map_set_merge_rasterizer_cell_scale", "map", "scale"), &NavigationServer3D::map_set_merge_rasterizer_cell_scale);
58
ClassDB::bind_method(D_METHOD("map_get_merge_rasterizer_cell_scale", "map"), &NavigationServer3D::map_get_merge_rasterizer_cell_scale);
59
ClassDB::bind_method(D_METHOD("map_set_use_edge_connections", "map", "enabled"), &NavigationServer3D::map_set_use_edge_connections);
60
ClassDB::bind_method(D_METHOD("map_get_use_edge_connections", "map"), &NavigationServer3D::map_get_use_edge_connections);
61
ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin", "map", "margin"), &NavigationServer3D::map_set_edge_connection_margin);
62
ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin", "map"), &NavigationServer3D::map_get_edge_connection_margin);
63
ClassDB::bind_method(D_METHOD("map_set_link_connection_radius", "map", "radius"), &NavigationServer3D::map_set_link_connection_radius);
64
ClassDB::bind_method(D_METHOD("map_get_link_connection_radius", "map"), &NavigationServer3D::map_get_link_connection_radius);
65
ClassDB::bind_method(D_METHOD("map_get_path", "map", "origin", "destination", "optimize", "navigation_layers"), &NavigationServer3D::map_get_path, DEFVAL(1));
66
ClassDB::bind_method(D_METHOD("map_get_closest_point_to_segment", "map", "start", "end", "use_collision"), &NavigationServer3D::map_get_closest_point_to_segment, DEFVAL(false));
67
ClassDB::bind_method(D_METHOD("map_get_closest_point", "map", "to_point"), &NavigationServer3D::map_get_closest_point);
68
ClassDB::bind_method(D_METHOD("map_get_closest_point_normal", "map", "to_point"), &NavigationServer3D::map_get_closest_point_normal);
69
ClassDB::bind_method(D_METHOD("map_get_closest_point_owner", "map", "to_point"), &NavigationServer3D::map_get_closest_point_owner);
70
71
ClassDB::bind_method(D_METHOD("map_get_links", "map"), &NavigationServer3D::map_get_links);
72
ClassDB::bind_method(D_METHOD("map_get_regions", "map"), &NavigationServer3D::map_get_regions);
73
ClassDB::bind_method(D_METHOD("map_get_agents", "map"), &NavigationServer3D::map_get_agents);
74
ClassDB::bind_method(D_METHOD("map_get_obstacles", "map"), &NavigationServer3D::map_get_obstacles);
75
76
ClassDB::bind_method(D_METHOD("map_force_update", "map"), &NavigationServer3D::map_force_update);
77
ClassDB::bind_method(D_METHOD("map_get_iteration_id", "map"), &NavigationServer3D::map_get_iteration_id);
78
ClassDB::bind_method(D_METHOD("map_set_use_async_iterations", "map", "enabled"), &NavigationServer3D::map_set_use_async_iterations);
79
ClassDB::bind_method(D_METHOD("map_get_use_async_iterations", "map"), &NavigationServer3D::map_get_use_async_iterations);
80
81
ClassDB::bind_method(D_METHOD("map_get_random_point", "map", "navigation_layers", "uniformly"), &NavigationServer3D::map_get_random_point);
82
83
ClassDB::bind_method(D_METHOD("query_path", "parameters", "result", "callback"), &NavigationServer3D::query_path, DEFVAL(Callable()));
84
85
ClassDB::bind_method(D_METHOD("region_create"), &NavigationServer3D::region_create);
86
ClassDB::bind_method(D_METHOD("region_get_iteration_id", "region"), &NavigationServer3D::region_get_iteration_id);
87
ClassDB::bind_method(D_METHOD("region_set_use_async_iterations", "region", "enabled"), &NavigationServer3D::region_set_use_async_iterations);
88
ClassDB::bind_method(D_METHOD("region_get_use_async_iterations", "region"), &NavigationServer3D::region_get_use_async_iterations);
89
ClassDB::bind_method(D_METHOD("region_set_enabled", "region", "enabled"), &NavigationServer3D::region_set_enabled);
90
ClassDB::bind_method(D_METHOD("region_get_enabled", "region"), &NavigationServer3D::region_get_enabled);
91
ClassDB::bind_method(D_METHOD("region_set_use_edge_connections", "region", "enabled"), &NavigationServer3D::region_set_use_edge_connections);
92
ClassDB::bind_method(D_METHOD("region_get_use_edge_connections", "region"), &NavigationServer3D::region_get_use_edge_connections);
93
ClassDB::bind_method(D_METHOD("region_set_enter_cost", "region", "enter_cost"), &NavigationServer3D::region_set_enter_cost);
94
ClassDB::bind_method(D_METHOD("region_get_enter_cost", "region"), &NavigationServer3D::region_get_enter_cost);
95
ClassDB::bind_method(D_METHOD("region_set_travel_cost", "region", "travel_cost"), &NavigationServer3D::region_set_travel_cost);
96
ClassDB::bind_method(D_METHOD("region_get_travel_cost", "region"), &NavigationServer3D::region_get_travel_cost);
97
ClassDB::bind_method(D_METHOD("region_set_owner_id", "region", "owner_id"), &NavigationServer3D::region_set_owner_id);
98
ClassDB::bind_method(D_METHOD("region_get_owner_id", "region"), &NavigationServer3D::region_get_owner_id);
99
ClassDB::bind_method(D_METHOD("region_owns_point", "region", "point"), &NavigationServer3D::region_owns_point);
100
ClassDB::bind_method(D_METHOD("region_set_map", "region", "map"), &NavigationServer3D::region_set_map);
101
ClassDB::bind_method(D_METHOD("region_get_map", "region"), &NavigationServer3D::region_get_map);
102
ClassDB::bind_method(D_METHOD("region_set_navigation_layers", "region", "navigation_layers"), &NavigationServer3D::region_set_navigation_layers);
103
ClassDB::bind_method(D_METHOD("region_get_navigation_layers", "region"), &NavigationServer3D::region_get_navigation_layers);
104
ClassDB::bind_method(D_METHOD("region_set_transform", "region", "transform"), &NavigationServer3D::region_set_transform);
105
ClassDB::bind_method(D_METHOD("region_get_transform", "region"), &NavigationServer3D::region_get_transform);
106
ClassDB::bind_method(D_METHOD("region_set_navigation_mesh", "region", "navigation_mesh"), &NavigationServer3D::region_set_navigation_mesh);
107
#ifndef DISABLE_DEPRECATED
108
ClassDB::bind_method(D_METHOD("region_bake_navigation_mesh", "navigation_mesh", "root_node"), &NavigationServer3D::region_bake_navigation_mesh);
109
#endif // DISABLE_DEPRECATED
110
ClassDB::bind_method(D_METHOD("region_get_connections_count", "region"), &NavigationServer3D::region_get_connections_count);
111
ClassDB::bind_method(D_METHOD("region_get_connection_pathway_start", "region", "connection"), &NavigationServer3D::region_get_connection_pathway_start);
112
ClassDB::bind_method(D_METHOD("region_get_connection_pathway_end", "region", "connection"), &NavigationServer3D::region_get_connection_pathway_end);
113
ClassDB::bind_method(D_METHOD("region_get_closest_point_to_segment", "region", "start", "end", "use_collision"), &NavigationServer3D::region_get_closest_point_to_segment, DEFVAL(false));
114
ClassDB::bind_method(D_METHOD("region_get_closest_point", "region", "to_point"), &NavigationServer3D::region_get_closest_point);
115
ClassDB::bind_method(D_METHOD("region_get_closest_point_normal", "region", "to_point"), &NavigationServer3D::region_get_closest_point_normal);
116
ClassDB::bind_method(D_METHOD("region_get_random_point", "region", "navigation_layers", "uniformly"), &NavigationServer3D::region_get_random_point);
117
ClassDB::bind_method(D_METHOD("region_get_bounds", "region"), &NavigationServer3D::region_get_bounds);
118
119
ClassDB::bind_method(D_METHOD("link_create"), &NavigationServer3D::link_create);
120
ClassDB::bind_method(D_METHOD("link_get_iteration_id", "link"), &NavigationServer3D::link_get_iteration_id);
121
ClassDB::bind_method(D_METHOD("link_set_map", "link", "map"), &NavigationServer3D::link_set_map);
122
ClassDB::bind_method(D_METHOD("link_get_map", "link"), &NavigationServer3D::link_get_map);
123
ClassDB::bind_method(D_METHOD("link_set_enabled", "link", "enabled"), &NavigationServer3D::link_set_enabled);
124
ClassDB::bind_method(D_METHOD("link_get_enabled", "link"), &NavigationServer3D::link_get_enabled);
125
ClassDB::bind_method(D_METHOD("link_set_bidirectional", "link", "bidirectional"), &NavigationServer3D::link_set_bidirectional);
126
ClassDB::bind_method(D_METHOD("link_is_bidirectional", "link"), &NavigationServer3D::link_is_bidirectional);
127
ClassDB::bind_method(D_METHOD("link_set_navigation_layers", "link", "navigation_layers"), &NavigationServer3D::link_set_navigation_layers);
128
ClassDB::bind_method(D_METHOD("link_get_navigation_layers", "link"), &NavigationServer3D::link_get_navigation_layers);
129
ClassDB::bind_method(D_METHOD("link_set_start_position", "link", "position"), &NavigationServer3D::link_set_start_position);
130
ClassDB::bind_method(D_METHOD("link_get_start_position", "link"), &NavigationServer3D::link_get_start_position);
131
ClassDB::bind_method(D_METHOD("link_set_end_position", "link", "position"), &NavigationServer3D::link_set_end_position);
132
ClassDB::bind_method(D_METHOD("link_get_end_position", "link"), &NavigationServer3D::link_get_end_position);
133
ClassDB::bind_method(D_METHOD("link_set_enter_cost", "link", "enter_cost"), &NavigationServer3D::link_set_enter_cost);
134
ClassDB::bind_method(D_METHOD("link_get_enter_cost", "link"), &NavigationServer3D::link_get_enter_cost);
135
ClassDB::bind_method(D_METHOD("link_set_travel_cost", "link", "travel_cost"), &NavigationServer3D::link_set_travel_cost);
136
ClassDB::bind_method(D_METHOD("link_get_travel_cost", "link"), &NavigationServer3D::link_get_travel_cost);
137
ClassDB::bind_method(D_METHOD("link_set_owner_id", "link", "owner_id"), &NavigationServer3D::link_set_owner_id);
138
ClassDB::bind_method(D_METHOD("link_get_owner_id", "link"), &NavigationServer3D::link_get_owner_id);
139
140
ClassDB::bind_method(D_METHOD("agent_create"), &NavigationServer3D::agent_create);
141
ClassDB::bind_method(D_METHOD("agent_set_avoidance_enabled", "agent", "enabled"), &NavigationServer3D::agent_set_avoidance_enabled);
142
ClassDB::bind_method(D_METHOD("agent_get_avoidance_enabled", "agent"), &NavigationServer3D::agent_get_avoidance_enabled);
143
ClassDB::bind_method(D_METHOD("agent_set_use_3d_avoidance", "agent", "enabled"), &NavigationServer3D::agent_set_use_3d_avoidance);
144
ClassDB::bind_method(D_METHOD("agent_get_use_3d_avoidance", "agent"), &NavigationServer3D::agent_get_use_3d_avoidance);
145
146
ClassDB::bind_method(D_METHOD("agent_set_map", "agent", "map"), &NavigationServer3D::agent_set_map);
147
ClassDB::bind_method(D_METHOD("agent_get_map", "agent"), &NavigationServer3D::agent_get_map);
148
ClassDB::bind_method(D_METHOD("agent_set_paused", "agent", "paused"), &NavigationServer3D::agent_set_paused);
149
ClassDB::bind_method(D_METHOD("agent_get_paused", "agent"), &NavigationServer3D::agent_get_paused);
150
ClassDB::bind_method(D_METHOD("agent_set_neighbor_distance", "agent", "distance"), &NavigationServer3D::agent_set_neighbor_distance);
151
ClassDB::bind_method(D_METHOD("agent_get_neighbor_distance", "agent"), &NavigationServer3D::agent_get_neighbor_distance);
152
ClassDB::bind_method(D_METHOD("agent_set_max_neighbors", "agent", "count"), &NavigationServer3D::agent_set_max_neighbors);
153
ClassDB::bind_method(D_METHOD("agent_get_max_neighbors", "agent"), &NavigationServer3D::agent_get_max_neighbors);
154
ClassDB::bind_method(D_METHOD("agent_set_time_horizon_agents", "agent", "time_horizon"), &NavigationServer3D::agent_set_time_horizon_agents);
155
ClassDB::bind_method(D_METHOD("agent_get_time_horizon_agents", "agent"), &NavigationServer3D::agent_get_time_horizon_agents);
156
ClassDB::bind_method(D_METHOD("agent_set_time_horizon_obstacles", "agent", "time_horizon"), &NavigationServer3D::agent_set_time_horizon_obstacles);
157
ClassDB::bind_method(D_METHOD("agent_get_time_horizon_obstacles", "agent"), &NavigationServer3D::agent_get_time_horizon_obstacles);
158
ClassDB::bind_method(D_METHOD("agent_set_radius", "agent", "radius"), &NavigationServer3D::agent_set_radius);
159
ClassDB::bind_method(D_METHOD("agent_get_radius", "agent"), &NavigationServer3D::agent_get_radius);
160
ClassDB::bind_method(D_METHOD("agent_set_height", "agent", "height"), &NavigationServer3D::agent_set_height);
161
ClassDB::bind_method(D_METHOD("agent_get_height", "agent"), &NavigationServer3D::agent_get_height);
162
ClassDB::bind_method(D_METHOD("agent_set_max_speed", "agent", "max_speed"), &NavigationServer3D::agent_set_max_speed);
163
ClassDB::bind_method(D_METHOD("agent_get_max_speed", "agent"), &NavigationServer3D::agent_get_max_speed);
164
ClassDB::bind_method(D_METHOD("agent_set_velocity_forced", "agent", "velocity"), &NavigationServer3D::agent_set_velocity_forced);
165
ClassDB::bind_method(D_METHOD("agent_set_velocity", "agent", "velocity"), &NavigationServer3D::agent_set_velocity);
166
ClassDB::bind_method(D_METHOD("agent_get_velocity", "agent"), &NavigationServer3D::agent_get_velocity);
167
ClassDB::bind_method(D_METHOD("agent_set_position", "agent", "position"), &NavigationServer3D::agent_set_position);
168
ClassDB::bind_method(D_METHOD("agent_get_position", "agent"), &NavigationServer3D::agent_get_position);
169
ClassDB::bind_method(D_METHOD("agent_is_map_changed", "agent"), &NavigationServer3D::agent_is_map_changed);
170
ClassDB::bind_method(D_METHOD("agent_set_avoidance_callback", "agent", "callback"), &NavigationServer3D::agent_set_avoidance_callback);
171
ClassDB::bind_method(D_METHOD("agent_has_avoidance_callback", "agent"), &NavigationServer3D::agent_has_avoidance_callback);
172
ClassDB::bind_method(D_METHOD("agent_set_avoidance_layers", "agent", "layers"), &NavigationServer3D::agent_set_avoidance_layers);
173
ClassDB::bind_method(D_METHOD("agent_get_avoidance_layers", "agent"), &NavigationServer3D::agent_get_avoidance_layers);
174
ClassDB::bind_method(D_METHOD("agent_set_avoidance_mask", "agent", "mask"), &NavigationServer3D::agent_set_avoidance_mask);
175
ClassDB::bind_method(D_METHOD("agent_get_avoidance_mask", "agent"), &NavigationServer3D::agent_get_avoidance_mask);
176
ClassDB::bind_method(D_METHOD("agent_set_avoidance_priority", "agent", "priority"), &NavigationServer3D::agent_set_avoidance_priority);
177
ClassDB::bind_method(D_METHOD("agent_get_avoidance_priority", "agent"), &NavigationServer3D::agent_get_avoidance_priority);
178
179
ClassDB::bind_method(D_METHOD("obstacle_create"), &NavigationServer3D::obstacle_create);
180
ClassDB::bind_method(D_METHOD("obstacle_set_avoidance_enabled", "obstacle", "enabled"), &NavigationServer3D::obstacle_set_avoidance_enabled);
181
ClassDB::bind_method(D_METHOD("obstacle_get_avoidance_enabled", "obstacle"), &NavigationServer3D::obstacle_get_avoidance_enabled);
182
ClassDB::bind_method(D_METHOD("obstacle_set_use_3d_avoidance", "obstacle", "enabled"), &NavigationServer3D::obstacle_set_use_3d_avoidance);
183
ClassDB::bind_method(D_METHOD("obstacle_get_use_3d_avoidance", "obstacle"), &NavigationServer3D::obstacle_get_use_3d_avoidance);
184
ClassDB::bind_method(D_METHOD("obstacle_set_map", "obstacle", "map"), &NavigationServer3D::obstacle_set_map);
185
ClassDB::bind_method(D_METHOD("obstacle_get_map", "obstacle"), &NavigationServer3D::obstacle_get_map);
186
ClassDB::bind_method(D_METHOD("obstacle_set_paused", "obstacle", "paused"), &NavigationServer3D::obstacle_set_paused);
187
ClassDB::bind_method(D_METHOD("obstacle_get_paused", "obstacle"), &NavigationServer3D::obstacle_get_paused);
188
ClassDB::bind_method(D_METHOD("obstacle_set_radius", "obstacle", "radius"), &NavigationServer3D::obstacle_set_radius);
189
ClassDB::bind_method(D_METHOD("obstacle_get_radius", "obstacle"), &NavigationServer3D::obstacle_get_radius);
190
ClassDB::bind_method(D_METHOD("obstacle_set_height", "obstacle", "height"), &NavigationServer3D::obstacle_set_height);
191
ClassDB::bind_method(D_METHOD("obstacle_get_height", "obstacle"), &NavigationServer3D::obstacle_get_height);
192
ClassDB::bind_method(D_METHOD("obstacle_set_velocity", "obstacle", "velocity"), &NavigationServer3D::obstacle_set_velocity);
193
ClassDB::bind_method(D_METHOD("obstacle_get_velocity", "obstacle"), &NavigationServer3D::obstacle_get_velocity);
194
ClassDB::bind_method(D_METHOD("obstacle_set_position", "obstacle", "position"), &NavigationServer3D::obstacle_set_position);
195
ClassDB::bind_method(D_METHOD("obstacle_get_position", "obstacle"), &NavigationServer3D::obstacle_get_position);
196
ClassDB::bind_method(D_METHOD("obstacle_set_vertices", "obstacle", "vertices"), &NavigationServer3D::obstacle_set_vertices);
197
ClassDB::bind_method(D_METHOD("obstacle_get_vertices", "obstacle"), &NavigationServer3D::obstacle_get_vertices);
198
ClassDB::bind_method(D_METHOD("obstacle_set_avoidance_layers", "obstacle", "layers"), &NavigationServer3D::obstacle_set_avoidance_layers);
199
ClassDB::bind_method(D_METHOD("obstacle_get_avoidance_layers", "obstacle"), &NavigationServer3D::obstacle_get_avoidance_layers);
200
201
#ifndef _3D_DISABLED
202
ClassDB::bind_method(D_METHOD("parse_source_geometry_data", "navigation_mesh", "source_geometry_data", "root_node", "callback"), &NavigationServer3D::parse_source_geometry_data, DEFVAL(Callable()));
203
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data", "navigation_mesh", "source_geometry_data", "callback"), &NavigationServer3D::bake_from_source_geometry_data, DEFVAL(Callable()));
204
ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data_async", "navigation_mesh", "source_geometry_data", "callback"), &NavigationServer3D::bake_from_source_geometry_data_async, DEFVAL(Callable()));
205
ClassDB::bind_method(D_METHOD("is_baking_navigation_mesh", "navigation_mesh"), &NavigationServer3D::is_baking_navigation_mesh);
206
#endif // _3D_DISABLED
207
208
ClassDB::bind_method(D_METHOD("source_geometry_parser_create"), &NavigationServer3D::source_geometry_parser_create);
209
ClassDB::bind_method(D_METHOD("source_geometry_parser_set_callback", "parser", "callback"), &NavigationServer3D::source_geometry_parser_set_callback);
210
211
ClassDB::bind_method(D_METHOD("simplify_path", "path", "epsilon"), &NavigationServer3D::simplify_path);
212
213
ClassDB::bind_method(D_METHOD("free_rid", "rid"), &NavigationServer3D::free);
214
215
ClassDB::bind_method(D_METHOD("set_active", "active"), &NavigationServer3D::set_active);
216
217
ClassDB::bind_method(D_METHOD("set_debug_enabled", "enabled"), &NavigationServer3D::set_debug_enabled);
218
ClassDB::bind_method(D_METHOD("get_debug_enabled"), &NavigationServer3D::get_debug_enabled);
219
220
ADD_SIGNAL(MethodInfo("map_changed", PropertyInfo(Variant::RID, "map")));
221
222
ADD_SIGNAL(MethodInfo("navigation_debug_changed"));
223
ADD_SIGNAL(MethodInfo("avoidance_debug_changed"));
224
225
ClassDB::bind_method(D_METHOD("get_process_info", "process_info"), &NavigationServer3D::get_process_info);
226
227
BIND_ENUM_CONSTANT(INFO_ACTIVE_MAPS);
228
BIND_ENUM_CONSTANT(INFO_REGION_COUNT);
229
BIND_ENUM_CONSTANT(INFO_AGENT_COUNT);
230
BIND_ENUM_CONSTANT(INFO_LINK_COUNT);
231
BIND_ENUM_CONSTANT(INFO_POLYGON_COUNT);
232
BIND_ENUM_CONSTANT(INFO_EDGE_COUNT);
233
BIND_ENUM_CONSTANT(INFO_EDGE_MERGE_COUNT);
234
BIND_ENUM_CONSTANT(INFO_EDGE_CONNECTION_COUNT);
235
BIND_ENUM_CONSTANT(INFO_EDGE_FREE_COUNT);
236
BIND_ENUM_CONSTANT(INFO_OBSTACLE_COUNT);
237
}
238
239
NavigationServer3D *NavigationServer3D::get_singleton() {
240
return singleton;
241
}
242
243
NavigationServer3D::NavigationServer3D() {
244
ERR_FAIL_COND(singleton != nullptr);
245
singleton = this;
246
247
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_cell_size", PROPERTY_HINT_RANGE, NavigationDefaults3D::NAV_MESH_CELL_SIZE_HINT), NavigationDefaults3D::NAV_MESH_CELL_SIZE);
248
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_cell_height", PROPERTY_HINT_RANGE, "0.001,100,0.001,or_greater"), NavigationDefaults3D::NAV_MESH_CELL_HEIGHT);
249
GLOBAL_DEF("navigation/3d/default_up", Vector3(0, 1, 0));
250
GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "navigation/3d/merge_rasterizer_cell_scale", PROPERTY_HINT_RANGE, "0.001,1,0.001,or_greater"), 1.0);
251
GLOBAL_DEF("navigation/3d/use_edge_connections", true);
252
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_edge_connection_margin", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults3D::EDGE_CONNECTION_MARGIN);
253
GLOBAL_DEF_BASIC(PropertyInfo(Variant::FLOAT, "navigation/3d/default_link_connection_radius", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), NavigationDefaults3D::LINK_CONNECTION_RADIUS);
254
255
#ifdef DEBUG_ENABLED
256
#ifndef DISABLE_DEPRECATED
257
#define MOVE_PROJECT_SETTING_1(m_old_setting, m_new_setting) \
258
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting) && ProjectSettings::get_singleton()->has_setting(m_old_setting)) { \
259
Variant value = GLOBAL_GET(m_old_setting); \
260
ProjectSettings::get_singleton()->set_setting(m_new_setting, value); \
261
ProjectSettings::get_singleton()->clear(m_old_setting); \
262
}
263
#define MOVE_PROJECT_SETTING_2(m_old_setting, m_new_setting_1, m_new_setting_2) \
264
if ((!ProjectSettings::get_singleton()->has_setting(m_new_setting_1) || !ProjectSettings::get_singleton()->has_setting(m_new_setting_2)) && \
265
ProjectSettings::get_singleton()->has_setting(m_old_setting)) { \
266
Variant value = GLOBAL_GET(m_old_setting); \
267
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting_1)) { \
268
ProjectSettings::get_singleton()->set_setting(m_new_setting_1, value); \
269
} \
270
if (!ProjectSettings::get_singleton()->has_setting(m_new_setting_2)) { \
271
ProjectSettings::get_singleton()->set_setting(m_new_setting_2, value); \
272
} \
273
ProjectSettings::get_singleton()->clear(m_old_setting); \
274
}
275
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/edge_connection_color", "debug/shapes/navigation/2d/edge_connection_color", "debug/shapes/navigation/3d/edge_connection_color");
276
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_edge_color", "debug/shapes/navigation/2d/geometry_edge_color", "debug/shapes/navigation/3d/geometry_edge_color");
277
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_face_color", "debug/shapes/navigation/2d/geometry_face_color", "debug/shapes/navigation/3d/geometry_face_color");
278
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_edge_disabled_color", "debug/shapes/navigation/2d/geometry_edge_disabled_color", "debug/shapes/navigation/3d/geometry_edge_disabled_color");
279
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/geometry_face_disabled_color", "debug/shapes/navigation/2d/geometry_face_disabled_color", "debug/shapes/navigation/3d/geometry_face_disabled_color");
280
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/link_connection_color", "debug/shapes/navigation/2d/link_connection_color", "debug/shapes/navigation/3d/link_connection_color");
281
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/link_connection_disabled_color", "debug/shapes/navigation/2d/link_connection_disabled_color", "debug/shapes/navigation/3d/link_connection_disabled_color");
282
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/agent_path_color", "debug/shapes/navigation/2d/agent_path_color", "debug/shapes/navigation/3d/agent_path_color");
283
284
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_edge_connections", "debug/shapes/navigation/2d/enable_edge_connections", "debug/shapes/navigation/3d/enable_edge_connections");
285
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_edge_connections_xray", "debug/shapes/navigation/3d/enable_edge_connections_xray");
286
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_edge_lines", "debug/shapes/navigation/2d/enable_edge_lines", "debug/shapes/navigation/3d/enable_edge_lines");
287
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_edge_lines_xray", "debug/shapes/navigation/3d/enable_edge_lines_xray");
288
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_geometry_face_random_color", "debug/shapes/navigation/2d/enable_geometry_face_random_color", "debug/shapes/navigation/3d/enable_geometry_face_random_color");
289
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_link_connections", "debug/shapes/navigation/2d/enable_link_connections", "debug/shapes/navigation/3d/enable_link_connections");
290
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_link_connections_xray", "debug/shapes/navigation/3d/enable_link_connections_xray");
291
292
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/enable_agent_paths", "debug/shapes/navigation/2d/enable_agent_paths", "debug/shapes/navigation/3d/enable_agent_paths");
293
MOVE_PROJECT_SETTING_1("debug/shapes/navigation/enable_agent_paths_xray", "debug/shapes/navigation/3d/enable_agent_paths_xray");
294
MOVE_PROJECT_SETTING_2("debug/shapes/navigation/agent_path_point_size", "debug/shapes/navigation/2d/agent_path_point_size", "debug/shapes/navigation/3d/agent_path_point_size");
295
296
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/agents_radius_color", "debug/shapes/avoidance/2d/agents_radius_color", "debug/shapes/avoidance/3d/agents_radius_color");
297
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_radius_color", "debug/shapes/avoidance/2d/obstacles_radius_color", "debug/shapes/avoidance/3d/obstacles_radius_color");
298
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_face_pushin_color", "debug/shapes/avoidance/2d/obstacles_static_face_pushin_color", "debug/shapes/avoidance/3d/obstacles_static_face_pushin_color");
299
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_edge_pushin_color", "debug/shapes/avoidance/2d/obstacles_static_edge_pushin_color", "debug/shapes/avoidance/3d/obstacles_static_edge_pushin_color");
300
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_face_pushout_color", "debug/shapes/avoidance/2d/obstacles_static_face_pushout_color", "debug/shapes/avoidance/3d/obstacles_static_face_pushout_color");
301
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/obstacles_static_edge_pushout_color", "debug/shapes/avoidance/2d/obstacles_static_edge_pushout_color", "debug/shapes/avoidance/3d/obstacles_static_edge_pushout_color");
302
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_agents_radius", "debug/shapes/avoidance/2d/enable_agents_radius", "debug/shapes/avoidance/3d/enable_agents_radius");
303
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_obstacles_radius", "debug/shapes/avoidance/2d/enable_obstacles_radius", "debug/shapes/avoidance/2d/enable_obstacles_static");
304
MOVE_PROJECT_SETTING_2("debug/shapes/avoidance/enable_obstacles_radius", "debug/shapes/avoidance/3d/enable_obstacles_radius", "debug/shapes/avoidance/3d/enable_obstacles_static");
305
#undef MOVE_PROJECT_SETTING_1
306
#undef MOVE_PROJECT_SETTING_2
307
#endif // DISABLE_DEPRECATED
308
309
debug_navigation_edge_connection_color = GLOBAL_DEF("debug/shapes/navigation/3d/edge_connection_color", Color(1.0, 0.0, 1.0, 1.0));
310
debug_navigation_geometry_edge_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_edge_color", Color(0.5, 1.0, 1.0, 1.0));
311
debug_navigation_geometry_face_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_face_color", Color(0.5, 1.0, 1.0, 0.4));
312
debug_navigation_geometry_edge_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_edge_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
313
debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/geometry_face_disabled_color", Color(0.5, 0.5, 0.5, 0.4));
314
debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/3d/link_connection_color", Color(1.0, 0.5, 1.0, 1.0));
315
debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/3d/link_connection_disabled_color", Color(0.5, 0.5, 0.5, 1.0));
316
debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/3d/agent_path_color", Color(1.0, 0.0, 0.0, 1.0));
317
318
debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_connections", true);
319
debug_navigation_enable_edge_connections_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_connections_xray", true);
320
debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_lines", true);
321
debug_navigation_enable_edge_lines_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_edge_lines_xray", true);
322
debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/3d/enable_geometry_face_random_color", true);
323
debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/3d/enable_link_connections", true);
324
debug_navigation_enable_link_connections_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_link_connections_xray", true);
325
326
debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/3d/enable_agent_paths", true);
327
debug_navigation_enable_agent_paths_xray = GLOBAL_DEF("debug/shapes/navigation/3d/enable_agent_paths_xray", true);
328
debug_navigation_agent_path_point_size = GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "debug/shapes/navigation/3d/agent_path_point_size", PROPERTY_HINT_RANGE, "0.01,10,0.001,or_greater"), 4.0);
329
330
debug_navigation_avoidance_agents_radius_color = GLOBAL_DEF("debug/shapes/avoidance/3d/agents_radius_color", Color(1.0, 1.0, 0.0, 0.25));
331
debug_navigation_avoidance_obstacles_radius_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_radius_color", Color(1.0, 0.5, 0.0, 0.25));
332
debug_navigation_avoidance_static_obstacle_pushin_face_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_face_pushin_color", Color(1.0, 0.0, 0.0, 0.0));
333
debug_navigation_avoidance_static_obstacle_pushin_edge_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_edge_pushin_color", Color(1.0, 0.0, 0.0, 1.0));
334
debug_navigation_avoidance_static_obstacle_pushout_face_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_face_pushout_color", Color(1.0, 1.0, 0.0, 0.5));
335
debug_navigation_avoidance_static_obstacle_pushout_edge_color = GLOBAL_DEF("debug/shapes/avoidance/3d/obstacles_static_edge_pushout_color", Color(1.0, 1.0, 0.0, 1.0));
336
debug_navigation_avoidance_enable_agents_radius = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_agents_radius", true);
337
debug_navigation_avoidance_enable_obstacles_radius = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_obstacles_radius", true);
338
debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/3d/enable_obstacles_static", true);
339
340
if (Engine::get_singleton()->is_editor_hint()) {
341
// enable NavigationServer3D when in Editor or else navigation mesh edge connections are invisible
342
// on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this
343
set_debug_enabled(true);
344
set_debug_navigation_enabled(true);
345
set_debug_avoidance_enabled(true);
346
}
347
#endif // DEBUG_ENABLED
348
}
349
350
NavigationServer3D::~NavigationServer3D() {
351
singleton = nullptr;
352
353
RWLockWrite write_lock(geometry_parser_rwlock);
354
for (NavMeshGeometryParser3D *parser : generator_parsers) {
355
geometry_parser_owner.free(parser->self);
356
}
357
generator_parsers.clear();
358
}
359
360
RID NavigationServer3D::source_geometry_parser_create() {
361
RWLockWrite write_lock(geometry_parser_rwlock);
362
363
RID rid = geometry_parser_owner.make_rid();
364
365
NavMeshGeometryParser3D *parser = geometry_parser_owner.get_or_null(rid);
366
parser->self = rid;
367
368
generator_parsers.push_back(parser);
369
370
return rid;
371
}
372
373
void NavigationServer3D::free(RID p_object) {
374
if (!geometry_parser_owner.owns(p_object)) {
375
return;
376
}
377
RWLockWrite write_lock(geometry_parser_rwlock);
378
379
NavMeshGeometryParser3D *parser = geometry_parser_owner.get_or_null(p_object);
380
ERR_FAIL_NULL(parser);
381
382
generator_parsers.erase(parser);
383
geometry_parser_owner.free(parser->self);
384
}
385
386
void NavigationServer3D::source_geometry_parser_set_callback(RID p_parser, const Callable &p_callback) {
387
RWLockWrite write_lock(geometry_parser_rwlock);
388
389
NavMeshGeometryParser3D *parser = geometry_parser_owner.get_or_null(p_parser);
390
ERR_FAIL_NULL(parser);
391
392
parser->callback = p_callback;
393
}
394
395
void NavigationServer3D::set_debug_enabled(bool p_enabled) {
396
#ifdef DEBUG_ENABLED
397
if (debug_enabled != p_enabled) {
398
debug_dirty = true;
399
}
400
401
debug_enabled = p_enabled;
402
403
if (debug_dirty) {
404
navigation_debug_dirty = true;
405
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
406
407
avoidance_debug_dirty = true;
408
callable_mp(this, &NavigationServer3D::_emit_avoidance_debug_changed_signal).call_deferred();
409
}
410
#endif // DEBUG_ENABLED
411
}
412
413
bool NavigationServer3D::get_debug_enabled() const {
414
return debug_enabled;
415
}
416
417
#ifdef DEBUG_ENABLED
418
void NavigationServer3D::_emit_navigation_debug_changed_signal() {
419
if (navigation_debug_dirty) {
420
navigation_debug_dirty = false;
421
emit_signal(SNAME("navigation_debug_changed"));
422
}
423
}
424
425
void NavigationServer3D::_emit_avoidance_debug_changed_signal() {
426
if (avoidance_debug_dirty) {
427
avoidance_debug_dirty = false;
428
emit_signal(SNAME("avoidance_debug_changed"));
429
}
430
}
431
#endif // DEBUG_ENABLED
432
433
#ifdef DEBUG_ENABLED
434
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_material() {
435
if (debug_navigation_geometry_face_material.is_valid()) {
436
return debug_navigation_geometry_face_material;
437
}
438
439
bool enabled_geometry_face_random_color = get_debug_navigation_enable_geometry_face_random_color();
440
441
Ref<StandardMaterial3D> face_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
442
face_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
443
face_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
444
face_material->set_albedo(get_debug_navigation_geometry_face_color());
445
face_material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
446
face_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
447
if (enabled_geometry_face_random_color) {
448
face_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true);
449
face_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true);
450
}
451
452
debug_navigation_geometry_face_material = face_material;
453
454
return debug_navigation_geometry_face_material;
455
}
456
457
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_material() {
458
if (debug_navigation_geometry_edge_material.is_valid()) {
459
return debug_navigation_geometry_edge_material;
460
}
461
462
bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray();
463
464
Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
465
line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
466
line_material->set_albedo(get_debug_navigation_geometry_edge_color());
467
line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
468
if (enabled_edge_lines_xray) {
469
line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
470
}
471
472
debug_navigation_geometry_edge_material = line_material;
473
474
return debug_navigation_geometry_edge_material;
475
}
476
477
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_disabled_material() {
478
if (debug_navigation_geometry_face_disabled_material.is_valid()) {
479
return debug_navigation_geometry_face_disabled_material;
480
}
481
482
Ref<StandardMaterial3D> face_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
483
face_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
484
face_disabled_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
485
face_disabled_material->set_albedo(get_debug_navigation_geometry_face_disabled_color());
486
face_disabled_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
487
488
debug_navigation_geometry_face_disabled_material = face_disabled_material;
489
490
return debug_navigation_geometry_face_disabled_material;
491
}
492
493
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_disabled_material() {
494
if (debug_navigation_geometry_edge_disabled_material.is_valid()) {
495
return debug_navigation_geometry_edge_disabled_material;
496
}
497
498
bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray();
499
500
Ref<StandardMaterial3D> line_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
501
line_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
502
line_disabled_material->set_albedo(get_debug_navigation_geometry_edge_disabled_color());
503
line_disabled_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
504
if (enabled_edge_lines_xray) {
505
line_disabled_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
506
}
507
508
debug_navigation_geometry_edge_disabled_material = line_disabled_material;
509
510
return debug_navigation_geometry_edge_disabled_material;
511
}
512
513
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_edge_connections_material() {
514
if (debug_navigation_edge_connections_material.is_valid()) {
515
return debug_navigation_edge_connections_material;
516
}
517
518
bool enabled_edge_connections_xray = get_debug_navigation_enable_edge_connections_xray();
519
520
Ref<StandardMaterial3D> edge_connections_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
521
edge_connections_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
522
edge_connections_material->set_albedo(get_debug_navigation_edge_connection_color());
523
edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
524
if (enabled_edge_connections_xray) {
525
edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
526
}
527
edge_connections_material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
528
529
debug_navigation_edge_connections_material = edge_connections_material;
530
531
return debug_navigation_edge_connections_material;
532
}
533
534
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_link_connections_material() {
535
if (debug_navigation_link_connections_material.is_valid()) {
536
return debug_navigation_link_connections_material;
537
}
538
539
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
540
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
541
material->set_albedo(debug_navigation_link_connection_color);
542
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
543
if (debug_navigation_enable_link_connections_xray) {
544
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
545
}
546
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
547
548
debug_navigation_link_connections_material = material;
549
return debug_navigation_link_connections_material;
550
}
551
552
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_link_connections_disabled_material() {
553
if (debug_navigation_link_connections_disabled_material.is_valid()) {
554
return debug_navigation_link_connections_disabled_material;
555
}
556
557
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
558
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
559
material->set_albedo(debug_navigation_link_connection_disabled_color);
560
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
561
if (debug_navigation_enable_link_connections_xray) {
562
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
563
}
564
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
565
566
debug_navigation_link_connections_disabled_material = material;
567
return debug_navigation_link_connections_disabled_material;
568
}
569
570
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_line_material() {
571
if (debug_navigation_agent_path_line_material.is_valid()) {
572
return debug_navigation_agent_path_line_material;
573
}
574
575
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
576
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
577
578
material->set_albedo(debug_navigation_agent_path_color);
579
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
580
if (debug_navigation_enable_agent_paths_xray) {
581
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
582
}
583
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
584
585
debug_navigation_agent_path_line_material = material;
586
return debug_navigation_agent_path_line_material;
587
}
588
589
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_point_material() {
590
if (debug_navigation_agent_path_point_material.is_valid()) {
591
return debug_navigation_agent_path_point_material;
592
}
593
594
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
595
material->set_albedo(debug_navigation_agent_path_color);
596
material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true);
597
material->set_point_size(debug_navigation_agent_path_point_size);
598
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
599
if (debug_navigation_enable_agent_paths_xray) {
600
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
601
}
602
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2);
603
604
debug_navigation_agent_path_point_material = material;
605
return debug_navigation_agent_path_point_material;
606
}
607
608
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_agents_radius_material() {
609
if (debug_navigation_avoidance_agents_radius_material.is_valid()) {
610
return debug_navigation_avoidance_agents_radius_material;
611
}
612
613
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
614
material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
615
material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
616
material->set_albedo(debug_navigation_avoidance_agents_radius_color);
617
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
618
619
debug_navigation_avoidance_agents_radius_material = material;
620
return debug_navigation_avoidance_agents_radius_material;
621
}
622
623
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_obstacles_radius_material() {
624
if (debug_navigation_avoidance_obstacles_radius_material.is_valid()) {
625
return debug_navigation_avoidance_obstacles_radius_material;
626
}
627
628
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
629
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
630
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
631
material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
632
material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
633
material->set_albedo(debug_navigation_avoidance_obstacles_radius_color);
634
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
635
636
debug_navigation_avoidance_obstacles_radius_material = material;
637
return debug_navigation_avoidance_obstacles_radius_material;
638
}
639
640
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_face_material() {
641
if (debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) {
642
return debug_navigation_avoidance_static_obstacle_pushin_face_material;
643
}
644
645
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
646
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
647
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
648
material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
649
material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
650
material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_face_color);
651
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
652
653
debug_navigation_avoidance_static_obstacle_pushin_face_material = material;
654
return debug_navigation_avoidance_static_obstacle_pushin_face_material;
655
}
656
657
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_face_material() {
658
if (debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) {
659
return debug_navigation_avoidance_static_obstacle_pushout_face_material;
660
}
661
662
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
663
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
664
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
665
material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
666
material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
667
material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_face_color);
668
material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
669
670
debug_navigation_avoidance_static_obstacle_pushout_face_material = material;
671
return debug_navigation_avoidance_static_obstacle_pushout_face_material;
672
}
673
674
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_edge_material() {
675
if (debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) {
676
return debug_navigation_avoidance_static_obstacle_pushin_edge_material;
677
}
678
679
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
680
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
681
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
682
//material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
683
//material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
684
material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_edge_color);
685
//material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
686
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
687
688
debug_navigation_avoidance_static_obstacle_pushin_edge_material = material;
689
return debug_navigation_avoidance_static_obstacle_pushin_edge_material;
690
}
691
692
Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_edge_material() {
693
if (debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) {
694
return debug_navigation_avoidance_static_obstacle_pushout_edge_material;
695
}
696
697
Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D));
698
material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
699
material->set_flag(StandardMaterial3D::FLAG_DISABLE_FOG, true);
700
///material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA);
701
//material->set_cull_mode(StandardMaterial3D::CULL_DISABLED);
702
material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_edge_color);
703
//material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2);
704
material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true);
705
706
debug_navigation_avoidance_static_obstacle_pushout_edge_material = material;
707
return debug_navigation_avoidance_static_obstacle_pushout_edge_material;
708
}
709
710
void NavigationServer3D::set_debug_navigation_edge_connection_color(const Color &p_color) {
711
debug_navigation_edge_connection_color = p_color;
712
if (debug_navigation_edge_connections_material.is_valid()) {
713
debug_navigation_edge_connections_material->set_albedo(debug_navigation_edge_connection_color);
714
}
715
}
716
717
Color NavigationServer3D::get_debug_navigation_edge_connection_color() const {
718
return debug_navigation_edge_connection_color;
719
}
720
721
void NavigationServer3D::set_debug_navigation_geometry_edge_color(const Color &p_color) {
722
debug_navigation_geometry_edge_color = p_color;
723
if (debug_navigation_geometry_edge_material.is_valid()) {
724
debug_navigation_geometry_edge_material->set_albedo(debug_navigation_geometry_edge_color);
725
}
726
}
727
728
Color NavigationServer3D::get_debug_navigation_geometry_edge_color() const {
729
return debug_navigation_geometry_edge_color;
730
}
731
732
void NavigationServer3D::set_debug_navigation_geometry_face_color(const Color &p_color) {
733
debug_navigation_geometry_face_color = p_color;
734
if (debug_navigation_geometry_face_material.is_valid()) {
735
debug_navigation_geometry_face_material->set_albedo(debug_navigation_geometry_face_color);
736
}
737
}
738
739
Color NavigationServer3D::get_debug_navigation_geometry_face_color() const {
740
return debug_navigation_geometry_face_color;
741
}
742
743
void NavigationServer3D::set_debug_navigation_geometry_edge_disabled_color(const Color &p_color) {
744
debug_navigation_geometry_edge_disabled_color = p_color;
745
if (debug_navigation_geometry_edge_disabled_material.is_valid()) {
746
debug_navigation_geometry_edge_disabled_material->set_albedo(debug_navigation_geometry_edge_disabled_color);
747
}
748
}
749
750
Color NavigationServer3D::get_debug_navigation_geometry_edge_disabled_color() const {
751
return debug_navigation_geometry_edge_disabled_color;
752
}
753
754
void NavigationServer3D::set_debug_navigation_geometry_face_disabled_color(const Color &p_color) {
755
debug_navigation_geometry_face_disabled_color = p_color;
756
if (debug_navigation_geometry_face_disabled_material.is_valid()) {
757
debug_navigation_geometry_face_disabled_material->set_albedo(debug_navigation_geometry_face_disabled_color);
758
}
759
}
760
761
Color NavigationServer3D::get_debug_navigation_geometry_face_disabled_color() const {
762
return debug_navigation_geometry_face_disabled_color;
763
}
764
765
void NavigationServer3D::set_debug_navigation_link_connection_color(const Color &p_color) {
766
debug_navigation_link_connection_color = p_color;
767
if (debug_navigation_link_connections_material.is_valid()) {
768
debug_navigation_link_connections_material->set_albedo(debug_navigation_link_connection_color);
769
}
770
}
771
772
Color NavigationServer3D::get_debug_navigation_link_connection_color() const {
773
return debug_navigation_link_connection_color;
774
}
775
776
void NavigationServer3D::set_debug_navigation_link_connection_disabled_color(const Color &p_color) {
777
debug_navigation_link_connection_disabled_color = p_color;
778
if (debug_navigation_link_connections_disabled_material.is_valid()) {
779
debug_navigation_link_connections_disabled_material->set_albedo(debug_navigation_link_connection_disabled_color);
780
}
781
}
782
783
Color NavigationServer3D::get_debug_navigation_link_connection_disabled_color() const {
784
return debug_navigation_link_connection_disabled_color;
785
}
786
787
void NavigationServer3D::set_debug_navigation_agent_path_point_size(real_t p_point_size) {
788
debug_navigation_agent_path_point_size = MAX(0.1, p_point_size);
789
if (debug_navigation_agent_path_point_material.is_valid()) {
790
debug_navigation_agent_path_point_material->set_point_size(debug_navigation_agent_path_point_size);
791
}
792
}
793
794
real_t NavigationServer3D::get_debug_navigation_agent_path_point_size() const {
795
return debug_navigation_agent_path_point_size;
796
}
797
798
void NavigationServer3D::set_debug_navigation_agent_path_color(const Color &p_color) {
799
debug_navigation_agent_path_color = p_color;
800
if (debug_navigation_agent_path_line_material.is_valid()) {
801
debug_navigation_agent_path_line_material->set_albedo(debug_navigation_agent_path_color);
802
}
803
if (debug_navigation_agent_path_point_material.is_valid()) {
804
debug_navigation_agent_path_point_material->set_albedo(debug_navigation_agent_path_color);
805
}
806
}
807
808
Color NavigationServer3D::get_debug_navigation_agent_path_color() const {
809
return debug_navigation_agent_path_color;
810
}
811
812
void NavigationServer3D::set_debug_navigation_enable_edge_connections(const bool p_value) {
813
debug_navigation_enable_edge_connections = p_value;
814
navigation_debug_dirty = true;
815
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
816
}
817
818
bool NavigationServer3D::get_debug_navigation_enable_edge_connections() const {
819
return debug_navigation_enable_edge_connections;
820
}
821
822
void NavigationServer3D::set_debug_navigation_enable_edge_connections_xray(const bool p_value) {
823
debug_navigation_enable_edge_connections_xray = p_value;
824
if (debug_navigation_edge_connections_material.is_valid()) {
825
debug_navigation_edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_edge_connections_xray);
826
}
827
}
828
829
bool NavigationServer3D::get_debug_navigation_enable_edge_connections_xray() const {
830
return debug_navigation_enable_edge_connections_xray;
831
}
832
833
void NavigationServer3D::set_debug_navigation_enable_edge_lines(const bool p_value) {
834
debug_navigation_enable_edge_lines = p_value;
835
navigation_debug_dirty = true;
836
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
837
}
838
839
bool NavigationServer3D::get_debug_navigation_enable_edge_lines() const {
840
return debug_navigation_enable_edge_lines;
841
}
842
843
void NavigationServer3D::set_debug_navigation_enable_edge_lines_xray(const bool p_value) {
844
debug_navigation_enable_edge_lines_xray = p_value;
845
if (debug_navigation_geometry_edge_material.is_valid()) {
846
debug_navigation_geometry_edge_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_edge_lines_xray);
847
}
848
}
849
850
bool NavigationServer3D::get_debug_navigation_enable_edge_lines_xray() const {
851
return debug_navigation_enable_edge_lines_xray;
852
}
853
854
void NavigationServer3D::set_debug_navigation_enable_geometry_face_random_color(const bool p_value) {
855
debug_navigation_enable_geometry_face_random_color = p_value;
856
navigation_debug_dirty = true;
857
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
858
}
859
860
bool NavigationServer3D::get_debug_navigation_enable_geometry_face_random_color() const {
861
return debug_navigation_enable_geometry_face_random_color;
862
}
863
864
void NavigationServer3D::set_debug_navigation_enable_link_connections(const bool p_value) {
865
debug_navigation_enable_link_connections = p_value;
866
navigation_debug_dirty = true;
867
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
868
}
869
870
bool NavigationServer3D::get_debug_navigation_enable_link_connections() const {
871
return debug_navigation_enable_link_connections;
872
}
873
874
void NavigationServer3D::set_debug_navigation_enable_link_connections_xray(const bool p_value) {
875
debug_navigation_enable_link_connections_xray = p_value;
876
if (debug_navigation_link_connections_material.is_valid()) {
877
debug_navigation_link_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_link_connections_xray);
878
}
879
}
880
881
bool NavigationServer3D::get_debug_navigation_enable_link_connections_xray() const {
882
return debug_navigation_enable_link_connections_xray;
883
}
884
885
void NavigationServer3D::set_debug_navigation_avoidance_enable_agents_radius(const bool p_value) {
886
debug_navigation_avoidance_enable_agents_radius = p_value;
887
avoidance_debug_dirty = true;
888
callable_mp(this, &NavigationServer3D::_emit_avoidance_debug_changed_signal).call_deferred();
889
}
890
891
bool NavigationServer3D::get_debug_navigation_avoidance_enable_agents_radius() const {
892
return debug_navigation_avoidance_enable_agents_radius;
893
}
894
895
void NavigationServer3D::set_debug_navigation_avoidance_enable_obstacles_radius(const bool p_value) {
896
debug_navigation_avoidance_enable_obstacles_radius = p_value;
897
avoidance_debug_dirty = true;
898
callable_mp(this, &NavigationServer3D::_emit_avoidance_debug_changed_signal).call_deferred();
899
}
900
901
bool NavigationServer3D::get_debug_navigation_avoidance_enable_obstacles_radius() const {
902
return debug_navigation_avoidance_enable_obstacles_radius;
903
}
904
905
void NavigationServer3D::set_debug_navigation_avoidance_enable_obstacles_static(const bool p_value) {
906
debug_navigation_avoidance_enable_obstacles_static = p_value;
907
avoidance_debug_dirty = true;
908
callable_mp(this, &NavigationServer3D::_emit_avoidance_debug_changed_signal).call_deferred();
909
}
910
911
bool NavigationServer3D::get_debug_navigation_avoidance_enable_obstacles_static() const {
912
return debug_navigation_avoidance_enable_obstacles_static;
913
}
914
915
void NavigationServer3D::set_debug_navigation_avoidance_agents_radius_color(const Color &p_color) {
916
debug_navigation_avoidance_agents_radius_color = p_color;
917
if (debug_navigation_avoidance_agents_radius_material.is_valid()) {
918
debug_navigation_avoidance_agents_radius_material->set_albedo(debug_navigation_avoidance_agents_radius_color);
919
}
920
}
921
922
Color NavigationServer3D::get_debug_navigation_avoidance_agents_radius_color() const {
923
return debug_navigation_avoidance_agents_radius_color;
924
}
925
926
void NavigationServer3D::set_debug_navigation_avoidance_obstacles_radius_color(const Color &p_color) {
927
debug_navigation_avoidance_obstacles_radius_color = p_color;
928
if (debug_navigation_avoidance_obstacles_radius_material.is_valid()) {
929
debug_navigation_avoidance_obstacles_radius_material->set_albedo(debug_navigation_avoidance_obstacles_radius_color);
930
}
931
}
932
933
Color NavigationServer3D::get_debug_navigation_avoidance_obstacles_radius_color() const {
934
return debug_navigation_avoidance_obstacles_radius_color;
935
}
936
937
void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushin_face_color(const Color &p_color) {
938
debug_navigation_avoidance_static_obstacle_pushin_face_color = p_color;
939
if (debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) {
940
debug_navigation_avoidance_static_obstacle_pushin_face_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_face_color);
941
}
942
}
943
944
Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_face_color() const {
945
return debug_navigation_avoidance_static_obstacle_pushin_face_color;
946
}
947
948
void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushout_face_color(const Color &p_color) {
949
debug_navigation_avoidance_static_obstacle_pushout_face_color = p_color;
950
if (debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) {
951
debug_navigation_avoidance_static_obstacle_pushout_face_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_face_color);
952
}
953
}
954
955
Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_face_color() const {
956
return debug_navigation_avoidance_static_obstacle_pushout_face_color;
957
}
958
959
void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushin_edge_color(const Color &p_color) {
960
debug_navigation_avoidance_static_obstacle_pushin_edge_color = p_color;
961
if (debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) {
962
debug_navigation_avoidance_static_obstacle_pushin_edge_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_edge_color);
963
}
964
}
965
966
Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_edge_color() const {
967
return debug_navigation_avoidance_static_obstacle_pushin_edge_color;
968
}
969
970
void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushout_edge_color(const Color &p_color) {
971
debug_navigation_avoidance_static_obstacle_pushout_edge_color = p_color;
972
if (debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) {
973
debug_navigation_avoidance_static_obstacle_pushout_edge_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_edge_color);
974
}
975
}
976
977
Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_edge_color() const {
978
return debug_navigation_avoidance_static_obstacle_pushout_edge_color;
979
}
980
981
void NavigationServer3D::set_debug_navigation_enable_agent_paths(const bool p_value) {
982
if (debug_navigation_enable_agent_paths != p_value) {
983
debug_dirty = true;
984
}
985
986
debug_navigation_enable_agent_paths = p_value;
987
988
if (debug_dirty) {
989
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
990
}
991
}
992
993
bool NavigationServer3D::get_debug_navigation_enable_agent_paths() const {
994
return debug_navigation_enable_agent_paths;
995
}
996
997
void NavigationServer3D::set_debug_navigation_enable_agent_paths_xray(const bool p_value) {
998
debug_navigation_enable_agent_paths_xray = p_value;
999
if (debug_navigation_agent_path_line_material.is_valid()) {
1000
debug_navigation_agent_path_line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray);
1001
}
1002
if (debug_navigation_agent_path_point_material.is_valid()) {
1003
debug_navigation_agent_path_point_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray);
1004
}
1005
}
1006
1007
bool NavigationServer3D::get_debug_navigation_enable_agent_paths_xray() const {
1008
return debug_navigation_enable_agent_paths_xray;
1009
}
1010
1011
void NavigationServer3D::set_debug_navigation_enabled(bool p_enabled) {
1012
debug_navigation_enabled = p_enabled;
1013
navigation_debug_dirty = true;
1014
callable_mp(this, &NavigationServer3D::_emit_navigation_debug_changed_signal).call_deferred();
1015
}
1016
1017
bool NavigationServer3D::get_debug_navigation_enabled() const {
1018
return debug_navigation_enabled;
1019
}
1020
1021
void NavigationServer3D::set_debug_avoidance_enabled(bool p_enabled) {
1022
debug_avoidance_enabled = p_enabled;
1023
avoidance_debug_dirty = true;
1024
callable_mp(this, &NavigationServer3D::_emit_avoidance_debug_changed_signal).call_deferred();
1025
}
1026
1027
bool NavigationServer3D::get_debug_avoidance_enabled() const {
1028
return debug_avoidance_enabled;
1029
}
1030
1031
#endif // DEBUG_ENABLED
1032
1033
///////////////////////////////////////////////////////
1034
1035
static NavigationServer3D *navigation_server_3d = nullptr;
1036
1037
NavigationServer3DCallback NavigationServer3DManager::create_callback = nullptr;
1038
1039
void NavigationServer3DManager::set_default_server(NavigationServer3DCallback p_callback) {
1040
create_callback = p_callback;
1041
}
1042
1043
NavigationServer3D *NavigationServer3DManager::new_default_server() {
1044
if (create_callback == nullptr) {
1045
return nullptr;
1046
}
1047
1048
return create_callback();
1049
}
1050
1051
void NavigationServer3DManager::initialize_server() {
1052
ERR_FAIL_COND(navigation_server_3d != nullptr);
1053
1054
// Init 3D Navigation Server
1055
navigation_server_3d = NavigationServer3DManager::new_default_server();
1056
1057
// Fall back to dummy if no default server has been registered.
1058
if (!navigation_server_3d) {
1059
WARN_VERBOSE("Failed to initialize NavigationServer3D. Fall back to dummy server.");
1060
navigation_server_3d = memnew(NavigationServer3DDummy);
1061
}
1062
1063
// Should be impossible, but make sure it's not null.
1064
ERR_FAIL_NULL_MSG(navigation_server_3d, "Failed to initialize NavigationServer3D.");
1065
navigation_server_3d->init();
1066
}
1067
1068
void NavigationServer3DManager::finalize_server() {
1069
ERR_FAIL_NULL(navigation_server_3d);
1070
navigation_server_3d->finish();
1071
memdelete(navigation_server_3d);
1072
navigation_server_3d = nullptr;
1073
}
1074
1075