| 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 "core/config/project_settings.h" |
| 33 | |
| 34 | NavigationServer3D *NavigationServer3D::singleton = nullptr; |
| 35 | |
| 36 | void NavigationServer3D::_bind_methods() { |
| 37 | ClassDB::bind_method(D_METHOD("get_maps" ), &NavigationServer3D::get_maps); |
| 38 | |
| 39 | ClassDB::bind_method(D_METHOD("map_create" ), &NavigationServer3D::map_create); |
| 40 | ClassDB::bind_method(D_METHOD("map_set_active" , "map" , "active" ), &NavigationServer3D::map_set_active); |
| 41 | ClassDB::bind_method(D_METHOD("map_is_active" , "map" ), &NavigationServer3D::map_is_active); |
| 42 | ClassDB::bind_method(D_METHOD("map_set_up" , "map" , "up" ), &NavigationServer3D::map_set_up); |
| 43 | ClassDB::bind_method(D_METHOD("map_get_up" , "map" ), &NavigationServer3D::map_get_up); |
| 44 | ClassDB::bind_method(D_METHOD("map_set_cell_size" , "map" , "cell_size" ), &NavigationServer3D::map_set_cell_size); |
| 45 | ClassDB::bind_method(D_METHOD("map_get_cell_size" , "map" ), &NavigationServer3D::map_get_cell_size); |
| 46 | ClassDB::bind_method(D_METHOD("map_set_cell_height" , "map" , "cell_height" ), &NavigationServer3D::map_set_cell_height); |
| 47 | ClassDB::bind_method(D_METHOD("map_get_cell_height" , "map" ), &NavigationServer3D::map_get_cell_height); |
| 48 | ClassDB::bind_method(D_METHOD("map_set_use_edge_connections" , "map" , "enabled" ), &NavigationServer3D::map_set_use_edge_connections); |
| 49 | ClassDB::bind_method(D_METHOD("map_get_use_edge_connections" , "map" ), &NavigationServer3D::map_get_use_edge_connections); |
| 50 | ClassDB::bind_method(D_METHOD("map_set_edge_connection_margin" , "map" , "margin" ), &NavigationServer3D::map_set_edge_connection_margin); |
| 51 | ClassDB::bind_method(D_METHOD("map_get_edge_connection_margin" , "map" ), &NavigationServer3D::map_get_edge_connection_margin); |
| 52 | ClassDB::bind_method(D_METHOD("map_set_link_connection_radius" , "map" , "radius" ), &NavigationServer3D::map_set_link_connection_radius); |
| 53 | ClassDB::bind_method(D_METHOD("map_get_link_connection_radius" , "map" ), &NavigationServer3D::map_get_link_connection_radius); |
| 54 | ClassDB::bind_method(D_METHOD("map_get_path" , "map" , "origin" , "destination" , "optimize" , "navigation_layers" ), &NavigationServer3D::map_get_path, DEFVAL(1)); |
| 55 | 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)); |
| 56 | ClassDB::bind_method(D_METHOD("map_get_closest_point" , "map" , "to_point" ), &NavigationServer3D::map_get_closest_point); |
| 57 | ClassDB::bind_method(D_METHOD("map_get_closest_point_normal" , "map" , "to_point" ), &NavigationServer3D::map_get_closest_point_normal); |
| 58 | ClassDB::bind_method(D_METHOD("map_get_closest_point_owner" , "map" , "to_point" ), &NavigationServer3D::map_get_closest_point_owner); |
| 59 | |
| 60 | ClassDB::bind_method(D_METHOD("map_get_links" , "map" ), &NavigationServer3D::map_get_links); |
| 61 | ClassDB::bind_method(D_METHOD("map_get_regions" , "map" ), &NavigationServer3D::map_get_regions); |
| 62 | ClassDB::bind_method(D_METHOD("map_get_agents" , "map" ), &NavigationServer3D::map_get_agents); |
| 63 | ClassDB::bind_method(D_METHOD("map_get_obstacles" , "map" ), &NavigationServer3D::map_get_obstacles); |
| 64 | |
| 65 | ClassDB::bind_method(D_METHOD("map_force_update" , "map" ), &NavigationServer3D::map_force_update); |
| 66 | |
| 67 | ClassDB::bind_method(D_METHOD("query_path" , "parameters" , "result" ), &NavigationServer3D::query_path); |
| 68 | |
| 69 | ClassDB::bind_method(D_METHOD("region_create" ), &NavigationServer3D::region_create); |
| 70 | ClassDB::bind_method(D_METHOD("region_set_enabled" , "region" , "enabled" ), &NavigationServer3D::region_set_enabled); |
| 71 | ClassDB::bind_method(D_METHOD("region_get_enabled" , "region" ), &NavigationServer3D::region_get_enabled); |
| 72 | ClassDB::bind_method(D_METHOD("region_set_use_edge_connections" , "region" , "enabled" ), &NavigationServer3D::region_set_use_edge_connections); |
| 73 | ClassDB::bind_method(D_METHOD("region_get_use_edge_connections" , "region" ), &NavigationServer3D::region_get_use_edge_connections); |
| 74 | ClassDB::bind_method(D_METHOD("region_set_enter_cost" , "region" , "enter_cost" ), &NavigationServer3D::region_set_enter_cost); |
| 75 | ClassDB::bind_method(D_METHOD("region_get_enter_cost" , "region" ), &NavigationServer3D::region_get_enter_cost); |
| 76 | ClassDB::bind_method(D_METHOD("region_set_travel_cost" , "region" , "travel_cost" ), &NavigationServer3D::region_set_travel_cost); |
| 77 | ClassDB::bind_method(D_METHOD("region_get_travel_cost" , "region" ), &NavigationServer3D::region_get_travel_cost); |
| 78 | ClassDB::bind_method(D_METHOD("region_set_owner_id" , "region" , "owner_id" ), &NavigationServer3D::region_set_owner_id); |
| 79 | ClassDB::bind_method(D_METHOD("region_get_owner_id" , "region" ), &NavigationServer3D::region_get_owner_id); |
| 80 | ClassDB::bind_method(D_METHOD("region_owns_point" , "region" , "point" ), &NavigationServer3D::region_owns_point); |
| 81 | ClassDB::bind_method(D_METHOD("region_set_map" , "region" , "map" ), &NavigationServer3D::region_set_map); |
| 82 | ClassDB::bind_method(D_METHOD("region_get_map" , "region" ), &NavigationServer3D::region_get_map); |
| 83 | ClassDB::bind_method(D_METHOD("region_set_navigation_layers" , "region" , "navigation_layers" ), &NavigationServer3D::region_set_navigation_layers); |
| 84 | ClassDB::bind_method(D_METHOD("region_get_navigation_layers" , "region" ), &NavigationServer3D::region_get_navigation_layers); |
| 85 | ClassDB::bind_method(D_METHOD("region_set_transform" , "region" , "transform" ), &NavigationServer3D::region_set_transform); |
| 86 | ClassDB::bind_method(D_METHOD("region_set_navigation_mesh" , "region" , "navigation_mesh" ), &NavigationServer3D::region_set_navigation_mesh); |
| 87 | #ifndef DISABLE_DEPRECATED |
| 88 | ClassDB::bind_method(D_METHOD("region_bake_navigation_mesh" , "navigation_mesh" , "root_node" ), &NavigationServer3D::region_bake_navigation_mesh); |
| 89 | #endif // DISABLE_DEPRECATED |
| 90 | ClassDB::bind_method(D_METHOD("region_get_connections_count" , "region" ), &NavigationServer3D::region_get_connections_count); |
| 91 | ClassDB::bind_method(D_METHOD("region_get_connection_pathway_start" , "region" , "connection" ), &NavigationServer3D::region_get_connection_pathway_start); |
| 92 | ClassDB::bind_method(D_METHOD("region_get_connection_pathway_end" , "region" , "connection" ), &NavigationServer3D::region_get_connection_pathway_end); |
| 93 | |
| 94 | ClassDB::bind_method(D_METHOD("link_create" ), &NavigationServer3D::link_create); |
| 95 | ClassDB::bind_method(D_METHOD("link_set_map" , "link" , "map" ), &NavigationServer3D::link_set_map); |
| 96 | ClassDB::bind_method(D_METHOD("link_get_map" , "link" ), &NavigationServer3D::link_get_map); |
| 97 | ClassDB::bind_method(D_METHOD("link_set_enabled" , "link" , "enabled" ), &NavigationServer3D::link_set_enabled); |
| 98 | ClassDB::bind_method(D_METHOD("link_get_enabled" , "link" ), &NavigationServer3D::link_get_enabled); |
| 99 | ClassDB::bind_method(D_METHOD("link_set_bidirectional" , "link" , "bidirectional" ), &NavigationServer3D::link_set_bidirectional); |
| 100 | ClassDB::bind_method(D_METHOD("link_is_bidirectional" , "link" ), &NavigationServer3D::link_is_bidirectional); |
| 101 | ClassDB::bind_method(D_METHOD("link_set_navigation_layers" , "link" , "navigation_layers" ), &NavigationServer3D::link_set_navigation_layers); |
| 102 | ClassDB::bind_method(D_METHOD("link_get_navigation_layers" , "link" ), &NavigationServer3D::link_get_navigation_layers); |
| 103 | ClassDB::bind_method(D_METHOD("link_set_start_position" , "link" , "position" ), &NavigationServer3D::link_set_start_position); |
| 104 | ClassDB::bind_method(D_METHOD("link_get_start_position" , "link" ), &NavigationServer3D::link_get_start_position); |
| 105 | ClassDB::bind_method(D_METHOD("link_set_end_position" , "link" , "position" ), &NavigationServer3D::link_set_end_position); |
| 106 | ClassDB::bind_method(D_METHOD("link_get_end_position" , "link" ), &NavigationServer3D::link_get_end_position); |
| 107 | ClassDB::bind_method(D_METHOD("link_set_enter_cost" , "link" , "enter_cost" ), &NavigationServer3D::link_set_enter_cost); |
| 108 | ClassDB::bind_method(D_METHOD("link_get_enter_cost" , "link" ), &NavigationServer3D::link_get_enter_cost); |
| 109 | ClassDB::bind_method(D_METHOD("link_set_travel_cost" , "link" , "travel_cost" ), &NavigationServer3D::link_set_travel_cost); |
| 110 | ClassDB::bind_method(D_METHOD("link_get_travel_cost" , "link" ), &NavigationServer3D::link_get_travel_cost); |
| 111 | ClassDB::bind_method(D_METHOD("link_set_owner_id" , "link" , "owner_id" ), &NavigationServer3D::link_set_owner_id); |
| 112 | ClassDB::bind_method(D_METHOD("link_get_owner_id" , "link" ), &NavigationServer3D::link_get_owner_id); |
| 113 | |
| 114 | ClassDB::bind_method(D_METHOD("agent_create" ), &NavigationServer3D::agent_create); |
| 115 | ClassDB::bind_method(D_METHOD("agent_set_avoidance_enabled" , "agent" , "enabled" ), &NavigationServer3D::agent_set_avoidance_enabled); |
| 116 | ClassDB::bind_method(D_METHOD("agent_get_avoidance_enabled" , "agent" ), &NavigationServer3D::agent_get_avoidance_enabled); |
| 117 | ClassDB::bind_method(D_METHOD("agent_set_use_3d_avoidance" , "agent" , "enabled" ), &NavigationServer3D::agent_set_use_3d_avoidance); |
| 118 | ClassDB::bind_method(D_METHOD("agent_get_use_3d_avoidance" , "agent" ), &NavigationServer3D::agent_get_use_3d_avoidance); |
| 119 | |
| 120 | ClassDB::bind_method(D_METHOD("agent_set_map" , "agent" , "map" ), &NavigationServer3D::agent_set_map); |
| 121 | ClassDB::bind_method(D_METHOD("agent_get_map" , "agent" ), &NavigationServer3D::agent_get_map); |
| 122 | ClassDB::bind_method(D_METHOD("agent_set_paused" , "agent" , "paused" ), &NavigationServer3D::agent_set_paused); |
| 123 | ClassDB::bind_method(D_METHOD("agent_get_paused" , "agent" ), &NavigationServer3D::agent_get_paused); |
| 124 | ClassDB::bind_method(D_METHOD("agent_set_neighbor_distance" , "agent" , "distance" ), &NavigationServer3D::agent_set_neighbor_distance); |
| 125 | ClassDB::bind_method(D_METHOD("agent_set_max_neighbors" , "agent" , "count" ), &NavigationServer3D::agent_set_max_neighbors); |
| 126 | ClassDB::bind_method(D_METHOD("agent_set_time_horizon_agents" , "agent" , "time_horizon" ), &NavigationServer3D::agent_set_time_horizon_agents); |
| 127 | ClassDB::bind_method(D_METHOD("agent_set_time_horizon_obstacles" , "agent" , "time_horizon" ), &NavigationServer3D::agent_set_time_horizon_obstacles); |
| 128 | ClassDB::bind_method(D_METHOD("agent_set_radius" , "agent" , "radius" ), &NavigationServer3D::agent_set_radius); |
| 129 | ClassDB::bind_method(D_METHOD("agent_set_height" , "agent" , "height" ), &NavigationServer3D::agent_set_height); |
| 130 | ClassDB::bind_method(D_METHOD("agent_set_max_speed" , "agent" , "max_speed" ), &NavigationServer3D::agent_set_max_speed); |
| 131 | ClassDB::bind_method(D_METHOD("agent_set_velocity_forced" , "agent" , "velocity" ), &NavigationServer3D::agent_set_velocity_forced); |
| 132 | ClassDB::bind_method(D_METHOD("agent_set_velocity" , "agent" , "velocity" ), &NavigationServer3D::agent_set_velocity); |
| 133 | ClassDB::bind_method(D_METHOD("agent_set_position" , "agent" , "position" ), &NavigationServer3D::agent_set_position); |
| 134 | ClassDB::bind_method(D_METHOD("agent_is_map_changed" , "agent" ), &NavigationServer3D::agent_is_map_changed); |
| 135 | ClassDB::bind_method(D_METHOD("agent_set_avoidance_callback" , "agent" , "callback" ), &NavigationServer3D::agent_set_avoidance_callback); |
| 136 | ClassDB::bind_method(D_METHOD("agent_set_avoidance_layers" , "agent" , "layers" ), &NavigationServer3D::agent_set_avoidance_layers); |
| 137 | ClassDB::bind_method(D_METHOD("agent_set_avoidance_mask" , "agent" , "mask" ), &NavigationServer3D::agent_set_avoidance_mask); |
| 138 | ClassDB::bind_method(D_METHOD("agent_set_avoidance_priority" , "agent" , "priority" ), &NavigationServer3D::agent_set_avoidance_priority); |
| 139 | |
| 140 | ClassDB::bind_method(D_METHOD("obstacle_create" ), &NavigationServer3D::obstacle_create); |
| 141 | ClassDB::bind_method(D_METHOD("obstacle_set_avoidance_enabled" , "obstacle" , "enabled" ), &NavigationServer3D::obstacle_set_avoidance_enabled); |
| 142 | ClassDB::bind_method(D_METHOD("obstacle_get_avoidance_enabled" , "obstacle" ), &NavigationServer3D::obstacle_get_avoidance_enabled); |
| 143 | ClassDB::bind_method(D_METHOD("obstacle_set_use_3d_avoidance" , "obstacle" , "enabled" ), &NavigationServer3D::obstacle_set_use_3d_avoidance); |
| 144 | ClassDB::bind_method(D_METHOD("obstacle_get_use_3d_avoidance" , "obstacle" ), &NavigationServer3D::obstacle_get_use_3d_avoidance); |
| 145 | ClassDB::bind_method(D_METHOD("obstacle_set_map" , "obstacle" , "map" ), &NavigationServer3D::obstacle_set_map); |
| 146 | ClassDB::bind_method(D_METHOD("obstacle_get_map" , "obstacle" ), &NavigationServer3D::obstacle_get_map); |
| 147 | ClassDB::bind_method(D_METHOD("obstacle_set_paused" , "obstacle" , "paused" ), &NavigationServer3D::obstacle_set_paused); |
| 148 | ClassDB::bind_method(D_METHOD("obstacle_get_paused" , "obstacle" ), &NavigationServer3D::obstacle_get_paused); |
| 149 | ClassDB::bind_method(D_METHOD("obstacle_set_radius" , "obstacle" , "radius" ), &NavigationServer3D::obstacle_set_radius); |
| 150 | ClassDB::bind_method(D_METHOD("obstacle_set_height" , "obstacle" , "height" ), &NavigationServer3D::obstacle_set_height); |
| 151 | ClassDB::bind_method(D_METHOD("obstacle_set_velocity" , "obstacle" , "velocity" ), &NavigationServer3D::obstacle_set_velocity); |
| 152 | ClassDB::bind_method(D_METHOD("obstacle_set_position" , "obstacle" , "position" ), &NavigationServer3D::obstacle_set_position); |
| 153 | ClassDB::bind_method(D_METHOD("obstacle_set_vertices" , "obstacle" , "vertices" ), &NavigationServer3D::obstacle_set_vertices); |
| 154 | ClassDB::bind_method(D_METHOD("obstacle_set_avoidance_layers" , "obstacle" , "layers" ), &NavigationServer3D::obstacle_set_avoidance_layers); |
| 155 | |
| 156 | ClassDB::bind_method(D_METHOD("parse_source_geometry_data" , "navigation_mesh" , "source_geometry_data" , "root_node" , "callback" ), &NavigationServer3D::parse_source_geometry_data, DEFVAL(Callable())); |
| 157 | ClassDB::bind_method(D_METHOD("bake_from_source_geometry_data" , "navigation_mesh" , "source_geometry_data" , "callback" ), &NavigationServer3D::bake_from_source_geometry_data, DEFVAL(Callable())); |
| 158 | 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())); |
| 159 | |
| 160 | ClassDB::bind_method(D_METHOD("free_rid" , "rid" ), &NavigationServer3D::free); |
| 161 | |
| 162 | ClassDB::bind_method(D_METHOD("set_active" , "active" ), &NavigationServer3D::set_active); |
| 163 | |
| 164 | ClassDB::bind_method(D_METHOD("set_debug_enabled" , "enabled" ), &NavigationServer3D::set_debug_enabled); |
| 165 | ClassDB::bind_method(D_METHOD("get_debug_enabled" ), &NavigationServer3D::get_debug_enabled); |
| 166 | |
| 167 | ADD_SIGNAL(MethodInfo("map_changed" , PropertyInfo(Variant::RID, "map" ))); |
| 168 | |
| 169 | ADD_SIGNAL(MethodInfo("navigation_debug_changed" )); |
| 170 | ADD_SIGNAL(MethodInfo("avoidance_debug_changed" )); |
| 171 | |
| 172 | ClassDB::bind_method(D_METHOD("get_process_info" , "process_info" ), &NavigationServer3D::get_process_info); |
| 173 | |
| 174 | BIND_ENUM_CONSTANT(INFO_ACTIVE_MAPS); |
| 175 | BIND_ENUM_CONSTANT(INFO_REGION_COUNT); |
| 176 | BIND_ENUM_CONSTANT(INFO_AGENT_COUNT); |
| 177 | BIND_ENUM_CONSTANT(INFO_LINK_COUNT); |
| 178 | BIND_ENUM_CONSTANT(INFO_POLYGON_COUNT); |
| 179 | BIND_ENUM_CONSTANT(INFO_EDGE_COUNT); |
| 180 | BIND_ENUM_CONSTANT(INFO_EDGE_MERGE_COUNT); |
| 181 | BIND_ENUM_CONSTANT(INFO_EDGE_CONNECTION_COUNT); |
| 182 | BIND_ENUM_CONSTANT(INFO_EDGE_FREE_COUNT); |
| 183 | } |
| 184 | |
| 185 | NavigationServer3D *NavigationServer3D::get_singleton() { |
| 186 | return singleton; |
| 187 | } |
| 188 | |
| 189 | NavigationServer3D::NavigationServer3D() { |
| 190 | ERR_FAIL_COND(singleton != nullptr); |
| 191 | singleton = this; |
| 192 | |
| 193 | GLOBAL_DEF_BASIC("navigation/2d/default_cell_size" , 1.0); |
| 194 | GLOBAL_DEF("navigation/2d/use_edge_connections" , true); |
| 195 | GLOBAL_DEF_BASIC("navigation/2d/default_edge_connection_margin" , 1.0); |
| 196 | GLOBAL_DEF_BASIC("navigation/2d/default_link_connection_radius" , 4.0); |
| 197 | |
| 198 | GLOBAL_DEF_BASIC("navigation/3d/default_cell_size" , 0.25); |
| 199 | GLOBAL_DEF_BASIC("navigation/3d/default_cell_height" , 0.25); |
| 200 | GLOBAL_DEF("navigation/3d/default_up" , Vector3(0, 1, 0)); |
| 201 | GLOBAL_DEF("navigation/3d/use_edge_connections" , true); |
| 202 | GLOBAL_DEF_BASIC("navigation/3d/default_edge_connection_margin" , 0.25); |
| 203 | GLOBAL_DEF_BASIC("navigation/3d/default_link_connection_radius" , 1.0); |
| 204 | |
| 205 | GLOBAL_DEF("navigation/avoidance/thread_model/avoidance_use_multiple_threads" , true); |
| 206 | GLOBAL_DEF("navigation/avoidance/thread_model/avoidance_use_high_priority_threads" , true); |
| 207 | |
| 208 | GLOBAL_DEF("navigation/baking/thread_model/baking_use_multiple_threads" , true); |
| 209 | GLOBAL_DEF("navigation/baking/thread_model/baking_use_high_priority_threads" , true); |
| 210 | |
| 211 | #ifdef DEBUG_ENABLED |
| 212 | debug_navigation_edge_connection_color = GLOBAL_DEF("debug/shapes/navigation/edge_connection_color" , Color(1.0, 0.0, 1.0, 1.0)); |
| 213 | debug_navigation_geometry_edge_color = GLOBAL_DEF("debug/shapes/navigation/geometry_edge_color" , Color(0.5, 1.0, 1.0, 1.0)); |
| 214 | debug_navigation_geometry_face_color = GLOBAL_DEF("debug/shapes/navigation/geometry_face_color" , Color(0.5, 1.0, 1.0, 0.4)); |
| 215 | debug_navigation_geometry_edge_disabled_color = GLOBAL_DEF("debug/shapes/navigation/geometry_edge_disabled_color" , Color(0.5, 0.5, 0.5, 1.0)); |
| 216 | debug_navigation_geometry_face_disabled_color = GLOBAL_DEF("debug/shapes/navigation/geometry_face_disabled_color" , Color(0.5, 0.5, 0.5, 0.4)); |
| 217 | debug_navigation_link_connection_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_color" , Color(1.0, 0.5, 1.0, 1.0)); |
| 218 | debug_navigation_link_connection_disabled_color = GLOBAL_DEF("debug/shapes/navigation/link_connection_disabled_color" , Color(0.5, 0.5, 0.5, 1.0)); |
| 219 | debug_navigation_agent_path_color = GLOBAL_DEF("debug/shapes/navigation/agent_path_color" , Color(1.0, 0.0, 0.0, 1.0)); |
| 220 | |
| 221 | debug_navigation_enable_edge_connections = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections" , true); |
| 222 | debug_navigation_enable_edge_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_connections_xray" , true); |
| 223 | debug_navigation_enable_edge_lines = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines" , true); |
| 224 | debug_navigation_enable_edge_lines_xray = GLOBAL_DEF("debug/shapes/navigation/enable_edge_lines_xray" , true); |
| 225 | debug_navigation_enable_geometry_face_random_color = GLOBAL_DEF("debug/shapes/navigation/enable_geometry_face_random_color" , true); |
| 226 | debug_navigation_enable_link_connections = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections" , true); |
| 227 | debug_navigation_enable_link_connections_xray = GLOBAL_DEF("debug/shapes/navigation/enable_link_connections_xray" , true); |
| 228 | |
| 229 | debug_navigation_enable_agent_paths = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths" , true); |
| 230 | debug_navigation_enable_agent_paths_xray = GLOBAL_DEF("debug/shapes/navigation/enable_agent_paths_xray" , true); |
| 231 | debug_navigation_agent_path_point_size = GLOBAL_DEF("debug/shapes/navigation/agent_path_point_size" , 4.0); |
| 232 | |
| 233 | debug_navigation_avoidance_agents_radius_color = GLOBAL_DEF("debug/shapes/avoidance/agents_radius_color" , Color(1.0, 1.0, 0.0, 0.25)); |
| 234 | debug_navigation_avoidance_obstacles_radius_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_radius_color" , Color(1.0, 0.5, 0.0, 0.25)); |
| 235 | debug_navigation_avoidance_static_obstacle_pushin_face_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_face_pushin_color" , Color(1.0, 0.0, 0.0, 0.0)); |
| 236 | debug_navigation_avoidance_static_obstacle_pushin_edge_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_edge_pushin_color" , Color(1.0, 0.0, 0.0, 1.0)); |
| 237 | debug_navigation_avoidance_static_obstacle_pushout_face_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_face_pushout_color" , Color(1.0, 1.0, 0.0, 0.5)); |
| 238 | debug_navigation_avoidance_static_obstacle_pushout_edge_color = GLOBAL_DEF("debug/shapes/avoidance/obstacles_static_edge_pushout_color" , Color(1.0, 1.0, 0.0, 1.0)); |
| 239 | debug_navigation_avoidance_enable_agents_radius = GLOBAL_DEF("debug/shapes/avoidance/enable_agents_radius" , true); |
| 240 | debug_navigation_avoidance_enable_obstacles_radius = GLOBAL_DEF("debug/shapes/avoidance/enable_obstacles_radius" , true); |
| 241 | debug_navigation_avoidance_enable_obstacles_static = GLOBAL_DEF("debug/shapes/avoidance/enable_obstacles_static" , true); |
| 242 | |
| 243 | if (Engine::get_singleton()->is_editor_hint()) { |
| 244 | // enable NavigationServer3D when in Editor or else navigation mesh edge connections are invisible |
| 245 | // on runtime tests SceneTree has "Visible Navigation" set and main iteration takes care of this |
| 246 | set_debug_enabled(true); |
| 247 | set_debug_navigation_enabled(true); |
| 248 | set_debug_avoidance_enabled(true); |
| 249 | } |
| 250 | #endif // DEBUG_ENABLED |
| 251 | } |
| 252 | |
| 253 | NavigationServer3D::~NavigationServer3D() { |
| 254 | singleton = nullptr; |
| 255 | } |
| 256 | |
| 257 | void NavigationServer3D::set_debug_enabled(bool p_enabled) { |
| 258 | #ifdef DEBUG_ENABLED |
| 259 | if (debug_enabled != p_enabled) { |
| 260 | debug_dirty = true; |
| 261 | } |
| 262 | |
| 263 | debug_enabled = p_enabled; |
| 264 | |
| 265 | if (debug_dirty) { |
| 266 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 267 | } |
| 268 | #endif // DEBUG_ENABLED |
| 269 | } |
| 270 | |
| 271 | bool NavigationServer3D::get_debug_enabled() const { |
| 272 | return debug_enabled; |
| 273 | } |
| 274 | |
| 275 | #ifdef DEBUG_ENABLED |
| 276 | void NavigationServer3D::_emit_navigation_debug_changed_signal() { |
| 277 | if (navigation_debug_dirty) { |
| 278 | navigation_debug_dirty = false; |
| 279 | emit_signal(SNAME("navigation_debug_changed" )); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | void NavigationServer3D::_emit_avoidance_debug_changed_signal() { |
| 284 | if (avoidance_debug_dirty) { |
| 285 | avoidance_debug_dirty = false; |
| 286 | emit_signal(SNAME("avoidance_debug_changed" )); |
| 287 | } |
| 288 | } |
| 289 | #endif // DEBUG_ENABLED |
| 290 | |
| 291 | #ifdef DEBUG_ENABLED |
| 292 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_material() { |
| 293 | if (debug_navigation_geometry_face_material.is_valid()) { |
| 294 | return debug_navigation_geometry_face_material; |
| 295 | } |
| 296 | |
| 297 | bool enabled_geometry_face_random_color = get_debug_navigation_enable_geometry_face_random_color(); |
| 298 | |
| 299 | Ref<StandardMaterial3D> face_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 300 | face_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 301 | face_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 302 | face_material->set_albedo(get_debug_navigation_geometry_face_color()); |
| 303 | face_material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 304 | if (enabled_geometry_face_random_color) { |
| 305 | face_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); |
| 306 | face_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); |
| 307 | } |
| 308 | |
| 309 | debug_navigation_geometry_face_material = face_material; |
| 310 | |
| 311 | return debug_navigation_geometry_face_material; |
| 312 | } |
| 313 | |
| 314 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_material() { |
| 315 | if (debug_navigation_geometry_edge_material.is_valid()) { |
| 316 | return debug_navigation_geometry_edge_material; |
| 317 | } |
| 318 | |
| 319 | bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray(); |
| 320 | |
| 321 | Ref<StandardMaterial3D> line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 322 | line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 323 | line_material->set_albedo(get_debug_navigation_geometry_edge_color()); |
| 324 | if (enabled_edge_lines_xray) { |
| 325 | line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 326 | } |
| 327 | |
| 328 | debug_navigation_geometry_edge_material = line_material; |
| 329 | |
| 330 | return debug_navigation_geometry_edge_material; |
| 331 | } |
| 332 | |
| 333 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_face_disabled_material() { |
| 334 | if (debug_navigation_geometry_face_disabled_material.is_valid()) { |
| 335 | return debug_navigation_geometry_face_disabled_material; |
| 336 | } |
| 337 | |
| 338 | Ref<StandardMaterial3D> face_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 339 | face_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 340 | face_disabled_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 341 | face_disabled_material->set_albedo(get_debug_navigation_geometry_face_disabled_color()); |
| 342 | |
| 343 | debug_navigation_geometry_face_disabled_material = face_disabled_material; |
| 344 | |
| 345 | return debug_navigation_geometry_face_disabled_material; |
| 346 | } |
| 347 | |
| 348 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_geometry_edge_disabled_material() { |
| 349 | if (debug_navigation_geometry_edge_disabled_material.is_valid()) { |
| 350 | return debug_navigation_geometry_edge_disabled_material; |
| 351 | } |
| 352 | |
| 353 | bool enabled_edge_lines_xray = get_debug_navigation_enable_edge_lines_xray(); |
| 354 | |
| 355 | Ref<StandardMaterial3D> line_disabled_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 356 | line_disabled_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 357 | line_disabled_material->set_albedo(get_debug_navigation_geometry_edge_disabled_color()); |
| 358 | if (enabled_edge_lines_xray) { |
| 359 | line_disabled_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 360 | } |
| 361 | |
| 362 | debug_navigation_geometry_edge_disabled_material = line_disabled_material; |
| 363 | |
| 364 | return debug_navigation_geometry_edge_disabled_material; |
| 365 | } |
| 366 | |
| 367 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_edge_connections_material() { |
| 368 | if (debug_navigation_edge_connections_material.is_valid()) { |
| 369 | return debug_navigation_edge_connections_material; |
| 370 | } |
| 371 | |
| 372 | bool enabled_edge_connections_xray = get_debug_navigation_enable_edge_connections_xray(); |
| 373 | |
| 374 | Ref<StandardMaterial3D> edge_connections_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 375 | edge_connections_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 376 | edge_connections_material->set_albedo(get_debug_navigation_edge_connection_color()); |
| 377 | if (enabled_edge_connections_xray) { |
| 378 | edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 379 | } |
| 380 | edge_connections_material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2); |
| 381 | |
| 382 | debug_navigation_edge_connections_material = edge_connections_material; |
| 383 | |
| 384 | return debug_navigation_edge_connections_material; |
| 385 | } |
| 386 | |
| 387 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_link_connections_material() { |
| 388 | if (debug_navigation_link_connections_material.is_valid()) { |
| 389 | return debug_navigation_link_connections_material; |
| 390 | } |
| 391 | |
| 392 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 393 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 394 | material->set_albedo(debug_navigation_link_connection_color); |
| 395 | if (debug_navigation_enable_link_connections_xray) { |
| 396 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 397 | } |
| 398 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2); |
| 399 | |
| 400 | debug_navigation_link_connections_material = material; |
| 401 | return debug_navigation_link_connections_material; |
| 402 | } |
| 403 | |
| 404 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_link_connections_disabled_material() { |
| 405 | if (debug_navigation_link_connections_disabled_material.is_valid()) { |
| 406 | return debug_navigation_link_connections_disabled_material; |
| 407 | } |
| 408 | |
| 409 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 410 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 411 | material->set_albedo(debug_navigation_link_connection_disabled_color); |
| 412 | if (debug_navigation_enable_link_connections_xray) { |
| 413 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 414 | } |
| 415 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2); |
| 416 | |
| 417 | debug_navigation_link_connections_disabled_material = material; |
| 418 | return debug_navigation_link_connections_disabled_material; |
| 419 | } |
| 420 | |
| 421 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_line_material() { |
| 422 | if (debug_navigation_agent_path_line_material.is_valid()) { |
| 423 | return debug_navigation_agent_path_line_material; |
| 424 | } |
| 425 | |
| 426 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 427 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 428 | |
| 429 | material->set_albedo(debug_navigation_agent_path_color); |
| 430 | if (debug_navigation_enable_agent_paths_xray) { |
| 431 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 432 | } |
| 433 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2); |
| 434 | |
| 435 | debug_navigation_agent_path_line_material = material; |
| 436 | return debug_navigation_agent_path_line_material; |
| 437 | } |
| 438 | |
| 439 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_agent_path_point_material() { |
| 440 | if (debug_navigation_agent_path_point_material.is_valid()) { |
| 441 | return debug_navigation_agent_path_point_material; |
| 442 | } |
| 443 | |
| 444 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 445 | material->set_albedo(debug_navigation_agent_path_color); |
| 446 | material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); |
| 447 | material->set_point_size(debug_navigation_agent_path_point_size); |
| 448 | if (debug_navigation_enable_agent_paths_xray) { |
| 449 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 450 | } |
| 451 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MAX - 2); |
| 452 | |
| 453 | debug_navigation_agent_path_point_material = material; |
| 454 | return debug_navigation_agent_path_point_material; |
| 455 | } |
| 456 | |
| 457 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_agents_radius_material() { |
| 458 | if (debug_navigation_avoidance_agents_radius_material.is_valid()) { |
| 459 | return debug_navigation_avoidance_agents_radius_material; |
| 460 | } |
| 461 | |
| 462 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 463 | material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 464 | material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 465 | material->set_albedo(debug_navigation_avoidance_agents_radius_color); |
| 466 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 467 | |
| 468 | debug_navigation_avoidance_agents_radius_material = material; |
| 469 | return debug_navigation_avoidance_agents_radius_material; |
| 470 | } |
| 471 | |
| 472 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_obstacles_radius_material() { |
| 473 | if (debug_navigation_avoidance_obstacles_radius_material.is_valid()) { |
| 474 | return debug_navigation_avoidance_obstacles_radius_material; |
| 475 | } |
| 476 | |
| 477 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 478 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 479 | material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 480 | material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 481 | material->set_albedo(debug_navigation_avoidance_obstacles_radius_color); |
| 482 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 483 | |
| 484 | debug_navigation_avoidance_obstacles_radius_material = material; |
| 485 | return debug_navigation_avoidance_obstacles_radius_material; |
| 486 | } |
| 487 | |
| 488 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_face_material() { |
| 489 | if (debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) { |
| 490 | return debug_navigation_avoidance_static_obstacle_pushin_face_material; |
| 491 | } |
| 492 | |
| 493 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 494 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 495 | material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 496 | material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 497 | material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_face_color); |
| 498 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 499 | |
| 500 | debug_navigation_avoidance_static_obstacle_pushin_face_material = material; |
| 501 | return debug_navigation_avoidance_static_obstacle_pushin_face_material; |
| 502 | } |
| 503 | |
| 504 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_face_material() { |
| 505 | if (debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) { |
| 506 | return debug_navigation_avoidance_static_obstacle_pushout_face_material; |
| 507 | } |
| 508 | |
| 509 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 510 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 511 | material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 512 | material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 513 | material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_face_color); |
| 514 | material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 515 | |
| 516 | debug_navigation_avoidance_static_obstacle_pushout_face_material = material; |
| 517 | return debug_navigation_avoidance_static_obstacle_pushout_face_material; |
| 518 | } |
| 519 | |
| 520 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_edge_material() { |
| 521 | if (debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) { |
| 522 | return debug_navigation_avoidance_static_obstacle_pushin_edge_material; |
| 523 | } |
| 524 | |
| 525 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 526 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 527 | //material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 528 | //material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 529 | material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_edge_color); |
| 530 | //material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 531 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 532 | |
| 533 | debug_navigation_avoidance_static_obstacle_pushin_edge_material = material; |
| 534 | return debug_navigation_avoidance_static_obstacle_pushin_edge_material; |
| 535 | } |
| 536 | |
| 537 | Ref<StandardMaterial3D> NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_edge_material() { |
| 538 | if (debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) { |
| 539 | return debug_navigation_avoidance_static_obstacle_pushout_edge_material; |
| 540 | } |
| 541 | |
| 542 | Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); |
| 543 | material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); |
| 544 | ///material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); |
| 545 | //material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); |
| 546 | material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_edge_color); |
| 547 | //material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 2); |
| 548 | material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); |
| 549 | |
| 550 | debug_navigation_avoidance_static_obstacle_pushout_edge_material = material; |
| 551 | return debug_navigation_avoidance_static_obstacle_pushout_edge_material; |
| 552 | } |
| 553 | |
| 554 | void NavigationServer3D::set_debug_navigation_edge_connection_color(const Color &p_color) { |
| 555 | debug_navigation_edge_connection_color = p_color; |
| 556 | if (debug_navigation_edge_connections_material.is_valid()) { |
| 557 | debug_navigation_edge_connections_material->set_albedo(debug_navigation_edge_connection_color); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | Color NavigationServer3D::get_debug_navigation_edge_connection_color() const { |
| 562 | return debug_navigation_edge_connection_color; |
| 563 | } |
| 564 | |
| 565 | void NavigationServer3D::set_debug_navigation_geometry_edge_color(const Color &p_color) { |
| 566 | debug_navigation_geometry_edge_color = p_color; |
| 567 | if (debug_navigation_geometry_edge_material.is_valid()) { |
| 568 | debug_navigation_geometry_edge_material->set_albedo(debug_navigation_geometry_edge_color); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | Color NavigationServer3D::get_debug_navigation_geometry_edge_color() const { |
| 573 | return debug_navigation_geometry_edge_color; |
| 574 | } |
| 575 | |
| 576 | void NavigationServer3D::set_debug_navigation_geometry_face_color(const Color &p_color) { |
| 577 | debug_navigation_geometry_face_color = p_color; |
| 578 | if (debug_navigation_geometry_face_material.is_valid()) { |
| 579 | debug_navigation_geometry_face_material->set_albedo(debug_navigation_geometry_face_color); |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | Color NavigationServer3D::get_debug_navigation_geometry_face_color() const { |
| 584 | return debug_navigation_geometry_face_color; |
| 585 | } |
| 586 | |
| 587 | void NavigationServer3D::set_debug_navigation_geometry_edge_disabled_color(const Color &p_color) { |
| 588 | debug_navigation_geometry_edge_disabled_color = p_color; |
| 589 | if (debug_navigation_geometry_edge_disabled_material.is_valid()) { |
| 590 | debug_navigation_geometry_edge_disabled_material->set_albedo(debug_navigation_geometry_edge_disabled_color); |
| 591 | } |
| 592 | } |
| 593 | |
| 594 | Color NavigationServer3D::get_debug_navigation_geometry_edge_disabled_color() const { |
| 595 | return debug_navigation_geometry_edge_disabled_color; |
| 596 | } |
| 597 | |
| 598 | void NavigationServer3D::set_debug_navigation_geometry_face_disabled_color(const Color &p_color) { |
| 599 | debug_navigation_geometry_face_disabled_color = p_color; |
| 600 | if (debug_navigation_geometry_face_disabled_material.is_valid()) { |
| 601 | debug_navigation_geometry_face_disabled_material->set_albedo(debug_navigation_geometry_face_disabled_color); |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | Color NavigationServer3D::get_debug_navigation_geometry_face_disabled_color() const { |
| 606 | return debug_navigation_geometry_face_disabled_color; |
| 607 | } |
| 608 | |
| 609 | void NavigationServer3D::set_debug_navigation_link_connection_color(const Color &p_color) { |
| 610 | debug_navigation_link_connection_color = p_color; |
| 611 | if (debug_navigation_link_connections_material.is_valid()) { |
| 612 | debug_navigation_link_connections_material->set_albedo(debug_navigation_link_connection_color); |
| 613 | } |
| 614 | } |
| 615 | |
| 616 | Color NavigationServer3D::get_debug_navigation_link_connection_color() const { |
| 617 | return debug_navigation_link_connection_color; |
| 618 | } |
| 619 | |
| 620 | void NavigationServer3D::set_debug_navigation_link_connection_disabled_color(const Color &p_color) { |
| 621 | debug_navigation_link_connection_disabled_color = p_color; |
| 622 | if (debug_navigation_link_connections_disabled_material.is_valid()) { |
| 623 | debug_navigation_link_connections_disabled_material->set_albedo(debug_navigation_link_connection_disabled_color); |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | Color NavigationServer3D::get_debug_navigation_link_connection_disabled_color() const { |
| 628 | return debug_navigation_link_connection_disabled_color; |
| 629 | } |
| 630 | |
| 631 | void NavigationServer3D::set_debug_navigation_agent_path_point_size(real_t p_point_size) { |
| 632 | debug_navigation_agent_path_point_size = MAX(0.1, p_point_size); |
| 633 | if (debug_navigation_agent_path_point_material.is_valid()) { |
| 634 | debug_navigation_agent_path_point_material->set_point_size(debug_navigation_agent_path_point_size); |
| 635 | } |
| 636 | } |
| 637 | |
| 638 | real_t NavigationServer3D::get_debug_navigation_agent_path_point_size() const { |
| 639 | return debug_navigation_agent_path_point_size; |
| 640 | } |
| 641 | |
| 642 | void NavigationServer3D::set_debug_navigation_agent_path_color(const Color &p_color) { |
| 643 | debug_navigation_agent_path_color = p_color; |
| 644 | if (debug_navigation_agent_path_line_material.is_valid()) { |
| 645 | debug_navigation_agent_path_line_material->set_albedo(debug_navigation_agent_path_color); |
| 646 | } |
| 647 | if (debug_navigation_agent_path_point_material.is_valid()) { |
| 648 | debug_navigation_agent_path_point_material->set_albedo(debug_navigation_agent_path_color); |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | Color NavigationServer3D::get_debug_navigation_agent_path_color() const { |
| 653 | return debug_navigation_agent_path_color; |
| 654 | } |
| 655 | |
| 656 | void NavigationServer3D::set_debug_navigation_enable_edge_connections(const bool p_value) { |
| 657 | debug_navigation_enable_edge_connections = p_value; |
| 658 | navigation_debug_dirty = true; |
| 659 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 660 | } |
| 661 | |
| 662 | bool NavigationServer3D::get_debug_navigation_enable_edge_connections() const { |
| 663 | return debug_navigation_enable_edge_connections; |
| 664 | } |
| 665 | |
| 666 | void NavigationServer3D::set_debug_navigation_enable_edge_connections_xray(const bool p_value) { |
| 667 | debug_navigation_enable_edge_connections_xray = p_value; |
| 668 | if (debug_navigation_edge_connections_material.is_valid()) { |
| 669 | debug_navigation_edge_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_edge_connections_xray); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | bool NavigationServer3D::get_debug_navigation_enable_edge_connections_xray() const { |
| 674 | return debug_navigation_enable_edge_connections_xray; |
| 675 | } |
| 676 | |
| 677 | void NavigationServer3D::set_debug_navigation_enable_edge_lines(const bool p_value) { |
| 678 | debug_navigation_enable_edge_lines = p_value; |
| 679 | navigation_debug_dirty = true; |
| 680 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 681 | } |
| 682 | |
| 683 | bool NavigationServer3D::get_debug_navigation_enable_edge_lines() const { |
| 684 | return debug_navigation_enable_edge_lines; |
| 685 | } |
| 686 | |
| 687 | void NavigationServer3D::set_debug_navigation_enable_edge_lines_xray(const bool p_value) { |
| 688 | debug_navigation_enable_edge_lines_xray = p_value; |
| 689 | if (debug_navigation_geometry_edge_material.is_valid()) { |
| 690 | debug_navigation_geometry_edge_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_edge_lines_xray); |
| 691 | } |
| 692 | } |
| 693 | |
| 694 | bool NavigationServer3D::get_debug_navigation_enable_edge_lines_xray() const { |
| 695 | return debug_navigation_enable_edge_lines_xray; |
| 696 | } |
| 697 | |
| 698 | void NavigationServer3D::set_debug_navigation_enable_geometry_face_random_color(const bool p_value) { |
| 699 | debug_navigation_enable_geometry_face_random_color = p_value; |
| 700 | navigation_debug_dirty = true; |
| 701 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 702 | } |
| 703 | |
| 704 | bool NavigationServer3D::get_debug_navigation_enable_geometry_face_random_color() const { |
| 705 | return debug_navigation_enable_geometry_face_random_color; |
| 706 | } |
| 707 | |
| 708 | void NavigationServer3D::set_debug_navigation_enable_link_connections(const bool p_value) { |
| 709 | debug_navigation_enable_link_connections = p_value; |
| 710 | navigation_debug_dirty = true; |
| 711 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 712 | } |
| 713 | |
| 714 | bool NavigationServer3D::get_debug_navigation_enable_link_connections() const { |
| 715 | return debug_navigation_enable_link_connections; |
| 716 | } |
| 717 | |
| 718 | void NavigationServer3D::set_debug_navigation_enable_link_connections_xray(const bool p_value) { |
| 719 | debug_navigation_enable_link_connections_xray = p_value; |
| 720 | if (debug_navigation_link_connections_material.is_valid()) { |
| 721 | debug_navigation_link_connections_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_link_connections_xray); |
| 722 | } |
| 723 | } |
| 724 | |
| 725 | bool NavigationServer3D::get_debug_navigation_enable_link_connections_xray() const { |
| 726 | return debug_navigation_enable_link_connections_xray; |
| 727 | } |
| 728 | |
| 729 | void NavigationServer3D::set_debug_navigation_avoidance_enable_agents_radius(const bool p_value) { |
| 730 | debug_navigation_avoidance_enable_agents_radius = p_value; |
| 731 | avoidance_debug_dirty = true; |
| 732 | call_deferred("_emit_avoidance_debug_changed_signal" ); |
| 733 | } |
| 734 | |
| 735 | bool NavigationServer3D::get_debug_navigation_avoidance_enable_agents_radius() const { |
| 736 | return debug_navigation_avoidance_enable_agents_radius; |
| 737 | } |
| 738 | |
| 739 | void NavigationServer3D::set_debug_navigation_avoidance_enable_obstacles_radius(const bool p_value) { |
| 740 | debug_navigation_avoidance_enable_obstacles_radius = p_value; |
| 741 | avoidance_debug_dirty = true; |
| 742 | call_deferred("_emit_avoidance_debug_changed_signal" ); |
| 743 | } |
| 744 | |
| 745 | bool NavigationServer3D::get_debug_navigation_avoidance_enable_obstacles_radius() const { |
| 746 | return debug_navigation_avoidance_enable_obstacles_radius; |
| 747 | } |
| 748 | |
| 749 | void NavigationServer3D::set_debug_navigation_avoidance_enable_obstacles_static(const bool p_value) { |
| 750 | debug_navigation_avoidance_enable_obstacles_static = p_value; |
| 751 | avoidance_debug_dirty = true; |
| 752 | call_deferred("_emit_avoidance_debug_changed_signal" ); |
| 753 | } |
| 754 | |
| 755 | bool NavigationServer3D::get_debug_navigation_avoidance_enable_obstacles_static() const { |
| 756 | return debug_navigation_avoidance_enable_obstacles_static; |
| 757 | } |
| 758 | |
| 759 | void NavigationServer3D::set_debug_navigation_avoidance_agents_radius_color(const Color &p_color) { |
| 760 | debug_navigation_avoidance_agents_radius_color = p_color; |
| 761 | if (debug_navigation_avoidance_agents_radius_material.is_valid()) { |
| 762 | debug_navigation_avoidance_agents_radius_material->set_albedo(debug_navigation_avoidance_agents_radius_color); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | Color NavigationServer3D::get_debug_navigation_avoidance_agents_radius_color() const { |
| 767 | return debug_navigation_avoidance_agents_radius_color; |
| 768 | } |
| 769 | |
| 770 | void NavigationServer3D::set_debug_navigation_avoidance_obstacles_radius_color(const Color &p_color) { |
| 771 | debug_navigation_avoidance_obstacles_radius_color = p_color; |
| 772 | if (debug_navigation_avoidance_obstacles_radius_material.is_valid()) { |
| 773 | debug_navigation_avoidance_obstacles_radius_material->set_albedo(debug_navigation_avoidance_obstacles_radius_color); |
| 774 | } |
| 775 | } |
| 776 | |
| 777 | Color NavigationServer3D::get_debug_navigation_avoidance_obstacles_radius_color() const { |
| 778 | return debug_navigation_avoidance_obstacles_radius_color; |
| 779 | } |
| 780 | |
| 781 | void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushin_face_color(const Color &p_color) { |
| 782 | debug_navigation_avoidance_static_obstacle_pushin_face_color = p_color; |
| 783 | if (debug_navigation_avoidance_static_obstacle_pushin_face_material.is_valid()) { |
| 784 | debug_navigation_avoidance_static_obstacle_pushin_face_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_face_color); |
| 785 | } |
| 786 | } |
| 787 | |
| 788 | Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_face_color() const { |
| 789 | return debug_navigation_avoidance_static_obstacle_pushin_face_color; |
| 790 | } |
| 791 | |
| 792 | void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushout_face_color(const Color &p_color) { |
| 793 | debug_navigation_avoidance_static_obstacle_pushout_face_color = p_color; |
| 794 | if (debug_navigation_avoidance_static_obstacle_pushout_face_material.is_valid()) { |
| 795 | debug_navigation_avoidance_static_obstacle_pushout_face_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_face_color); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_face_color() const { |
| 800 | return debug_navigation_avoidance_static_obstacle_pushout_face_color; |
| 801 | } |
| 802 | |
| 803 | void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushin_edge_color(const Color &p_color) { |
| 804 | debug_navigation_avoidance_static_obstacle_pushin_edge_color = p_color; |
| 805 | if (debug_navigation_avoidance_static_obstacle_pushin_edge_material.is_valid()) { |
| 806 | debug_navigation_avoidance_static_obstacle_pushin_edge_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushin_edge_color); |
| 807 | } |
| 808 | } |
| 809 | |
| 810 | Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushin_edge_color() const { |
| 811 | return debug_navigation_avoidance_static_obstacle_pushin_edge_color; |
| 812 | } |
| 813 | |
| 814 | void NavigationServer3D::set_debug_navigation_avoidance_static_obstacle_pushout_edge_color(const Color &p_color) { |
| 815 | debug_navigation_avoidance_static_obstacle_pushout_edge_color = p_color; |
| 816 | if (debug_navigation_avoidance_static_obstacle_pushout_edge_material.is_valid()) { |
| 817 | debug_navigation_avoidance_static_obstacle_pushout_edge_material->set_albedo(debug_navigation_avoidance_static_obstacle_pushout_edge_color); |
| 818 | } |
| 819 | } |
| 820 | |
| 821 | Color NavigationServer3D::get_debug_navigation_avoidance_static_obstacle_pushout_edge_color() const { |
| 822 | return debug_navigation_avoidance_static_obstacle_pushout_edge_color; |
| 823 | } |
| 824 | |
| 825 | void NavigationServer3D::set_debug_navigation_enable_agent_paths(const bool p_value) { |
| 826 | if (debug_navigation_enable_agent_paths != p_value) { |
| 827 | debug_dirty = true; |
| 828 | } |
| 829 | |
| 830 | debug_navigation_enable_agent_paths = p_value; |
| 831 | |
| 832 | if (debug_dirty) { |
| 833 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 834 | } |
| 835 | } |
| 836 | |
| 837 | bool NavigationServer3D::get_debug_navigation_enable_agent_paths() const { |
| 838 | return debug_navigation_enable_agent_paths; |
| 839 | } |
| 840 | |
| 841 | void NavigationServer3D::set_debug_navigation_enable_agent_paths_xray(const bool p_value) { |
| 842 | debug_navigation_enable_agent_paths_xray = p_value; |
| 843 | if (debug_navigation_agent_path_line_material.is_valid()) { |
| 844 | debug_navigation_agent_path_line_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray); |
| 845 | } |
| 846 | if (debug_navigation_agent_path_point_material.is_valid()) { |
| 847 | debug_navigation_agent_path_point_material->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, debug_navigation_enable_agent_paths_xray); |
| 848 | } |
| 849 | } |
| 850 | |
| 851 | bool NavigationServer3D::get_debug_navigation_enable_agent_paths_xray() const { |
| 852 | return debug_navigation_enable_agent_paths_xray; |
| 853 | } |
| 854 | |
| 855 | void NavigationServer3D::set_debug_navigation_enabled(bool p_enabled) { |
| 856 | debug_navigation_enabled = p_enabled; |
| 857 | navigation_debug_dirty = true; |
| 858 | call_deferred("_emit_navigation_debug_changed_signal" ); |
| 859 | } |
| 860 | |
| 861 | bool NavigationServer3D::get_debug_navigation_enabled() const { |
| 862 | return debug_navigation_enabled; |
| 863 | } |
| 864 | |
| 865 | void NavigationServer3D::set_debug_avoidance_enabled(bool p_enabled) { |
| 866 | debug_avoidance_enabled = p_enabled; |
| 867 | avoidance_debug_dirty = true; |
| 868 | call_deferred("_emit_avoidance_debug_changed_signal" ); |
| 869 | } |
| 870 | |
| 871 | bool NavigationServer3D::get_debug_avoidance_enabled() const { |
| 872 | return debug_avoidance_enabled; |
| 873 | } |
| 874 | |
| 875 | #endif // DEBUG_ENABLED |
| 876 | |
| 877 | void NavigationServer3D::query_path(const Ref<NavigationPathQueryParameters3D> &p_query_parameters, Ref<NavigationPathQueryResult3D> p_query_result) const { |
| 878 | ERR_FAIL_COND(!p_query_parameters.is_valid()); |
| 879 | ERR_FAIL_COND(!p_query_result.is_valid()); |
| 880 | |
| 881 | const NavigationUtilities::PathQueryResult _query_result = _query_path(p_query_parameters->get_parameters()); |
| 882 | |
| 883 | p_query_result->set_path(_query_result.path); |
| 884 | p_query_result->set_path_types(_query_result.path_types); |
| 885 | p_query_result->set_path_rids(_query_result.path_rids); |
| 886 | p_query_result->set_path_owner_ids(_query_result.path_owner_ids); |
| 887 | } |
| 888 | |
| 889 | /////////////////////////////////////////////////////// |
| 890 | |
| 891 | NavigationServer3DCallback NavigationServer3DManager::create_callback = nullptr; |
| 892 | |
| 893 | void NavigationServer3DManager::set_default_server(NavigationServer3DCallback p_callback) { |
| 894 | create_callback = p_callback; |
| 895 | } |
| 896 | |
| 897 | NavigationServer3D *NavigationServer3DManager::new_default_server() { |
| 898 | if (create_callback == nullptr) { |
| 899 | return nullptr; |
| 900 | } |
| 901 | |
| 902 | return create_callback(); |
| 903 | } |
| 904 | |