Allow to compile templates without navigation features

This commit is contained in:
Michael Alexsander 2025-03-30 13:20:04 -03:00
parent d52b84e472
commit 556933306a
No known key found for this signature in database
GPG Key ID: A9C91EE110F4EABA
79 changed files with 665 additions and 220 deletions

View File

@ -222,6 +222,8 @@ opts.Add(BoolVariable("disable_3d", "Disable 3D nodes for a smaller executable",
opts.Add(BoolVariable("disable_advanced_gui", "Disable advanced GUI nodes and behaviors", False))
opts.Add(BoolVariable("disable_physics_2d", "Disable 2D physics nodes and server", False))
opts.Add(BoolVariable("disable_physics_3d", "Disable 3D physics nodes and server", False))
opts.Add(BoolVariable("disable_navigation_2d", "Disable 2D navigation features", False))
opts.Add(BoolVariable("disable_navigation_3d", "Disable 3D navigation features", False))
opts.Add(BoolVariable("disable_xr", "Disable XR nodes and server", False))
opts.Add("build_profile", "Path to a file containing a feature build profile", "")
opts.Add(BoolVariable("modules_enabled_by_default", "If no, disable all modules except ones explicitly enabled", True))
@ -934,7 +936,14 @@ sys.modules.pop("detect")
if env.editor_build:
unsupported_opts = []
for disable_opt in ["disable_3d", "disable_advanced_gui", "disable_physics_2d", "disable_physics_3d"]:
for disable_opt in [
"disable_3d",
"disable_advanced_gui",
"disable_physics_2d",
"disable_physics_3d",
"disable_navigation_2d",
"disable_navigation_3d",
]:
if env[disable_opt]:
unsupported_opts.append(disable_opt)
if unsupported_opts != []:
@ -948,6 +957,7 @@ if env.editor_build:
if env["disable_3d"]:
env.Append(CPPDEFINES=["_3D_DISABLED"])
env["disable_physics_3d"] = True
env["disable_navigation_3d"] = True
env["disable_xr"] = True
if env["disable_advanced_gui"]:
env.Append(CPPDEFINES=["ADVANCED_GUI_DISABLED"])
@ -955,6 +965,10 @@ if env["disable_physics_2d"]:
env.Append(CPPDEFINES=["PHYSICS_2D_DISABLED"])
if env["disable_physics_3d"]:
env.Append(CPPDEFINES=["PHYSICS_3D_DISABLED"])
if env["disable_navigation_2d"]:
env.Append(CPPDEFINES=["NAVIGATION_2D_DISABLED"])
if env["disable_navigation_3d"]:
env.Append(CPPDEFINES=["NAVIGATION_3D_DISABLED"])
if env["disable_xr"]:
env.Append(CPPDEFINES=["XR_DISABLED"])
if env["minizip"]:

View File

@ -1630,6 +1630,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF_INTERNAL("internationalization/locale/translations_pot_files", PackedStringArray());
GLOBAL_DEF_INTERNAL("internationalization/locale/translation_add_builtin_strings_to_pot", false);
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
GLOBAL_DEF("navigation/world/map_use_async_iterations", true);
GLOBAL_DEF("navigation/avoidance/thread_model/avoidance_use_multiple_threads", true);
@ -1640,6 +1641,7 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("navigation/baking/use_crash_prevention_checks", true);
GLOBAL_DEF("navigation/baking/thread_model/baking_use_multiple_threads", true);
GLOBAL_DEF("navigation/baking/thread_model/baking_use_high_priority_threads", true);
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
ProjectSettings::get_singleton()->add_hidden_prefix("input/");
}

View File

@ -40,7 +40,7 @@
#include "editor/import/3d/scene_import_settings.h"
#include "scene/3d/importer_mesh_instance_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/3d/occluder_instance_3d.h"
#include "scene/3d/physics/area_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"

View File

@ -32,7 +32,7 @@
#include "editor/editor_undo_redo_manager.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation/navigation_link_3d.h"
#include "servers/navigation_server_3d.h"
NavigationLink3DGizmoPlugin::NavigationLink3DGizmoPlugin() {

View File

@ -31,7 +31,7 @@
#include "navigation_region_3d_gizmo_plugin.h"
#include "core/math/random_pcg.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "servers/navigation_server_3d.h"
NavigationRegion3DGizmoPlugin::NavigationRegion3DGizmoPlugin() {

View File

@ -36,7 +36,7 @@
#include "editor/multi_node_edit.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "editor/themes/editor_scale.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/3d/physics/collision_shape_3d.h"
#include "scene/3d/physics/static_body_3d.h"
#include "scene/gui/aspect_ratio_container.h"

View File

@ -39,7 +39,7 @@
#include "editor/plugins/node_3d_editor_plugin.h"
#include "main/main.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/3d/physics/static_body_3d.h"
#include "scene/gui/menu_button.h"
#include "scene/resources/packed_scene.h"

View File

@ -31,7 +31,7 @@
#pragma once
#include "editor/plugins/editor_plugin.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/2d/navigation/navigation_link_2d.h"
class CanvasItemEditor;

View File

@ -31,7 +31,7 @@
#pragma once
#include "editor/plugins/abstract_polygon_2d_editor.h"
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/navigation/navigation_obstacle_2d.h"
class NavigationObstacle2DEditor : public AbstractPolygon2DEditor {
GDCLASS(NavigationObstacle2DEditor, AbstractPolygon2DEditor);

View File

@ -36,7 +36,7 @@
#include "editor/editor_string_names.h"
#include "editor/editor_undo_redo_manager.h"
#include "editor/plugins/node_3d_editor_plugin.h"
#include "scene/3d/navigation_obstacle_3d.h"
#include "scene/3d/navigation/navigation_obstacle_3d.h"
#include "scene/gui/button.h"
#include "scene/gui/dialogs.h"
#include "servers/navigation_server_3d.h"

View File

@ -33,7 +33,7 @@
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/editor_undo_redo_manager.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/navigation/navigation_region_2d.h"
#include "scene/gui/dialogs.h"
Ref<NavigationPolygon> NavigationPolygonEditor::_ensure_navpoly() const {

View File

@ -72,25 +72,30 @@
#include "servers/display_server.h"
#include "servers/movie_writer/movie_writer.h"
#include "servers/movie_writer/movie_writer_mjpeg.h"
#include "servers/navigation_server_3d.h"
#include "servers/navigation_server_3d_dummy.h"
#include "servers/register_server_types.h"
#include "servers/rendering/rendering_server_default.h"
#include "servers/text/text_server_dummy.h"
#include "servers/text_server.h"
// 2D
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#include "servers/navigation_server_2d_dummy.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
#include "servers/physics_server_2d.h"
#include "servers/physics_server_2d_dummy.h"
#endif // PHYSICS_2D_DISABLED
// 3D
#ifndef PHYSICS_3D_DISABLED
#include "servers/physics_server_3d.h"
#include "servers/physics_server_3d_dummy.h"
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
#include "servers/navigation_server_3d_dummy.h"
#endif // NAVIGATION_3D_DISABLED
#ifndef _3D_DISABLED
#include "servers/xr_server.h"
#endif // _3D_DISABLED
@ -754,8 +759,12 @@ Error Main::test_setup() {
// Default theme will be initialized later, after modules and ScriptServer are ready.
initialize_theme_db();
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3DManager::initialize_server();
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2DManager::initialize_server();
#endif // NAVIGATION_2D_DISABLED
register_scene_types();
register_driver_types();
@ -839,8 +848,12 @@ void Main::test_cleanup() {
finalize_theme_db();
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2DManager::finalize_server();
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3DManager::finalize_server();
#endif // NAVIGATION_3D_DISABLED
GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);
uninitialize_modules(MODULE_INITIALIZATION_LEVEL_SERVERS);
@ -3496,10 +3509,16 @@ Error Main::setup2(bool p_show_boot_logo) {
// Default theme will be initialized later, after modules and ScriptServer are ready.
initialize_theme_db();
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
MAIN_PRINT("Main: Load Navigation");
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3DManager::initialize_server();
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2DManager::initialize_server();
#endif // NAVIGATION_2D_DISABLED
register_scene_types();
register_driver_types();
@ -4102,20 +4121,33 @@ int Main::start() {
if (debug_paths) {
sml->set_debug_paths_hint(true);
}
if (debug_navigation) {
sml->set_debug_navigation_hint(true);
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D::get_singleton()->set_debug_navigation_enabled(true);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D::get_singleton()->set_debug_navigation_enabled(true);
#endif // NAVIGATION_3D_DISABLED
}
if (debug_avoidance) {
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D::get_singleton()->set_debug_avoidance_enabled(true);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D::get_singleton()->set_debug_avoidance_enabled(true);
#endif // NAVIGATION_3D_DISABLED
}
if (debug_navigation || debug_avoidance) {
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D::get_singleton()->set_active(true);
NavigationServer2D::get_singleton()->set_debug_enabled(true);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D::get_singleton()->set_active(true);
NavigationServer3D::get_singleton()->set_debug_enabled(true);
#endif // NAVIGATION_3D_DISABLED
}
if (debug_canvas_item_redraw) {
RenderingServer::get_singleton()->canvas_item_set_debug_redraw(true);
@ -4546,7 +4578,9 @@ bool Main::iteration() {
uint64_t physics_process_ticks = 0;
uint64_t process_ticks = 0;
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
uint64_t navigation_process_ticks = 0;
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
frame += ticks_elapsed;
@ -4565,8 +4599,12 @@ bool Main::iteration() {
XRServer::get_singleton()->_process();
#endif // XR_DISABLED
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D::get_singleton()->sync();
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D::get_singleton()->sync();
#endif // NAVIGATION_3D_DISABLED
for (int iters = 0; iters < advance.physics_steps; ++iters) {
if (Input::get_singleton()->is_agile_input_event_flushing()) {
@ -4606,15 +4644,21 @@ bool Main::iteration() {
break;
}
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
uint64_t navigation_begin = OS::get_singleton()->get_ticks_usec();
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D::get_singleton()->process(physics_step * time_scale);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D::get_singleton()->process(physics_step * time_scale);
#endif // NAVIGATION_3D_DISABLED
navigation_process_ticks = MAX(navigation_process_ticks, OS::get_singleton()->get_ticks_usec() - navigation_begin); // keep the largest one for reference
navigation_process_max = MAX(OS::get_singleton()->get_ticks_usec() - navigation_begin, navigation_process_max);
message_queue->flush();
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
#ifndef PHYSICS_3D_DISABLED
PhysicsServer3D::get_singleton()->end_sync();
@ -4850,9 +4894,13 @@ void Main::cleanup(bool p_force) {
finalize_theme_db();
// Before deinitializing server extensions, finalize servers which may be loaded as extensions.
// Before deinitializing server extensions, finalize servers which may be loaded as extensions.
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2DManager::finalize_server();
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3DManager::finalize_server();
#endif // NAVIGATION_3D_DISABLED
finalize_physics();
GDExtensionManager::get_singleton()->deinitialize_extensions(GDExtension::INITIALIZATION_LEVEL_SERVERS);

View File

@ -35,8 +35,12 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "servers/audio_server.h"
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
#endif // NAVIGATION_3D_DISABLED
#include "servers/rendering_server.h"
#ifndef PHYSICS_2D_DISABLED
@ -84,6 +88,7 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(PHYSICS_3D_ISLAND_COUNT);
#endif // _3D_DISABLED
BIND_ENUM_CONSTANT(AUDIO_OUTPUT_LATENCY);
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
BIND_ENUM_CONSTANT(NAVIGATION_ACTIVE_MAPS);
BIND_ENUM_CONSTANT(NAVIGATION_REGION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_AGENT_COUNT);
@ -94,11 +99,13 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(NAVIGATION_EDGE_CONNECTION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_EDGE_FREE_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_OBSTACLE_COUNT);
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
BIND_ENUM_CONSTANT(PIPELINE_COMPILATIONS_CANVAS);
BIND_ENUM_CONSTANT(PIPELINE_COMPILATIONS_MESH);
BIND_ENUM_CONSTANT(PIPELINE_COMPILATIONS_SURFACE);
BIND_ENUM_CONSTANT(PIPELINE_COMPILATIONS_DRAW);
BIND_ENUM_CONSTANT(PIPELINE_COMPILATIONS_SPECIALIZATION);
#ifndef NAVIGATION_2D_DISABLED
BIND_ENUM_CONSTANT(NAVIGATION_2D_ACTIVE_MAPS);
BIND_ENUM_CONSTANT(NAVIGATION_2D_REGION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_2D_AGENT_COUNT);
@ -109,6 +116,8 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(NAVIGATION_2D_EDGE_CONNECTION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_2D_EDGE_FREE_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_2D_OBSTACLE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
BIND_ENUM_CONSTANT(NAVIGATION_3D_ACTIVE_MAPS);
BIND_ENUM_CONSTANT(NAVIGATION_3D_REGION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_3D_AGENT_COUNT);
@ -119,6 +128,7 @@ void Performance::_bind_methods() {
BIND_ENUM_CONSTANT(NAVIGATION_3D_EDGE_CONNECTION_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_3D_EDGE_FREE_COUNT);
BIND_ENUM_CONSTANT(NAVIGATION_3D_OBSTACLE_COUNT);
#endif // NAVIGATION_3D_DISABLED
BIND_ENUM_CONSTANT(MONITOR_MAX);
}
@ -158,6 +168,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
PNAME("physics_3d/collision_pairs"),
PNAME("physics_3d/islands"),
PNAME("audio/driver/output_latency"),
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
PNAME("navigation/active_maps"),
PNAME("navigation/regions"),
PNAME("navigation/agents"),
@ -168,11 +179,13 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
PNAME("navigation/edges_connected"),
PNAME("navigation/edges_free"),
PNAME("navigation/obstacles"),
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
PNAME("pipeline/compilations_canvas"),
PNAME("pipeline/compilations_mesh"),
PNAME("pipeline/compilations_surface"),
PNAME("pipeline/compilations_draw"),
PNAME("pipeline/compilations_specialization"),
#ifndef NAVIGATION_2D_DISABLED
PNAME("navigation_2d/active_maps"),
PNAME("navigation_2d/regions"),
PNAME("navigation_2d/agents"),
@ -183,6 +196,8 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
PNAME("navigation_2d/edges_connected"),
PNAME("navigation_2d/edges_free"),
PNAME("navigation_2d/obstacles"),
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
PNAME("navigation_3d/active_maps"),
PNAME("navigation_3d/regions"),
PNAME("navigation_3d/agents"),
@ -193,6 +208,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
PNAME("navigation_3d/edges_connected"),
PNAME("navigation_3d/edges_free"),
PNAME("navigation_3d/obstacles"),
#endif // NAVIGATION_3D_DISABLED
};
static_assert(std::size(names) == MONITOR_MAX);
@ -200,6 +216,8 @@ String Performance::get_monitor_name(Monitor p_monitor) const {
}
double Performance::get_monitor(Monitor p_monitor) const {
int info = 0;
switch (p_monitor) {
case TIME_FPS:
return Engine::get_singleton()->get_frames_per_second();
@ -280,36 +298,96 @@ double Performance::get_monitor(Monitor p_monitor) const {
return AudioServer::get_singleton()->get_output_latency();
case NAVIGATION_ACTIVE_MAPS:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_ACTIVE_MAPS) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_ACTIVE_MAPS);
case NAVIGATION_REGION_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_REGION_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_REGION_COUNT);
case NAVIGATION_AGENT_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_AGENT_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_AGENT_COUNT);
case NAVIGATION_LINK_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_LINK_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_LINK_COUNT);
case NAVIGATION_POLYGON_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_POLYGON_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_POLYGON_COUNT);
case NAVIGATION_EDGE_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_COUNT);
case NAVIGATION_EDGE_MERGE_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_MERGE_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_MERGE_COUNT);
case NAVIGATION_EDGE_CONNECTION_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_CONNECTION_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_CONNECTION_COUNT);
case NAVIGATION_EDGE_FREE_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_FREE_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_FREE_COUNT);
case NAVIGATION_OBSTACLE_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_OBSTACLE_COUNT) +
NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_OBSTACLE_COUNT);
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_ACTIVE_MAPS);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_ACTIVE_MAPS);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_REGION_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_REGION_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_REGION_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_AGENT_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_AGENT_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_AGENT_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_LINK_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_LINK_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_LINK_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_POLYGON_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_POLYGON_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_POLYGON_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_EDGE_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_EDGE_MERGE_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_MERGE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_MERGE_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_EDGE_CONNECTION_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_CONNECTION_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_CONNECTION_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_EDGE_FREE_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_FREE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_FREE_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
case NAVIGATION_OBSTACLE_COUNT:
#ifndef NAVIGATION_2D_DISABLED
info = NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_OBSTACLE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
info += NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_OBSTACLE_COUNT);
#endif // NAVIGATION_3D_DISABLED
return info;
#ifndef NAVIGATION_2D_DISABLED
case NAVIGATION_2D_ACTIVE_MAPS:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_ACTIVE_MAPS);
case NAVIGATION_2D_REGION_COUNT:
@ -330,7 +408,9 @@ double Performance::get_monitor(Monitor p_monitor) const {
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_EDGE_FREE_COUNT);
case NAVIGATION_2D_OBSTACLE_COUNT:
return NavigationServer2D::get_singleton()->get_process_info(NavigationServer2D::INFO_OBSTACLE_COUNT);
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
case NAVIGATION_3D_ACTIVE_MAPS:
return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_ACTIVE_MAPS);
case NAVIGATION_3D_REGION_COUNT:
@ -351,6 +431,7 @@ double Performance::get_monitor(Monitor p_monitor) const {
return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_FREE_COUNT);
case NAVIGATION_3D_OBSTACLE_COUNT:
return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_OBSTACLE_COUNT);
#endif // NAVIGATION_3D_DISABLED
default: {
}

View File

@ -36,10 +36,13 @@
#include "core/math/geometry_2d.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
#endif // NAVIGATION_3D_DISABLED
#include <manifold/manifold.h>
#ifndef NAVIGATION_3D_DISABLED
Callable CSGShape3D::_navmesh_source_geometry_parsing_callback;
RID CSGShape3D::_navmesh_source_geometry_parser;
@ -76,6 +79,7 @@ void CSGShape3D::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navi
}
}
}
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
void CSGShape3D::set_use_collision(bool p_enable) {

View File

@ -184,6 +184,7 @@ public:
virtual Ref<TriangleMesh> generate_triangle_mesh() const override;
#ifndef NAVIGATION_3D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
@ -191,6 +192,7 @@ private:
public:
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
CSGShape3D();
~CSGShape3D();

View File

@ -47,7 +47,9 @@ void initialize_csg_module(ModuleInitializationLevel p_level) {
GDREGISTER_CLASS(CSGTorus3D);
GDREGISTER_CLASS(CSGPolygon3D);
GDREGISTER_CLASS(CSGCombiner3D);
#ifndef NAVIGATION_3D_DISABLED
CSGShape3D::navmesh_parse_init();
#endif // NAVIGATION_3D_DISABLED
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {

View File

@ -45,11 +45,14 @@
#include "scene/resources/3d/sphere_shape_3d.h"
#include "scene/resources/physics_material.h"
#include "scene/resources/surface_tool.h"
#include "servers/navigation_server_3d.h"
#include "servers/rendering_server.h"
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
Callable GridMap::_navmesh_source_geometry_parsing_callback;
RID GridMap::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
bool GridMap::_set(const StringName &p_name, const Variant &p_value) {
String name = p_name;
@ -247,6 +250,7 @@ bool GridMap::is_baking_navigation() {
return bake_navigation;
}
#ifndef NAVIGATION_3D_DISABLED
void GridMap::set_navigation_map(RID p_navigation_map) {
map_override = p_navigation_map;
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
@ -267,6 +271,7 @@ RID GridMap::get_navigation_map() const {
}
return RID();
}
#endif // NAVIGATION_3D_DISABLED
void GridMap::set_mesh_library(const Ref<MeshLibrary> &p_mesh_library) {
if (mesh_library.is_valid()) {
@ -541,6 +546,7 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
}
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
// update transform for NavigationServer regions and navigation debugmesh instances
for (const KeyValue<IndexKey, Octant::NavigationCell> &E : g.navigation_cell_ids) {
if (bake_navigation) {
@ -552,6 +558,7 @@ void GridMap::_octant_transform(const OctantKey &p_key) {
}
}
}
#endif // NAVIGATION_3D_DISABLED
for (int i = 0; i < g.multimesh_instances.size(); i++) {
RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
@ -575,6 +582,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
//erase navigation
for (KeyValue<IndexKey, Octant::NavigationCell> &E : g.navigation_cell_ids) {
if (E.value.region.is_valid()) {
@ -587,6 +595,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
}
g.navigation_cell_ids.clear();
#endif // NAVIGATION_3D_DISABLED
//erase multimeshes
@ -656,6 +665,7 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
// add the item's navigation_mesh at given xform to GridMap's Navigation ancestor
Ref<NavigationMesh> navigation_mesh = mesh_library->get_item_navigation_mesh(c.item);
if (navigation_mesh.is_valid()) {
@ -696,13 +706,14 @@ bool GridMap::_octant_update(const OctantKey &p_key) {
}
g.navigation_cell_ids[E] = nm;
}
#endif // NAVIGATION_3D_DISABLED
}
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
if (bake_navigation) {
_update_octant_navigation_debug_edge_connections_mesh(p_key);
}
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
//update multimeshes, only if not baked
if (baked_meshes.size() == 0) {
@ -806,6 +817,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
RS::get_singleton()->instance_set_transform(g.multimesh_instances[i].instance, get_global_transform());
}
#ifndef NAVIGATION_3D_DISABLED
if (bake_navigation && mesh_library.is_valid()) {
for (KeyValue<IndexKey, Octant::NavigationCell> &F : g.navigation_cell_ids) {
if (cell_map.has(F.key) && F.value.region.is_valid() == false) {
@ -840,6 +852,7 @@ void GridMap::_octant_enter_world(const OctantKey &p_key) {
}
#endif // DEBUG_ENABLED
}
#endif // NAVIGATION_3D_DISABLED
}
void GridMap::_octant_exit_world(const OctantKey &p_key) {
@ -847,7 +860,9 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
#ifndef PHYSICS_3D_DISABLED
ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
#endif // NAVIGATION_3D_DISABLED
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
@ -865,6 +880,7 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
RS::get_singleton()->instance_set_scenario(g.multimesh_instances[i].instance, RID());
}
#ifndef NAVIGATION_3D_DISABLED
for (KeyValue<IndexKey, Octant::NavigationCell> &F : g.navigation_cell_ids) {
if (F.value.region.is_valid()) {
NavigationServer3D::get_singleton()->free(F.value.region);
@ -875,6 +891,7 @@ void GridMap::_octant_exit_world(const OctantKey &p_key) {
F.value.navigation_mesh_debug_instance = RID();
}
}
#endif // NAVIGATION_3D_DISABLED
#ifdef DEBUG_ENABLED
if (bake_navigation) {
@ -894,7 +911,9 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
#ifndef PHYSICS_3D_DISABLED
ERR_FAIL_NULL(PhysicsServer3D::get_singleton());
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
#endif // NAVIGATION_3D_DISABLED
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
@ -910,6 +929,7 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
PhysicsServer3D::get_singleton()->free(g.static_body);
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
// Erase navigation
for (const KeyValue<IndexKey, Octant::NavigationCell> &E : g.navigation_cell_ids) {
if (E.value.region.is_valid()) {
@ -920,6 +940,7 @@ void GridMap::_octant_clean_up(const OctantKey &p_key) {
}
}
g.navigation_cell_ids.clear();
#endif // NAVIGATION_3D_DISABLED
#ifdef DEBUG_ENABLED
if (bake_navigation) {
@ -958,11 +979,11 @@ void GridMap::_notification(int p_what) {
} break;
case NOTIFICATION_ENTER_TREE: {
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
if (bake_navigation && NavigationServer3D::get_singleton()->get_debug_navigation_enabled()) {
_update_navigation_debug_edge_connections();
}
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
_update_visibility();
} break;
@ -1109,8 +1130,10 @@ void GridMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_bake_navigation", "bake_navigation"), &GridMap::set_bake_navigation);
ClassDB::bind_method(D_METHOD("is_baking_navigation"), &GridMap::is_baking_navigation);
#ifndef NAVIGATION_3D_DISABLED
ClassDB::bind_method(D_METHOD("set_navigation_map", "navigation_map"), &GridMap::set_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map"), &GridMap::get_navigation_map);
#endif // NAVIGATION_3D_DISABLED
ClassDB::bind_method(D_METHOD("set_mesh_library", "mesh_library"), &GridMap::set_mesh_library);
ClassDB::bind_method(D_METHOD("get_mesh_library"), &GridMap::get_mesh_library);
@ -1373,12 +1396,13 @@ RID GridMap::get_bake_mesh_instance(int p_idx) {
GridMap::GridMap() {
set_notify_transform(true);
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
NavigationServer3D::get_singleton()->connect("map_changed", callable_mp(this, &GridMap::_navigation_map_changed));
NavigationServer3D::get_singleton()->connect("navigation_debug_changed", callable_mp(this, &GridMap::_update_navigation_debug_edge_connections));
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
}
#ifndef NAVIGATION_3D_DISABLED
void GridMap::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -1518,8 +1542,9 @@ void GridMap::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigat
}
#endif // PHYSICS_3D_DISABLED
}
#endif // NAVIGATION_3D_DISABLED
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
void GridMap::_update_navigation_debug_edge_connections() {
if (bake_navigation) {
for (const KeyValue<OctantKey, Octant *> &E : octant_map) {
@ -1533,17 +1558,17 @@ void GridMap::_navigation_map_changed(RID p_map) {
_update_navigation_debug_edge_connections();
}
}
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
GridMap::~GridMap() {
clear();
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
NavigationServer3D::get_singleton()->disconnect("map_changed", callable_mp(this, &GridMap::_navigation_map_changed));
NavigationServer3D::get_singleton()->disconnect("navigation_debug_changed", callable_mp(this, &GridMap::_update_navigation_debug_edge_connections));
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
}
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
void GridMap::_update_octant_navigation_debug_edge_connections_mesh(const OctantKey &p_key) {
ERR_FAIL_COND(!octant_map.has(p_key));
Octant &g = *octant_map[p_key];
@ -1641,4 +1666,4 @@ void GridMap::_update_octant_navigation_debug_edge_connections_mesh(const Octant
RS::get_singleton()->instance_set_visible(g.navigation_debug_edge_connections_instance, false);
}
}
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)

View File

@ -200,11 +200,11 @@ class GridMap : public Node3D {
bool _octant_update(const OctantKey &p_key);
void _octant_clean_up(const OctantKey &p_key);
void _octant_transform(const OctantKey &p_key);
#ifdef DEBUG_ENABLED
#if defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
void _update_octant_navigation_debug_edge_connections_mesh(const OctantKey &p_key);
void _navigation_map_changed(RID p_map);
void _update_navigation_debug_edge_connections();
#endif // DEBUG_ENABLED
#endif // defined(DEBUG_ENABLED) && !defined(NAVIGATION_3D_DISABLED)
bool awaiting_update = false;
void _queue_octants_dirty();
@ -264,8 +264,10 @@ public:
void set_bake_navigation(bool p_bake_navigation);
bool is_baking_navigation();
#ifndef NAVIGATION_3D_DISABLED
void set_navigation_map(RID p_navigation_map);
RID get_navigation_map() const;
#endif // NAVIGATION_3D_DISABLED
void set_mesh_library(const Ref<MeshLibrary> &p_mesh_library);
Ref<MeshLibrary> get_mesh_library() const;
@ -309,13 +311,17 @@ public:
Array get_bake_meshes();
RID get_bake_mesh_instance(int p_idx);
#ifndef NAVIGATION_3D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
public:
#ifndef NAVIGATION_3D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
GridMap();
~GridMap();

View File

@ -43,7 +43,9 @@
void initialize_gridmap_module(ModuleInitializationLevel p_level) {
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
GDREGISTER_CLASS(GridMap);
#ifndef NAVIGATION_3D_DISABLED
GridMap::navmesh_parse_init();
#endif // NAVIGATION_3D_DISABLED
}
#ifdef TOOLS_ENABLED
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {

View File

@ -1,5 +1,5 @@
def can_build(env, platform):
return True
return not env["disable_navigation_2d"]
def configure(env):

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/resources/navigation_mesh.h"
class NavigationMeshSourceGeometryData3D;

View File

@ -1,6 +1,9 @@
def can_build(env, platform):
if env["disable_navigation_3d"]:
return False
env.module_add_dependencies("navigation", ["csg", "gridmap"], True)
return not env["disable_3d"]
return True
def configure(env):

View File

@ -32,7 +32,7 @@
#include "editor/editor_node.h"
#include "editor/editor_string_names.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/gui/box_container.h"
#include "scene/gui/button.h"
#include "scene/gui/dialogs.h"

View File

@ -8,3 +8,5 @@ env.add_source_files(env.scene_sources, "*.cpp")
# Chain load SCsubs
if not env["disable_physics_2d"]:
SConscript("physics/SCsub")
if not env["disable_navigation_2d"]:
SConscript("navigation/SCsub")

View File

@ -30,13 +30,14 @@
#include "mesh_instance_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/2d/navigation_polygon.h"
#include "scene/scene_string_names.h"
#include "servers/navigation_server_2d.h"
#include "thirdparty/clipper2/include/clipper2/clipper.h"
#include "thirdparty/misc/polypartition.h"
#endif // NAVIGATION_2D_DISABLED
Callable MeshInstance2D::_navmesh_source_geometry_parsing_callback;
RID MeshInstance2D::_navmesh_source_geometry_parser;
@ -117,6 +118,7 @@ bool MeshInstance2D::_edit_use_rect() const {
}
#endif // DEBUG_ENABLED
#ifndef NAVIGATION_2D_DISABLED
void MeshInstance2D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -211,6 +213,7 @@ void MeshInstance2D::navmesh_parse_source_geometry(const Ref<NavigationPolygon>
p_source_geometry_data->add_obstruction_outline(shape_outline);
}
}
#endif // NAVIGATION_2D_DISABLED
MeshInstance2D::MeshInstance2D() {
}

View File

@ -63,8 +63,10 @@ private:
static RID _navmesh_source_geometry_parser;
public:
#ifndef NAVIGATION_2D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
MeshInstance2D();
};

View File

@ -30,13 +30,14 @@
#include "multimesh_instance_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/2d/navigation_polygon.h"
#include "scene/scene_string_names.h"
#include "servers/navigation_server_2d.h"
#include "thirdparty/clipper2/include/clipper2/clipper.h"
#include "thirdparty/misc/polypartition.h"
#endif // NAVIGATION_2D_DISABLED
Callable MultiMeshInstance2D::_navmesh_source_geometry_parsing_callback;
RID MultiMeshInstance2D::_navmesh_source_geometry_parser;
@ -106,6 +107,7 @@ Rect2 MultiMeshInstance2D::_edit_get_rect() const {
}
#endif // DEBUG_ENABLED
#ifndef NAVIGATION_2D_DISABLED
void MultiMeshInstance2D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -209,6 +211,7 @@ void MultiMeshInstance2D::navmesh_parse_source_geometry(const Ref<NavigationPoly
}
}
}
#endif // NAVIGATION_2D_DISABLED
MultiMeshInstance2D::MultiMeshInstance2D() {
}

View File

@ -63,8 +63,10 @@ private:
static RID _navmesh_source_geometry_parser;
public:
#ifndef NAVIGATION_2D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
MultiMeshInstance2D();
~MultiMeshInstance2D();

View File

@ -0,0 +1,6 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.scene_sources, "*.cpp")

View File

@ -31,7 +31,7 @@
#include "navigation_agent_2d.h"
#include "core/math/geometry_2d.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/2d/navigation/navigation_link_2d.h"
#include "scene/resources/world_2d.h"
#include "servers/navigation_server_2d.h"

View File

@ -30,6 +30,7 @@
#include "static_body_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/capsule_shape_2d.h"
#include "scene/resources/2d/circle_shape_2d.h"
#include "scene/resources/2d/concave_polygon_shape_2d.h"
@ -38,6 +39,7 @@
#include "scene/resources/2d/navigation_polygon.h"
#include "scene/resources/2d/rectangle_shape_2d.h"
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
Callable StaticBody2D::_navmesh_source_geometry_parsing_callback;
RID StaticBody2D::_navmesh_source_geometry_parser;
@ -89,6 +91,7 @@ void StaticBody2D::_reload_physics_characteristics() {
}
}
#ifndef NAVIGATION_2D_DISABLED
void StaticBody2D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -213,6 +216,7 @@ void StaticBody2D::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p
}
}
}
#endif // NAVIGATION_2D_DISABLED
void StaticBody2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody2D::set_constant_linear_velocity);

View File

@ -63,9 +63,11 @@ private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#ifndef NAVIGATION_2D_DISABLED
public:
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
private:
void _reload_physics_characteristics();

View File

@ -31,13 +31,17 @@
#include "polygon_2d.h"
#include "core/math/geometry_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/2d/navigation_polygon.h"
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
#include "skeleton_2d.h"
#ifndef NAVIGATION_2D_DISABLED
Callable Polygon2D::_navmesh_source_geometry_parsing_callback;
RID Polygon2D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
#ifdef TOOLS_ENABLED
Dictionary Polygon2D::_edit_get_state() const {
@ -610,6 +614,7 @@ NodePath Polygon2D::get_skeleton() const {
return skeleton;
}
#ifndef NAVIGATION_2D_DISABLED
void Polygon2D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -639,6 +644,7 @@ void Polygon2D::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_na
p_source_geometry_data->add_obstruction_outline(shape_outline);
}
}
#endif // NAVIGATION_2D_DISABLED
void Polygon2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_polygon", "polygon"), &Polygon2D::set_polygon);

View File

@ -152,13 +152,17 @@ public:
void set_skeleton(const NodePath &p_skeleton);
NodePath get_skeleton() const;
#ifndef NAVIGATION_2D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
public:
#ifndef NAVIGATION_2D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
Polygon2D();
~Polygon2D();

View File

@ -46,16 +46,20 @@ TileMap::VisibilityMode TileMap::_get_collision_visibility_mode_bind_compat_8711
return get_collision_visibility_mode();
}
#ifndef NAVIGATION_2D_DISABLED
TileMap::VisibilityMode TileMap::_get_navigation_visibility_mode_bind_compat_87115() {
return get_navigation_visibility_mode();
}
#endif // NAVIGATION_2D_DISABLED
void TileMap::_bind_compatibility_methods() {
ClassDB::bind_compatibility_method(D_METHOD("get_used_rect"), &TileMap::_get_used_rect_bind_compat_78328);
ClassDB::bind_compatibility_method(D_METHOD("set_quadrant_size", "quadrant_size"), &TileMap::_set_quadrant_size_compat_81070);
ClassDB::bind_compatibility_method(D_METHOD("get_quadrant_size"), &TileMap::_get_quadrant_size_compat_81070);
ClassDB::bind_compatibility_method(D_METHOD("get_collision_visibility_mode"), &TileMap::_get_collision_visibility_mode_bind_compat_87115);
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_compatibility_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::_get_navigation_visibility_mode_bind_compat_87115);
#endif // NAVIGATION_2D_DISABLED
}
#endif

View File

@ -32,8 +32,10 @@
#include "tile_map.compat.inc"
#include "core/io/marshalls.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
#define TILEMAP_CALL_FOR_LAYER(layer, function, ...) \
if (layer < 0) { \
@ -49,8 +51,10 @@
ERR_FAIL_INDEX_V(layer, (int)layers.size(), err_value); \
return layers[layer]->function(__VA_ARGS__);
#ifndef NAVIGATION_2D_DISABLED
Callable TileMap::_navmesh_source_geometry_parsing_callback;
RID TileMap::_navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
void TileMap::_tile_set_changed() {
update_configuration_warnings();
@ -376,6 +380,7 @@ int TileMap::get_layer_z_index(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, 0, get_z_index);
}
#ifndef NAVIGATION_2D_DISABLED
void TileMap::set_layer_navigation_enabled(int p_layer, bool p_enabled) {
TILEMAP_CALL_FOR_LAYER(p_layer, set_navigation_enabled, p_enabled);
}
@ -391,6 +396,7 @@ void TileMap::set_layer_navigation_map(int p_layer, RID p_map) {
RID TileMap::get_layer_navigation_map(int p_layer) const {
TILEMAP_CALL_FOR_LAYER_V(p_layer, RID(), get_navigation_map);
}
#endif // NAVIGATION_2D_DISABLED
void TileMap::set_collision_animatable(bool p_collision_animatable) {
if (collision_animatable == p_collision_animatable) {
@ -423,6 +429,7 @@ TileMap::VisibilityMode TileMap::get_collision_visibility_mode() const {
return collision_visibility_mode;
}
#ifndef NAVIGATION_2D_DISABLED
void TileMap::set_navigation_visibility_mode(TileMap::VisibilityMode p_show_navigation) {
if (navigation_visibility_mode == p_show_navigation) {
return;
@ -437,6 +444,7 @@ void TileMap::set_navigation_visibility_mode(TileMap::VisibilityMode p_show_navi
TileMap::VisibilityMode TileMap::get_navigation_visibility_mode() const {
return navigation_visibility_mode;
}
#endif // NAVIGATION_2D_DISABLED
void TileMap::set_y_sort_enabled(bool p_enable) {
if (is_y_sort_enabled() == p_enable) {
@ -898,8 +906,10 @@ PackedStringArray TileMap::get_configuration_warnings() const {
void TileMap::_bind_methods() {
#ifndef DISABLE_DEPRECATED
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_navigation_map", "layer", "map"), &TileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map", "layer"), &TileMap::get_layer_navigation_map);
#endif // NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("force_update", "layer"), &TileMap::force_update, DEFVAL(-1));
#endif // DISABLE_DEPRECATED
@ -925,18 +935,22 @@ void TileMap::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_layer_y_sort_origin", "layer"), &TileMap::get_layer_y_sort_origin);
ClassDB::bind_method(D_METHOD("set_layer_z_index", "layer", "z_index"), &TileMap::set_layer_z_index);
ClassDB::bind_method(D_METHOD("get_layer_z_index", "layer"), &TileMap::get_layer_z_index);
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_layer_navigation_enabled", "layer", "enabled"), &TileMap::set_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("is_layer_navigation_enabled", "layer"), &TileMap::is_layer_navigation_enabled);
ClassDB::bind_method(D_METHOD("set_layer_navigation_map", "layer", "map"), &TileMap::set_layer_navigation_map);
ClassDB::bind_method(D_METHOD("get_layer_navigation_map", "layer"), &TileMap::get_layer_navigation_map);
#endif // NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_collision_animatable", "enabled"), &TileMap::set_collision_animatable);
ClassDB::bind_method(D_METHOD("is_collision_animatable"), &TileMap::is_collision_animatable);
ClassDB::bind_method(D_METHOD("set_collision_visibility_mode", "collision_visibility_mode"), &TileMap::set_collision_visibility_mode);
ClassDB::bind_method(D_METHOD("get_collision_visibility_mode"), &TileMap::get_collision_visibility_mode);
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "navigation_visibility_mode"), &TileMap::set_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMap::get_navigation_visibility_mode);
#endif // NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_cell", "layer", "coords", "source_id", "atlas_coords", "alternative_tile"), &TileMap::set_cell, DEFVAL(TileSet::INVALID_SOURCE), DEFVAL(TileSetSource::INVALID_ATLAS_COORDS), DEFVAL(0));
ClassDB::bind_method(D_METHOD("erase_cell", "layer", "coords"), &TileMap::erase_cell);
@ -986,7 +1000,9 @@ void TileMap::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "rendering_quadrant_size", PROPERTY_HINT_RANGE, "1,128,1"), "set_rendering_quadrant_size", "get_rendering_quadrant_size");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_animatable"), "set_collision_animatable", "is_collision_animatable");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_collision_visibility_mode", "get_collision_visibility_mode");
#ifndef NAVIGATION_2D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_navigation_visibility_mode", "get_navigation_visibility_mode");
#endif // NAVIGATION_2D_DISABLED
ADD_ARRAY("layers", "layer_");
@ -1021,7 +1037,9 @@ TileMap::TileMap() {
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "y_sort_enabled"), defaults->is_y_sort_enabled(), &TileMap::set_layer_y_sort_enabled, &TileMap::is_layer_y_sort_enabled);
base_property_helper.register_property(PropertyInfo(Variant::INT, "y_sort_origin", PROPERTY_HINT_NONE, "suffix:px"), defaults->get_y_sort_origin(), &TileMap::set_layer_y_sort_origin, &TileMap::get_layer_y_sort_origin);
base_property_helper.register_property(PropertyInfo(Variant::INT, "z_index"), defaults->get_z_index(), &TileMap::set_layer_z_index, &TileMap::get_layer_z_index);
#ifndef NAVIGATION_2D_DISABLED
base_property_helper.register_property(PropertyInfo(Variant::BOOL, "navigation_enabled"), defaults->is_navigation_enabled(), &TileMap::set_layer_navigation_enabled, &TileMap::is_layer_navigation_enabled);
#endif // NAVIGATION_2D_DISABLED
base_property_helper.register_property(PropertyInfo(Variant::PACKED_INT32_ARRAY, "tile_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), Vector<int>(), &TileMap::_set_layer_tile_data, &TileMap::_get_tile_map_data_using_compatibility_format);
PropertyListHelper::register_base_helper(&base_property_helper);
@ -1031,6 +1049,7 @@ TileMap::TileMap() {
property_helper.setup_for_instance(base_property_helper, this);
}
#ifndef NAVIGATION_2D_DISABLED
void TileMap::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -1058,6 +1077,7 @@ void TileMap::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navi
}
}
}
#endif // NAVIGATION_2D_DISABLED
#undef TILEMAP_CALL_FOR_LAYER
#undef TILEMAP_CALL_FOR_LAYER_V

View File

@ -35,7 +35,9 @@
#include "scene/resources/2d/tile_set.h"
class Control;
#ifndef NAVIGATION_2D_DISABLED
class NavigationMeshSourceGeometryData2D;
#endif // NAVIGATION_2D_DISABLED
class TileMapLayer;
class TerrainConstraint;
@ -58,8 +60,6 @@ public:
};
private:
friend class TileSetPlugin;
// A compatibility enum to specify how is the data if formatted.
mutable TileMapDataFormat format = TileMapDataFormat::TILE_MAP_DATA_FORMAT_3;
@ -68,7 +68,9 @@ private:
int rendering_quadrant_size = 16;
bool collision_animatable = false;
VisibilityMode collision_visibility_mode = VISIBILITY_MODE_DEFAULT;
#ifndef NAVIGATION_2D_DISABLED
VisibilityMode navigation_visibility_mode = VISIBILITY_MODE_DEFAULT;
#endif // NAVIGATION_2D_DISABLED
// Layers.
LocalVector<TileMapLayer *> layers;
@ -104,7 +106,9 @@ protected:
void _set_quadrant_size_compat_81070(int p_quadrant_size);
int _get_quadrant_size_compat_81070() const;
VisibilityMode _get_collision_visibility_mode_bind_compat_87115();
#ifndef NAVIGATION_2D_DISABLED
VisibilityMode _get_navigation_visibility_mode_bind_compat_87115();
#endif // NAVIGATION_2D_DISABLED
static void _bind_compatibility_methods();
#endif // DISABLE_DEPRECATED
@ -143,10 +147,12 @@ public:
int get_layer_y_sort_origin(int p_layer) const;
void set_layer_z_index(int p_layer, int p_z_index);
int get_layer_z_index(int p_layer) const;
#ifndef NAVIGATION_2D_DISABLED
void set_layer_navigation_enabled(int p_layer, bool p_enabled);
bool is_layer_navigation_enabled(int p_layer) const;
void set_layer_navigation_map(int p_layer, RID p_map);
RID get_layer_navigation_map(int p_layer) const;
#endif // NAVIGATION_2D_DISABLED
void set_collision_animatable(bool p_collision_animatable);
bool is_collision_animatable() const;
@ -155,8 +161,10 @@ public:
void set_collision_visibility_mode(VisibilityMode p_show_collision);
VisibilityMode get_collision_visibility_mode() const;
#ifndef NAVIGATION_2D_DISABLED
void set_navigation_visibility_mode(VisibilityMode p_show_navigation);
VisibilityMode get_navigation_visibility_mode() const;
#endif // NAVIGATION_2D_DISABLED
// Cells accessors.
void set_cell(int p_layer, const Vector2i &p_coords, int p_source_id = TileSet::INVALID_SOURCE, const Vector2i p_atlas_coords = TileSetSource::INVALID_ATLAS_COORDS, int p_alternative_tile = 0);
@ -240,13 +248,17 @@ public:
// Configuration warnings.
PackedStringArray get_configuration_warnings() const override;
#ifndef NAVIGATION_2D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
public:
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
TileMap();
};

View File

@ -37,14 +37,16 @@
#include "scene/gui/control.h"
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/world_2d.h"
#include "servers/navigation_server_2d.h"
#ifndef PHYSICS_2D_DISABLED
#include "servers/physics_server_2d.h"
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
Callable TileMapLayer::_navmesh_source_geometry_parsing_callback;
RID TileMapLayer::_navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
Vector2i TileMapLayer::_coords_to_quadrant_coords(const Vector2i &p_coords, const int p_quadrant_size) const {
return Vector2i(
@ -149,7 +151,9 @@ void TileMapLayer::_debug_update(bool p_force_cleanup) {
CellData &cell_data = *cell_data_list_element->self();
if (cell_data.cell.source_id != TileSet::INVALID_SOURCE) {
_rendering_draw_cell_debug(ci, quadrant_pos, cell_data);
#ifndef NAVIGATION_2D_DISABLED
_navigation_draw_cell_debug(ci, quadrant_pos, cell_data);
#endif // NAVIGATION_2D_DISABLED
_scenes_draw_cell_debug(ci, quadrant_pos, cell_data);
debug_quadrant->drawn_to = true;
}
@ -1138,6 +1142,7 @@ void TileMapLayer::_physics_draw_quadrant_debug(const RID &p_canvas_item, DebugQ
#endif // DEBUG_ENABLED
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
/////////////////////////////// Navigation //////////////////////////////////////
void TileMapLayer::_navigation_update(bool p_force_cleanup) {
@ -1410,6 +1415,7 @@ void TileMapLayer::_navigation_draw_cell_debug(const RID &p_canvas_item, const V
}
}
#endif // DEBUG_ENABLED
#endif // NAVIGATION_2D_DISABLED
/////////////////////////////// Scenes //////////////////////////////////////
@ -1885,7 +1891,9 @@ void TileMapLayer::_internal_update(bool p_force_cleanup) {
#ifndef PHYSICS_2D_DISABLED
_physics_update(p_force_cleanup);
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
_navigation_update(p_force_cleanup);
#endif // NAVIGATION_2D_DISABLED
_scenes_update(p_force_cleanup);
#ifdef DEBUG_ENABLED
_debug_update(p_force_cleanup);
@ -1989,7 +1997,9 @@ void TileMapLayer::_notification(int p_what) {
#ifndef PHYSICS_2D_DISABLED
_physics_notification(p_what);
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
_navigation_notification(p_what);
#endif // NAVIGATION_2D_DISABLED
}
void TileMapLayer::_bind_methods() {
@ -2067,12 +2077,14 @@ void TileMapLayer::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_occlusion_enabled", "enabled"), &TileMapLayer::set_occlusion_enabled);
ClassDB::bind_method(D_METHOD("is_occlusion_enabled"), &TileMapLayer::is_occlusion_enabled);
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("set_navigation_enabled", "enabled"), &TileMapLayer::set_navigation_enabled);
ClassDB::bind_method(D_METHOD("is_navigation_enabled"), &TileMapLayer::is_navigation_enabled);
ClassDB::bind_method(D_METHOD("set_navigation_map", "map"), &TileMapLayer::set_navigation_map);
ClassDB::bind_method(D_METHOD("get_navigation_map"), &TileMapLayer::get_navigation_map);
ClassDB::bind_method(D_METHOD("set_navigation_visibility_mode", "show_navigation"), &TileMapLayer::set_navigation_visibility_mode);
ClassDB::bind_method(D_METHOD("get_navigation_visibility_mode"), &TileMapLayer::get_navigation_visibility_mode);
#endif // NAVIGATION_2D_DISABLED
GDVIRTUAL_BIND(_use_tile_data_runtime_update, "coords");
GDVIRTUAL_BIND(_tile_data_runtime_update, "coords", "tile_data");
@ -2092,9 +2104,11 @@ void TileMapLayer::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_kinematic_bodies"), "set_use_kinematic_bodies", "is_using_kinematic_bodies");
ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_collision_visibility_mode", "get_collision_visibility_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "physics_quadrant_size"), "set_physics_quadrant_size", "get_physics_quadrant_size");
#ifndef NAVIGATION_2D_DISABLED
ADD_GROUP("Navigation", "");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "navigation_enabled"), "set_navigation_enabled", "is_navigation_enabled");
ADD_PROPERTY(PropertyInfo(Variant::INT, "navigation_visibility_mode", PROPERTY_HINT_ENUM, "Default,Force Show,Force Hide"), "set_navigation_visibility_mode", "get_navigation_visibility_mode");
#endif // NAVIGATION_2D_DISABLED
ADD_SIGNAL(MethodInfo(CoreStringName(changed)));
@ -3233,6 +3247,7 @@ bool TileMapLayer::is_occlusion_enabled() const {
return occlusion_enabled;
}
#ifndef NAVIGATION_2D_DISABLED
void TileMapLayer::set_navigation_enabled(bool p_enabled) {
if (navigation_enabled == p_enabled) {
return;
@ -3395,6 +3410,7 @@ void TileMapLayer::navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p
#endif // PHYSICS_2D_DISABLED
}
}
#endif // NAVIGATION_2D_DISABLED
TileMapLayer::TileMapLayer() {
set_notify_transform(true);

View File

@ -32,7 +32,9 @@
#include "scene/resources/2d/tile_set.h"
#ifndef NAVIGATION_2D_DISABLED
class NavigationMeshSourceGeometryData2D;
#endif // NAVIGATION_2D_DISABLED
class TileSetAtlasSource;
class TileMap;
@ -454,6 +456,7 @@ private:
#endif // DEBUG_ENABLED
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
bool _navigation_was_cleaned_up = false;
void _navigation_update(bool p_force_cleanup);
void _navigation_notification(int p_what);
@ -462,6 +465,7 @@ private:
#ifdef DEBUG_ENABLED
void _navigation_draw_cell_debug(const RID &p_canvas_item, const Vector2 &p_quadrant_pos, const CellData &r_cell_data);
#endif // DEBUG_ENABLED
#endif // NAVIGATION_2D_DISABLED
bool _scenes_was_cleaned_up = false;
void _scenes_update(bool p_force_cleanup);
@ -618,12 +622,16 @@ public:
DebugVisibilityMode get_navigation_visibility_mode() const;
private:
#ifndef NAVIGATION_2D_DISABLED
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_2D_DISABLED
public:
#ifndef NAVIGATION_2D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationPolygon> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData2D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_2D_DISABLED
TileMapLayer();
~TileMapLayer();

View File

@ -8,5 +8,7 @@ env.add_source_files(env.scene_sources, "*.cpp")
# Chain load SCsubs
if not env["disable_physics_3d"]:
SConscript("physics/SCsub")
if not env["disable_navigation_3d"]:
SConscript("navigation/SCsub")
if not env["disable_xr"]:
SConscript("xr/SCsub")

View File

@ -31,9 +31,6 @@
#include "mesh_instance_3d.h"
#include "scene/3d/skeleton_3d.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/navigation_server_3d.h"
#ifndef PHYSICS_3D_DISABLED
#include "scene/3d/physics/collision_shape_3d.h"
@ -42,8 +39,14 @@
#include "scene/resources/3d/convex_polygon_shape_3d.h"
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/navigation_server_3d.h"
Callable MeshInstance3D::_navmesh_source_geometry_parsing_callback;
RID MeshInstance3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
bool MeshInstance3D::_set(const StringName &p_name, const Variant &p_value) {
//this is not _too_ bad performance wise, really. it only arrives here if the property was not set anywhere else.
@ -853,6 +856,7 @@ Ref<TriangleMesh> MeshInstance3D::generate_triangle_mesh() const {
return Ref<TriangleMesh>();
}
#ifndef NAVIGATION_3D_DISABLED
void MeshInstance3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -878,6 +882,7 @@ void MeshInstance3D::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_
}
}
}
#endif // NAVIGATION_3D_DISABLED
void MeshInstance3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_mesh", "mesh"), &MeshInstance3D::set_mesh);

View File

@ -33,8 +33,10 @@
#include "core/templates/local_vector.h"
#include "scene/3d/visual_instance_3d.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class Skin;
class SkinReference;
@ -110,13 +112,17 @@ public:
virtual Ref<TriangleMesh> generate_triangle_mesh() const override;
#ifndef NAVIGATION_3D_DISABLED
private:
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
public:
#ifndef NAVIGATION_3D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
MeshInstance3D();
~MeshInstance3D();

View File

@ -30,12 +30,14 @@
#include "multimesh_instance_3d.h"
#ifndef NAVIGATION_3D_DISABLED
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#include "scene/resources/navigation_mesh.h"
#include "servers/navigation_server_3d.h"
Callable MultiMeshInstance3D::_navmesh_source_geometry_parsing_callback;
RID MultiMeshInstance3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
void MultiMeshInstance3D::_refresh_interpolated() {
if (is_inside_tree() && multimesh.is_valid()) {
@ -103,6 +105,7 @@ AABB MultiMeshInstance3D::get_aabb() const {
}
}
#ifndef NAVIGATION_3D_DISABLED
void MultiMeshInstance3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -137,6 +140,7 @@ void MultiMeshInstance3D::navmesh_parse_source_geometry(const Ref<NavigationMesh
}
}
}
#endif // NAVIGATION_3D_DISABLED
MultiMeshInstance3D::MultiMeshInstance3D() {
}

View File

@ -33,8 +33,10 @@
#include "scene/3d/visual_instance_3d.h"
#include "scene/resources/multimesh.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class MultiMeshInstance3D : public GeometryInstance3D {
GDCLASS(MultiMeshInstance3D, GeometryInstance3D);
@ -57,12 +59,16 @@ public:
virtual AABB get_aabb() const override;
private:
#ifndef NAVIGATION_3D_DISABLED
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
public:
#ifndef NAVIGATION_3D_DISABLED
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
MultiMeshInstance3D();
~MultiMeshInstance3D();

View File

@ -0,0 +1,6 @@
#!/usr/bin/env python
from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.scene_sources, "*.cpp")

View File

@ -30,7 +30,7 @@
#include "navigation_agent_3d.h"
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation/navigation_link_3d.h"
#include "servers/navigation_server_3d.h"
void NavigationAgent3D::_bind_methods() {

View File

@ -30,6 +30,7 @@
#include "static_body_3d.h"
#ifndef NAVIGATION_3D_DISABLED
#include "core/math/convex_hull.h"
#include "scene/resources/3d/box_shape_3d.h"
#include "scene/resources/3d/capsule_shape_3d.h"
@ -47,6 +48,7 @@
Callable StaticBody3D::_navmesh_source_geometry_parsing_callback;
RID StaticBody3D::_navmesh_source_geometry_parser;
#endif // NAVIGATION_3D_DISABLED
void StaticBody3D::set_physics_material_override(const Ref<PhysicsMaterial> &p_physics_material_override) {
if (physics_material_override.is_valid()) {
@ -95,6 +97,7 @@ void StaticBody3D::_reload_physics_characteristics() {
}
}
#ifndef NAVIGATION_3D_DISABLED
void StaticBody3D::navmesh_parse_init() {
ERR_FAIL_NULL(NavigationServer3D::get_singleton());
if (!_navmesh_source_geometry_parser.is_valid()) {
@ -226,6 +229,7 @@ void StaticBody3D::navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_na
}
}
}
#endif // NAVIGATION_3D_DISABLED
void StaticBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_constant_linear_velocity", "vel"), &StaticBody3D::set_constant_linear_velocity);

View File

@ -32,8 +32,10 @@
#include "scene/3d/physics/physics_body_3d.h"
#ifndef NAVIGATION_3D_DISABLED
class NavigationMesh;
class NavigationMeshSourceGeometryData3D;
#endif // NAVIGATION_3D_DISABLED
class StaticBody3D : public PhysicsBody3D {
GDCLASS(StaticBody3D, PhysicsBody3D);
@ -62,10 +64,12 @@ public:
private:
void _reload_physics_characteristics();
#ifndef NAVIGATION_3D_DISABLED
static Callable _navmesh_source_geometry_parsing_callback;
static RID _navmesh_source_geometry_parser;
public:
static void navmesh_parse_init();
static void navmesh_parse_source_geometry(const Ref<NavigationMesh> &p_navigation_mesh, Ref<NavigationMeshSourceGeometryData3D> p_source_geometry_data, Node *p_node);
#endif // NAVIGATION_3D_DISABLED
};

View File

@ -131,7 +131,9 @@
#include "scene/resources/mesh_data_tool.h"
#include "scene/resources/mesh_texture.h"
#include "scene/resources/multimesh.h"
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
#include "scene/resources/navigation_mesh.h"
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
#include "scene/resources/packed_scene.h"
#include "scene/resources/particle_process_material.h"
#include "scene/resources/placeholder_textures.h"
@ -174,10 +176,6 @@
#include "scene/2d/marker_2d.h"
#include "scene/2d/mesh_instance_2d.h"
#include "scene/2d/multimesh_instance_2d.h"
#include "scene/2d/navigation_agent_2d.h"
#include "scene/2d/navigation_link_2d.h"
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/parallax_2d.h"
#include "scene/2d/parallax_background.h"
#include "scene/2d/parallax_layer.h"
@ -189,8 +187,6 @@
#include "scene/2d/tile_map.h"
#include "scene/2d/tile_map_layer.h"
#include "scene/2d/visible_on_screen_notifier_2d.h"
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/2d/navigation_polygon.h"
#include "scene/resources/2d/polygon_path_finder.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h"
#include "scene/resources/2d/skeleton/skeleton_modification_2d_ccdik.h"
@ -202,6 +198,15 @@
#include "scene/resources/2d/tile_set.h"
#include "scene/resources/world_2d.h"
#ifndef NAVIGATION_2D_DISABLED
#include "scene/2d/navigation/navigation_agent_2d.h"
#include "scene/2d/navigation/navigation_link_2d.h"
#include "scene/2d/navigation/navigation_obstacle_2d.h"
#include "scene/2d/navigation/navigation_region_2d.h"
#include "scene/resources/2d/navigation_mesh_source_geometry_data_2d.h"
#include "scene/resources/2d/navigation_polygon.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef _3D_DISABLED
#include "scene/3d/audio_listener_3d.h"
#include "scene/3d/audio_stream_player_3d.h"
@ -221,10 +226,6 @@
#include "scene/3d/marker_3d.h"
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/multimesh_instance_3d.h"
#include "scene/3d/navigation_agent_3d.h"
#include "scene/3d/navigation_link_3d.h"
#include "scene/3d/navigation_obstacle_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/3d/occluder_instance_3d.h"
#include "scene/3d/path_3d.h"
@ -238,12 +239,6 @@
#include "scene/3d/visible_on_screen_notifier_3d.h"
#include "scene/3d/voxel_gi.h"
#include "scene/3d/world_environment.h"
#ifndef XR_DISABLED
#include "scene/3d/xr/xr_body_modifier_3d.h"
#include "scene/3d/xr/xr_face_modifier_3d.h"
#include "scene/3d/xr/xr_hand_modifier_3d.h"
#include "scene/3d/xr/xr_nodes.h"
#endif // XR_DISABLED
#include "scene/animation/root_motion_view.h"
#include "scene/resources/3d/fog_material.h"
#include "scene/resources/3d/importer_mesh.h"
@ -252,6 +247,19 @@
#include "scene/resources/3d/primitive_meshes.h"
#include "scene/resources/3d/sky_material.h"
#include "scene/resources/3d/world_3d.h"
#ifndef NAVIGATION_3D_DISABLED
#include "scene/3d/navigation/navigation_agent_3d.h"
#include "scene/3d/navigation/navigation_link_3d.h"
#include "scene/3d/navigation/navigation_obstacle_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/resources/3d/navigation_mesh_source_geometry_data_3d.h"
#endif // NAVIGATION_3D_DISABLED
#ifndef XR_DISABLED
#include "scene/3d/xr/xr_body_modifier_3d.h"
#include "scene/3d/xr/xr_face_modifier_3d.h"
#include "scene/3d/xr/xr_hand_modifier_3d.h"
#include "scene/3d/xr/xr_nodes.h"
#endif // XR_DISABLED
#endif // _3D_DISABLED
#if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED)
@ -684,10 +692,13 @@ void register_scene_types() {
GDREGISTER_CLASS(Generic6DOFJoint3D);
#endif // PHYSICS_3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
GDREGISTER_CLASS(NavigationMeshSourceGeometryData3D);
GDREGISTER_CLASS(NavigationRegion3D);
GDREGISTER_CLASS(NavigationAgent3D);
GDREGISTER_CLASS(NavigationObstacle3D);
GDREGISTER_CLASS(NavigationLink3D);
#endif // NAVIGATION_3D_DISABLED
OS::get_singleton()->yield(); // may take time to init
#endif // _3D_DISABLED
@ -942,7 +953,6 @@ void register_scene_types() {
BaseMaterial3D::init_shaders();
GDREGISTER_CLASS(MeshLibrary);
GDREGISTER_CLASS(NavigationMeshSourceGeometryData3D);
OS::get_singleton()->yield(); // may take time to init
@ -1054,6 +1064,10 @@ void register_scene_types() {
OS::get_singleton()->yield(); // may take time to init
GDREGISTER_CLASS(AudioStreamPlayer2D);
GDREGISTER_CLASS(Curve2D);
GDREGISTER_CLASS(Path2D);
GDREGISTER_CLASS(PathFollow2D);
#ifndef PHYSICS_2D_DISABLED
GDREGISTER_ABSTRACT_CLASS(Shape2D);
GDREGISTER_CLASS(WorldBoundaryShape2D);
@ -1065,18 +1079,19 @@ void register_scene_types() {
GDREGISTER_CLASS(ConvexPolygonShape2D);
GDREGISTER_CLASS(ConcavePolygonShape2D);
#endif // PHYSICS_2D_DISABLED
GDREGISTER_CLASS(Curve2D);
GDREGISTER_CLASS(Path2D);
GDREGISTER_CLASS(PathFollow2D);
GDREGISTER_CLASS(PolygonPathFinder);
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
GDREGISTER_CLASS(NavigationMesh);
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
#ifndef NAVIGATION_2D_DISABLED
GDREGISTER_CLASS(NavigationMeshSourceGeometryData2D);
GDREGISTER_CLASS(NavigationPolygon);
GDREGISTER_CLASS(NavigationRegion2D);
GDREGISTER_CLASS(NavigationAgent2D);
GDREGISTER_CLASS(NavigationObstacle2D);
GDREGISTER_CLASS(NavigationLink2D);
GDREGISTER_CLASS(PolygonPathFinder);
OS::get_singleton()->yield(); // may take time to init
@ -1090,7 +1105,9 @@ void register_scene_types() {
#ifndef PHYSICS_2D_DISABLED
StaticBody2D::navmesh_parse_init();
#endif // PHYSICS_2D_DISABLED
#ifndef _3D_DISABLED
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
// 3D nodes that support navmesh baking need to server register their source geometry parsers.
MeshInstance3D::navmesh_parse_init();
MultiMeshInstance3D::navmesh_parse_init();
@ -1098,9 +1115,11 @@ void register_scene_types() {
#ifndef PHYSICS_3D_DISABLED
StaticBody3D::navmesh_parse_init();
#endif // PHYSICS_3D_DISABLED
#endif // _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#if !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
OS::get_singleton()->yield(); // may take time to init
#endif // !defined(NAVIGATION_2D_DISABLED) || !defined(NAVIGATION_3D_DISABLED)
GDREGISTER_ABSTRACT_CLASS(SceneState);
GDREGISTER_CLASS(PackedScene);
@ -1116,8 +1135,10 @@ void register_scene_types() {
ClassDB::add_compatibility_class("BitmapFont", "FontFile");
ClassDB::add_compatibility_class("DynamicFont", "FontFile");
ClassDB::add_compatibility_class("DynamicFontData", "FontFile");
#ifndef NAVIGATION_3D_DISABLED
ClassDB::add_compatibility_class("Navigation3D", "Node3D");
ClassDB::add_compatibility_class("Navigation2D", "Node2D");
#endif // NAVIGATION_3D_DISABLED
ClassDB::add_compatibility_class("OpenSimplexNoise", "FastNoiseLite");
ClassDB::add_compatibility_class("ProximityGroup", "Node3D");
ClassDB::add_compatibility_class("ToolButton", "Button");
@ -1164,13 +1185,17 @@ void register_scene_types() {
ClassDB::add_compatibility_class("Listener", "AudioListener3D");
ClassDB::add_compatibility_class("MeshInstance", "MeshInstance3D");
ClassDB::add_compatibility_class("MultiMeshInstance", "MultiMeshInstance3D");
#ifndef NAVIGATION_3D_DISABLED
ClassDB::add_compatibility_class("NavigationAgent", "NavigationAgent3D");
ClassDB::add_compatibility_class("NavigationMeshInstance", "NavigationRegion3D");
ClassDB::add_compatibility_class("NavigationObstacle", "NavigationObstacle3D");
ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
ClassDB::add_compatibility_class("NavigationRegion", "NavigationRegion3D");
ClassDB::add_compatibility_class("Navigation2DServer", "NavigationServer2D");
ClassDB::add_compatibility_class("NavigationServer", "NavigationServer3D");
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
ClassDB::add_compatibility_class("NavigationPolygonInstance", "NavigationRegion2D");
ClassDB::add_compatibility_class("Navigation2DServer", "NavigationServer2D");
#endif // NAVIGATION_2D_DISABLED
ClassDB::add_compatibility_class("OmniLight", "OmniLight3D");
ClassDB::add_compatibility_class("PanoramaSky", "Sky");
ClassDB::add_compatibility_class("Particles", "GPUParticles3D");
@ -1306,9 +1331,13 @@ void register_scene_types() {
for (int i = 0; i < 32; i++) {
GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/2d_physics"), i + 1), "");
#ifndef NAVIGATION_2D_DISABLED
GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/2d_navigation"), i + 1), "");
#endif // NAVIGATION_2D_DISABLED
GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/3d_physics"), i + 1), "");
#ifndef NAVIGATION_3D_DISABLED
GLOBAL_DEF_BASIC(vformat("%s/layer_%d", PNAME("layer_names/3d_navigation"), i + 1), "");
#endif // NAVIGATION_3D_DISABLED
}
for (int i = 0; i < 32; i++) {

View File

@ -3,9 +3,6 @@ from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.scene_sources, "navigation_mesh_source_geometry_data_2d.cpp")
env.add_source_files(env.scene_sources, "navigation_polygon.cpp")
env.add_source_files(env.scene_sources, "polygon_path_finder.cpp")
env.add_source_files(env.scene_sources, "tile_set.cpp")
if not env["disable_physics_2d"]:
@ -18,5 +15,9 @@ if not env["disable_physics_2d"]:
env.add_source_files(env.scene_sources, "separation_ray_shape_2d.cpp")
env.add_source_files(env.scene_sources, "shape_2d.cpp")
env.add_source_files(env.scene_sources, "world_boundary_shape_2d.cpp")
if not env["disable_navigation_2d"]:
env.add_source_files(env.scene_sources, "navigation_mesh_source_geometry_data_2d.cpp")
env.add_source_files(env.scene_sources, "navigation_polygon.cpp")
env.add_source_files(env.scene_sources, "polygon_path_finder.cpp")
SConscript("skeleton/SCsub")

View File

@ -32,16 +32,20 @@
#include "tile_set.h"
#ifndef NAVIGATION_2D_DISABLED
Ref<NavigationPolygon> TileData::_get_navigation_polygon_bind_compat_84660(int p_layer_id) const {
return get_navigation_polygon(p_layer_id, false, false, false);
}
#endif // NAVIGATION_2D_DISABLED
Ref<OccluderPolygon2D> TileData::_get_occluder_bind_compat_84660(int p_layer_id) const {
return get_occluder_polygon(p_layer_id, 0, false, false, false);
}
void TileData::_bind_compatibility_methods() {
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_compatibility_method(D_METHOD("get_navigation_polygon"), &TileData::_get_navigation_polygon_bind_compat_84660);
#endif // NAVIGATION_2D_DISABLED
ClassDB::bind_compatibility_method(D_METHOD("get_occluder"), &TileData::_get_occluder_bind_compat_84660);
}

View File

@ -37,7 +37,10 @@
#include "core/templates/rb_set.h"
#include "scene/gui/control.h"
#include "scene/resources/image_texture.h"
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
/////////////////////////////// TileMapPattern //////////////////////////////////////
@ -965,6 +968,7 @@ bool TileSet::is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeigh
return is_valid_terrain_peering_bit_for_mode(terrain_mode, p_peering_bit);
}
#ifndef NAVIGATION_2D_DISABLED
// Navigation
int TileSet::get_navigation_layers_count() const {
return navigation_layers.size();
@ -1039,6 +1043,7 @@ bool TileSet::get_navigation_layer_layer_value(int p_layer_index, int p_layer_nu
return get_navigation_layer_layers(p_layer_index) & (1 << (p_layer_number - 1));
}
#endif // NAVIGATION_2D_DISABLED
// Custom data.
int TileSet::get_custom_data_layers_count() const {
@ -3413,6 +3418,7 @@ void TileSet::_compatibility_conversion() {
tile_data->add_occluder_polygon(0);
tile_data->set_occluder_polygon(0, 0, occluder);
}
#ifndef NAVIGATION_2D_DISABLED
if (ctd->navigation.is_valid()) {
if (get_navigation_layers_count() < 1) {
add_navigation_layer();
@ -3425,6 +3431,7 @@ void TileSet::_compatibility_conversion() {
navigation->set_vertices(vertices);
tile_data->set_navigation_polygon(0, navigation);
}
#endif // NAVIGATION_2D_DISABLED
tile_data->set_z_index(ctd->z_index);
@ -3522,6 +3529,7 @@ void TileSet::_compatibility_conversion() {
tile_data->add_occluder_polygon(0);
tile_data->set_occluder_polygon(0, 0, occluder);
}
#ifndef NAVIGATION_2D_DISABLED
if (ctd->autotile_navpoly_map.has(coords)) {
if (get_navigation_layers_count() < 1) {
add_navigation_layer();
@ -3534,6 +3542,7 @@ void TileSet::_compatibility_conversion() {
navigation->set_vertices(vertices);
tile_data->set_navigation_polygon(0, navigation);
}
#endif // NAVIGATION_2D_DISABLED
if (ctd->autotile_priority_map.has(coords)) {
tile_data->set_probability(ctd->autotile_priority_map[coords]);
}
@ -3732,7 +3741,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
if (p[0].get_type() == Variant::VECTOR2) {
last_coord = p[0];
} else if (p[0].get_type() == Variant::OBJECT) {
#ifndef NAVIGATION_2D_DISABLED
ctd->autotile_navpoly_map.insert(last_coord, p[0]);
#endif // NAVIGATION_2D_DISABLED
}
p.pop_front();
}
@ -3794,7 +3805,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
} else if (what == "occluder") {
ctd->occluder = p_value;
} else if (what == "navigation") {
#ifndef NAVIGATION_2D_DISABLED
ctd->navigation = p_value;
#endif // NAVIGATION_2D_DISABLED
/*
// IGNORED FOR NOW, they seem duplicated data compared to the shapes array
@ -3913,6 +3926,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
}
}
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
#ifndef NAVIGATION_2D_DISABLED
// Navigation layers.
int index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(index < 0, false);
@ -3924,6 +3938,7 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
set_navigation_layer_layers(index, p_value);
return true;
}
#endif // NAVIGATION_2D_DISABLED
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
// Custom data layers.
int index = components[0].trim_prefix("custom_data_layer_").to_int();
@ -4057,10 +4072,12 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
if (index < 0 || index >= navigation_layers.size()) {
return false;
}
#ifndef NAVIGATION_2D_DISABLED
if (components[1] == "layers") {
r_ret = get_navigation_layer_layers(index);
return true;
}
#endif // NAVIGATION_2D_DISABLED
} else if (components.size() == 2 && components[0].begins_with("custom_data_layer_") && components[0].trim_prefix("custom_data_layer_").is_valid_int()) {
// Custom data layers.
int index = components[0].trim_prefix("custom_data_layer_").to_int();
@ -4294,6 +4311,7 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_terrain_color", "terrain_set", "terrain_index", "color"), &TileSet::set_terrain_color);
ClassDB::bind_method(D_METHOD("get_terrain_color", "terrain_set", "terrain_index"), &TileSet::get_terrain_color);
#ifndef NAVIGATION_2D_DISABLED
// Navigation
ClassDB::bind_method(D_METHOD("get_navigation_layers_count"), &TileSet::get_navigation_layers_count);
ClassDB::bind_method(D_METHOD("add_navigation_layer", "to_position"), &TileSet::add_navigation_layer, DEFVAL(-1));
@ -4303,6 +4321,7 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_navigation_layer_layers", "layer_index"), &TileSet::get_navigation_layer_layers);
ClassDB::bind_method(D_METHOD("set_navigation_layer_layer_value", "layer_index", "layer_number", "value"), &TileSet::set_navigation_layer_layer_value);
ClassDB::bind_method(D_METHOD("get_navigation_layer_layer_value", "layer_index", "layer_number"), &TileSet::get_navigation_layer_layer_value);
#endif // NAVIGATION_2D_DISABLED
// Custom data
ClassDB::bind_method(D_METHOD("get_custom_data_layers_count"), &TileSet::get_custom_data_layers_count);
@ -4350,7 +4369,9 @@ void TileSet::_bind_methods() {
ADD_GROUP("", "");
ADD_ARRAY("physics_layers", "physics_layer_");
ADD_ARRAY("terrain_sets", "terrain_set_");
#ifndef NAVIGATION_2D_DISABLED
ADD_ARRAY("navigation_layers", "navigation_layer_");
#endif // NAVIGATION_2D_DISABLED
ADD_ARRAY("custom_data_layers", "custom_data_layer_");
// -- Enum binding --
@ -4558,6 +4579,7 @@ void TileSetAtlasSource::remove_terrain(int p_terrain_set, int p_index) {
}
}
#ifndef NAVIGATION_2D_DISABLED
void TileSetAtlasSource::add_navigation_layer(int p_to_pos) {
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
for (KeyValue<int, TileData *> E_alternative : E_tile.value.alternatives) {
@ -4581,6 +4603,7 @@ void TileSetAtlasSource::remove_navigation_layer(int p_index) {
}
}
}
#endif // NAVIGATION_2D_DISABLED
void TileSetAtlasSource::add_custom_data_layer(int p_to_pos) {
for (KeyValue<Vector2i, TileAlternativesData> E_tile : tiles) {
@ -5932,7 +5955,9 @@ void TileData::notify_tile_data_properties_should_change() {
terrain_peering_bits[bit_index] = -1;
}
}
#ifndef NAVIGATION_2D_DISABLED
navigation.resize(tile_set->get_navigation_layers_count());
#endif // NAVIGATION_2D_DISABLED
// Convert custom data to the new type.
custom_data.resize(tile_set->get_custom_data_layers_count());
@ -6071,6 +6096,7 @@ void TileData::remove_terrain(int p_terrain_set, int p_index) {
}
}
#ifndef NAVIGATION_2D_DISABLED
void TileData::add_navigation_layer(int p_to_pos) {
if (p_to_pos < 0) {
p_to_pos = navigation.size();
@ -6090,6 +6116,7 @@ void TileData::remove_navigation_layer(int p_index) {
ERR_FAIL_INDEX(p_index, navigation.size());
navigation.remove_at(p_index);
}
#endif // NAVIGATION_2D_DISABLED
void TileData::add_custom_data_layer(int p_to_pos) {
if (p_to_pos < 0) {
@ -6142,8 +6169,10 @@ TileData *TileData::duplicate() {
// Terrain
output->terrain_set = -1;
memcpy(output->terrain_peering_bits, terrain_peering_bits, 16 * sizeof(int));
#ifndef NAVIGATION_2D_DISABLED
// Navigation
output->navigation = navigation;
#endif // NAVIGATION_2D_DISABLED
// Misc
output->probability = probability;
// Custom data
@ -6531,6 +6560,7 @@ TileSet::TerrainsPattern TileData::get_terrains_pattern() const {
return output;
}
#ifndef NAVIGATION_2D_DISABLED
// Navigation
void TileData::set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon) {
ERR_FAIL_INDEX(p_layer_id, navigation.size());
@ -6578,6 +6608,7 @@ Ref<NavigationPolygon> TileData::get_navigation_polygon(int p_layer_id, bool p_f
return I->value;
}
}
#endif // NAVIGATION_2D_DISABLED
// Misc
void TileData::set_probability(float p_probability) {
@ -6706,9 +6737,9 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
}
} else
}
#ifndef PHYSICS_2D_DISABLED
if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@ -6763,51 +6794,54 @@ bool TileData::_set(const StringName &p_name, const Variant &p_value) {
return true;
}
}
} else
}
#endif // PHYSICS_2D_DISABLED
if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Navigation layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (components[1] == "polygon") {
Ref<NavigationPolygon> polygon = p_value;
#ifndef NAVIGATION_2D_DISABLED
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Navigation layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (components[1] == "polygon") {
Ref<NavigationPolygon> polygon = p_value;
if (layer_index >= navigation.size()) {
if (tile_set) {
return false;
} else {
navigation.resize(layer_index + 1);
}
}
set_navigation_polygon(layer_index, polygon);
return true;
}
} else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
set_terrain_peering_bit(bit, p_value);
return true;
}
}
return false;
} else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
// Custom data layers.
int layer_index = components[0].trim_prefix("custom_data_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= custom_data.size()) {
if (layer_index >= navigation.size()) {
if (tile_set) {
return false;
} else {
custom_data.resize(layer_index + 1);
navigation.resize(layer_index + 1);
}
}
set_custom_data_by_layer_id(layer_index, p_value);
set_navigation_polygon(layer_index, polygon);
return true;
}
}
#endif // NAVIGATION_2D_DISABLED
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
TileSet::CellNeighbor bit = TileSet::CellNeighbor(i);
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
set_terrain_peering_bit(bit, p_value);
return true;
}
}
return false;
} else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
// Custom data layers.
int layer_index = components[0].trim_prefix("custom_data_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= custom_data.size()) {
if (tile_set) {
return false;
} else {
custom_data.resize(layer_index + 1);
}
}
set_custom_data_by_layer_id(layer_index, p_value);
return true;
}
return false;
}
@ -6854,9 +6888,9 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
}
} else
}
#ifndef PHYSICS_2D_DISABLED
if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
else if (components.size() >= 2 && components[0].begins_with("physics_layer_") && components[0].trim_prefix("physics_layer_").is_valid_int()) {
// Physics layers.
int layer_index = components[0].trim_prefix("physics_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
@ -6892,38 +6926,32 @@ bool TileData::_get(const StringName &p_name, Variant &r_ret) const {
return true;
}
}
} else
}
#endif // PHYSICS_2D_DISABLED
if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
r_ret = terrain_peering_bits[i];
return true;
}
}
return false;
} else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Occlusion layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= navigation.size()) {
return false;
}
if (components[1] == "polygon") {
r_ret = get_navigation_polygon(layer_index);
else if (components.size() == 2 && components[0] == "terrains_peering_bit") {
// Terrains.
for (int i = 0; i < TileSet::CELL_NEIGHBOR_MAX; i++) {
if (components[1] == TileSet::CELL_NEIGHBOR_ENUM_TO_TEXT[i]) {
r_ret = terrain_peering_bits[i];
return true;
}
} else if (components.size() == 1 && components[0].begins_with("custom_data_") && components[0].trim_prefix("custom_data_").is_valid_int()) {
// Custom data layers.
int layer_index = components[0].trim_prefix("custom_data_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= custom_data.size()) {
return false;
}
r_ret = get_custom_data_by_layer_id(layer_index);
}
return false;
}
#ifndef NAVIGATION_2D_DISABLED
else if (components.size() == 2 && components[0].begins_with("navigation_layer_") && components[0].trim_prefix("navigation_layer_").is_valid_int()) {
// Occlusion layers.
int layer_index = components[0].trim_prefix("navigation_layer_").to_int();
ERR_FAIL_COND_V(layer_index < 0, false);
if (layer_index >= navigation.size()) {
return false;
}
if (components[1] == "polygon") {
r_ret = get_navigation_polygon(layer_index);
return true;
}
}
#endif // NAVIGATION_2D_DISABLED
}
return false;
@ -7007,6 +7035,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
}
}
#ifndef NAVIGATION_2D_DISABLED
// Navigation layers.
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Navigation", ""), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_GROUP));
for (int i = 0; i < navigation.size(); i++) {
@ -7016,6 +7045,7 @@ void TileData::_get_property_list(List<PropertyInfo> *p_list) const {
}
p_list->push_back(property_info);
}
#endif // NAVIGATION_2D_DISABLED
// Custom data layers.
p_list->push_back(PropertyInfo(Variant::NIL, GNAME("Custom Data", "custom_data_"), PROPERTY_HINT_NONE, "custom_data_", PROPERTY_USAGE_GROUP));
@ -7090,9 +7120,11 @@ void TileData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_terrain_peering_bit", "peering_bit"), &TileData::get_terrain_peering_bit);
ClassDB::bind_method(D_METHOD("is_valid_terrain_peering_bit", "peering_bit"), &TileData::is_valid_terrain_peering_bit);
#ifndef NAVIGATION_2D_DISABLED
// Navigation
ClassDB::bind_method(D_METHOD("set_navigation_polygon", "layer_id", "navigation_polygon"), &TileData::set_navigation_polygon);
ClassDB::bind_method(D_METHOD("get_navigation_polygon", "layer_id", "flip_h", "flip_v", "transpose"), &TileData::get_navigation_polygon, DEFVAL(false), DEFVAL(false), DEFVAL(false));
#endif // NAVIGATION_2D_DISABLED
// Misc.
ClassDB::bind_method(D_METHOD("set_probability", "probability"), &TileData::set_probability);

View File

@ -36,14 +36,18 @@
#include "core/templates/rb_set.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/main/canvas_item.h"
#ifndef PHYSICS_2D_DISABLED
#include "scene/resources/2d/convex_polygon_shape_2d.h"
#endif // PHYSICS_2D_DISABLED
#include "scene/resources/2d/navigation_polygon.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/packed_scene.h"
#include "scene/resources/physics_material.h"
#ifndef PHYSICS_2D_DISABLED
#include "scene/resources/2d/convex_polygon_shape_2d.h"
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
#include "scene/resources/2d/navigation_polygon.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef DISABLE_DEPRECATED
#include "scene/resources/shader.h"
#endif
@ -53,12 +57,6 @@ class TileSetSource;
class TileSetAtlasSource;
class TileData;
// Forward-declare the plugins.
class TileSetPlugin;
class TileSetPluginAtlasRendering;
class TileSetPluginAtlasPhysics;
class TileSetPluginAtlasNavigation;
union TileMapCell {
struct {
int16_t source_id;
@ -178,14 +176,18 @@ private:
int autotile_spacing = 0;
HashMap<Vector2i, int> autotile_bitmask_flags;
HashMap<Vector2i, Ref<OccluderPolygon2D>> autotile_occluder_map;
#ifndef NAVIGATION_2D_DISABLED
HashMap<Vector2i, Ref<NavigationPolygon>> autotile_navpoly_map;
#endif // NAVIGATION_2D_DISABLED
HashMap<Vector2i, int> autotile_priority_map;
HashMap<Vector2i, int> autotile_z_index_map;
Vector<CompatibilityShapeData> shapes;
Ref<OccluderPolygon2D> occluder;
Vector2 occluder_offset;
#ifndef NAVIGATION_2D_DISABLED
Ref<NavigationPolygon> navigation;
#endif // NAVIGATION_2D_DISABLED
Vector2 navigation_offset;
int z_index = 0;
};
@ -406,9 +408,6 @@ protected:
static void _bind_methods();
public:
// --- Plugins ---
Vector<TileSetPlugin *> get_tile_set_atlas_plugins() const;
// --- Accessors for TileSet data ---
// -- Shape and layout --
@ -481,6 +480,7 @@ public:
bool is_valid_terrain_peering_bit_for_mode(TileSet::TerrainMode p_terrain_mode, TileSet::CellNeighbor p_peering_bit) const;
bool is_valid_terrain_peering_bit(int p_terrain_set, TileSet::CellNeighbor p_peering_bit) const;
#ifndef NAVIGATION_2D_DISABLED
// Navigation
int get_navigation_layers_count() const;
void add_navigation_layer(int p_index = -1);
@ -490,6 +490,7 @@ public:
uint32_t get_navigation_layer_layers(int p_layer_index) const;
void set_navigation_layer_layer_value(int p_layer_index, int p_layer_number, bool p_value);
bool get_navigation_layer_layer_value(int p_layer_index, int p_layer_number) const;
#endif // NAVIGATION_2D_DISABLED
// Custom data
int get_custom_data_layers_count() const;
@ -704,9 +705,11 @@ public:
virtual void add_terrain(int p_terrain_set, int p_index) override;
virtual void move_terrain(int p_terrain_set, int p_from_index, int p_to_pos) override;
virtual void remove_terrain(int p_terrain_set, int p_index) override;
#ifndef NAVIGATION_2D_DISABLED
virtual void add_navigation_layer(int p_index) override;
virtual void move_navigation_layer(int p_from_index, int p_to_pos) override;
virtual void remove_navigation_layer(int p_index) override;
#endif // NAVIGATION_2D_DISABLED
virtual void add_custom_data_layer(int p_index) override;
virtual void move_custom_data_layer(int p_from_index, int p_to_pos) override;
virtual void remove_custom_data_layer(int p_index) override;
@ -886,12 +889,14 @@ private:
int terrain = -1;
int terrain_peering_bits[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
#ifndef NAVIGATION_2D_DISABLED
// Navigation
struct NavigationLayerTileData {
Ref<NavigationPolygon> navigation_polygon;
mutable HashMap<int, Ref<NavigationPolygon>> transformed_navigation_polygon;
};
Vector<NavigationLayerTileData> navigation;
#endif // NAVIGATION_2D_DISABLED
// Misc
double probability = 1.0;
@ -906,7 +911,9 @@ protected:
static void _bind_methods();
#ifndef DISABLE_DEPRECATED
#ifndef NAVIGATION_2D_DISABLED
Ref<NavigationPolygon> _get_navigation_polygon_bind_compat_84660(int p_layer_id) const;
#endif // NAVIGATION_2D_DISABLED
Ref<OccluderPolygon2D> _get_occluder_bind_compat_84660(int p_layer_id) const;
static void _bind_compatibility_methods();
@ -1004,9 +1011,11 @@ public:
TileSet::TerrainsPattern get_terrains_pattern() const; // Not exposed.
#ifndef NAVIGATION_2D_DISABLED
// Navigation
void set_navigation_polygon(int p_layer_id, Ref<NavigationPolygon> p_navigation_polygon);
Ref<NavigationPolygon> get_navigation_polygon(int p_layer_id, bool p_flip_h = false, bool p_flip_v = false, bool p_transpose = false) const;
#endif // NAVIGATION_2D_DISABLED
// Misc
void set_probability(float p_probability);

View File

@ -6,7 +6,6 @@ Import("env")
env.add_source_files(env.scene_sources, "fog_material.cpp")
env.add_source_files(env.scene_sources, "importer_mesh.cpp")
env.add_source_files(env.scene_sources, "mesh_library.cpp")
env.add_source_files(env.scene_sources, "navigation_mesh_source_geometry_data_3d.cpp")
env.add_source_files(env.scene_sources, "primitive_meshes.cpp")
env.add_source_files(env.scene_sources, "skin.cpp")
env.add_source_files(env.scene_sources, "sky_material.cpp")
@ -25,3 +24,5 @@ if not env["disable_physics_3d"]:
env.add_source_files(env.scene_sources, "shape_3d.cpp")
env.add_source_files(env.scene_sources, "sphere_shape_3d.cpp")
env.add_source_files(env.scene_sources, "world_boundary_shape_3d.cpp")
if not env["disable_navigation_3d"]:
env.add_source_files(env.scene_sources, "navigation_mesh_source_geometry_data_3d.cpp")

View File

@ -32,9 +32,12 @@
#include "core/config/project_settings.h"
#include "scene/2d/visible_on_screen_notifier_2d.h"
#include "servers/navigation_server_2d.h"
#include "servers/rendering_server.h"
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
RID World2D::get_canvas() const {
return canvas;
}
@ -53,6 +56,7 @@ RID World2D::get_space() const {
}
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
RID World2D::get_navigation_map() const {
if (navigation_map.is_null()) {
navigation_map = NavigationServer2D::get_singleton()->map_create();
@ -64,6 +68,7 @@ RID World2D::get_navigation_map() const {
}
return navigation_map;
}
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
@ -73,14 +78,18 @@ PhysicsDirectSpaceState2D *World2D::get_direct_space_state() {
void World2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_canvas"), &World2D::get_canvas);
#ifndef NAVIGATION_2D_DISABLED
ClassDB::bind_method(D_METHOD("get_navigation_map"), &World2D::get_navigation_map);
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
ClassDB::bind_method(D_METHOD("get_space"), &World2D::get_space);
ClassDB::bind_method(D_METHOD("get_direct_space_state"), &World2D::get_direct_space_state);
#endif // PHYSICS_2D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::RID, "canvas", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_canvas");
#ifndef NAVIGATION_2D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::RID, "navigation_map", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_navigation_map");
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
ADD_PROPERTY(PropertyInfo(Variant::RID, "space", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_space");
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "direct_space_state", PROPERTY_HINT_RESOURCE_TYPE, "PhysicsDirectSpaceState2D", PROPERTY_USAGE_NONE), "", "get_direct_space_state");
@ -104,14 +113,19 @@ World2D::~World2D() {
#ifndef PHYSICS_2D_DISABLED
ERR_FAIL_NULL(PhysicsServer2D::get_singleton());
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
ERR_FAIL_NULL(NavigationServer2D::get_singleton());
#endif // NAVIGATION_2D_DISABLED
RenderingServer::get_singleton()->free(canvas);
#ifndef PHYSICS_2D_DISABLED
if (space.is_valid()) {
PhysicsServer2D::get_singleton()->free(space);
}
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
if (navigation_map.is_valid()) {
NavigationServer2D::get_singleton()->free(navigation_map);
}
#endif // NAVIGATION_2D_DISABLED
}

View File

@ -45,7 +45,9 @@ class World2D : public Resource {
RID canvas;
mutable RID space;
#ifndef NAVIGATION_2D_DISABLED
mutable RID navigation_map;
#endif // NAVIGATION_2D_DISABLED
HashSet<Viewport *> viewports;
@ -55,7 +57,9 @@ protected:
public:
RID get_canvas() const;
#ifndef NAVIGATION_2D_DISABLED
RID get_navigation_map() const;
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
RID get_space() const;

View File

@ -3,4 +3,10 @@ from misc.utility.scons_hints import *
Import("env")
env.add_source_files(env.servers_sources, "*.cpp")
if not env["disable_navigation_2d"]:
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_2d.cpp")
env.add_source_files(env.servers_sources, "navigation_path_query_result_2d.cpp")
if not env["disable_navigation_3d"]:
env.add_source_files(env.servers_sources, "navigation_path_query_parameters_3d.cpp")
env.add_source_files(env.servers_sources, "navigation_path_query_result_3d.cpp")

View File

@ -80,15 +80,19 @@
#include "text_server.h"
// 2D physics and navigation.
#ifndef NAVIGATION_2D_DISABLED
#include "navigation_server_2d.h"
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_2D_DISABLED
#include "physics_server_2d.h"
#include "physics_server_2d_dummy.h"
#include "servers/extensions/physics_server_2d_extension.h"
#endif // PHYSICS_2D_DISABLED
// 3D physics and navigation (3D navigation is needed for 2D).
// 3D physics and navigation.
#ifndef NAVIGATION_3D_DISABLED
#include "navigation_server_3d.h"
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
#include "physics_server_3d.h"
#include "physics_server_3d_dummy.h"
@ -282,9 +286,11 @@ void register_server_types() {
PhysicsServer2DManager::get_singleton()->register_server("Dummy", callable_mp_static(_create_dummy_physics_server_2d));
#endif // PHYSICS_2D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer2D);
GDREGISTER_CLASS(NavigationPathQueryParameters2D);
GDREGISTER_CLASS(NavigationPathQueryResult2D);
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
// Physics 3D
@ -330,9 +336,11 @@ void register_server_types() {
GDREGISTER_ABSTRACT_CLASS(XRTracker);
#endif // XR_DISABLED
#ifndef NAVIGATION_3D_DISABLED
GDREGISTER_ABSTRACT_CLASS(NavigationServer3D);
GDREGISTER_CLASS(NavigationPathQueryParameters3D);
GDREGISTER_CLASS(NavigationPathQueryResult3D);
#endif // NAVIGATION_3D_DISABLED
writer_mjpeg = memnew(MovieWriterMJPEG);
MovieWriter::add_writer(writer_mjpeg);
@ -361,8 +369,12 @@ void register_server_singletons() {
Engine::get_singleton()->add_singleton(Engine::Singleton("CameraServer", CameraServer::get_singleton(), "CameraServer"));
Engine::get_singleton()->add_singleton(Engine::Singleton("DisplayServer", DisplayServer::get_singleton(), "DisplayServer"));
Engine::get_singleton()->add_singleton(Engine::Singleton("NativeMenu", NativeMenu::get_singleton(), "NativeMenu"));
#ifndef NAVIGATION_2D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer2D", NavigationServer2D::get_singleton(), "NavigationServer2D"));
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("NavigationServer3D", NavigationServer3D::get_singleton(), "NavigationServer3D"));
#endif // NAVIGATION_3D_DISABLED
Engine::get_singleton()->add_singleton(Engine::Singleton("RenderingServer", RenderingServer::get_singleton(), "RenderingServer"));
#ifndef PHYSICS_2D_DISABLED

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/2d/navigation_agent_2d.h"
#include "scene/2d/navigation/navigation_agent_2d.h"
#include "scene/2d/node_2d.h"
#include "scene/main/window.h"
#include "scene/resources/world_2d.h"

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/3d/navigation_agent_3d.h"
#include "scene/3d/navigation/navigation_agent_3d.h"
#include "scene/3d/node_3d.h"
#include "scene/main/window.h"

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/2d/navigation_obstacle_2d.h"
#include "scene/2d/navigation/navigation_obstacle_2d.h"
#include "scene/main/window.h"
#include "tests/test_macros.h"

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/3d/navigation_obstacle_3d.h"
#include "scene/3d/navigation/navigation_obstacle_3d.h"
#include "scene/main/window.h"
#include "tests/test_macros.h"

View File

@ -30,7 +30,7 @@
#pragma once
#include "scene/2d/navigation_region_2d.h"
#include "scene/2d/navigation/navigation_region_2d.h"
#include "scene/main/window.h"
#include "tests/test_macros.h"

View File

@ -31,7 +31,7 @@
#pragma once
#include "scene/3d/mesh_instance_3d.h"
#include "scene/3d/navigation_region_3d.h"
#include "scene/3d/navigation/navigation_region_3d.h"
#include "scene/main/window.h"
#include "scene/resources/3d/primitive_meshes.h"

View File

@ -135,9 +135,6 @@
#include "tests/scene/test_parallax_2d.h"
#include "tests/scene/test_path_2d.h"
#include "tests/scene/test_path_follow_2d.h"
#ifndef PHYSICS_3D_DISABLED
#include "tests/scene/test_physics_material.h"
#endif // PHYSICS_3D_DISABLED
#include "tests/scene/test_sprite_frames.h"
#include "tests/scene/test_style_box_texture.h"
#include "tests/scene/test_texture_progress_bar.h"
@ -163,27 +160,10 @@
#include "tests/scene/test_tree.h"
#endif // ADVANCED_GUI_DISABLED
#ifdef MODULE_NAVIGATION_2D_ENABLED
#include "tests/scene/test_navigation_agent_2d.h"
#include "tests/scene/test_navigation_obstacle_2d.h"
#include "tests/scene/test_navigation_region_2d.h"
#include "tests/servers/test_navigation_server_2d.h"
#endif // MODULE_NAVIGATION_2D_ENABLED
#ifndef _3D_DISABLED
#ifdef MODULE_NAVIGATION_3D_ENABLED
#include "tests/scene/test_navigation_agent_3d.h"
#include "tests/scene/test_navigation_obstacle_3d.h"
#include "tests/scene/test_navigation_region_3d.h"
#include "tests/servers/test_navigation_server_3d.h"
#endif // MODULE_NAVIGATION_3D_ENABLED
#include "tests/scene/test_arraymesh.h"
#include "tests/scene/test_camera_3d.h"
#include "tests/scene/test_gltf_document.h"
#ifndef PHYSICS_3D_DISABLED
#include "tests/scene/test_height_map_shape_3d.h"
#endif // PHYSICS_3D_DISABLED
#include "tests/scene/test_path_3d.h"
#include "tests/scene/test_path_follow_3d.h"
#include "tests/scene/test_primitives.h"
@ -191,16 +171,39 @@
#include "tests/scene/test_sky.h"
#endif // _3D_DISABLED
#ifndef PHYSICS_3D_DISABLED
#include "tests/scene/test_height_map_shape_3d.h"
#include "tests/scene/test_physics_material.h"
#endif // PHYSICS_3D_DISABLED
#ifdef MODULE_NAVIGATION_2D_ENABLED
#include "tests/scene/test_navigation_agent_2d.h"
#include "tests/scene/test_navigation_obstacle_2d.h"
#include "tests/scene/test_navigation_region_2d.h"
#include "tests/servers/test_navigation_server_2d.h"
#endif // MODULE_NAVIGATION_2D_ENABLED
#ifdef MODULE_NAVIGATION_3D_ENABLED
#include "tests/scene/test_navigation_agent_3d.h"
#include "tests/scene/test_navigation_obstacle_3d.h"
#include "tests/scene/test_navigation_region_3d.h"
#include "tests/servers/test_navigation_server_3d.h"
#endif // MODULE_NAVIGATION_3D_ENABLED
#include "modules/modules_tests.gen.h"
#include "tests/display_server_mock.h"
#include "tests/test_macros.h"
#include "scene/theme/theme_db.h"
#ifndef NAVIGATION_2D_DISABLED
#include "servers/navigation_server_2d.h"
#ifndef _3D_DISABLED
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
#include "servers/navigation_server_3d.h"
#endif // _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#ifndef PHYSICS_2D_DISABLED
#include "servers/physics_server_2d.h"
#include "servers/physics_server_2d_dummy.h"
@ -209,6 +212,7 @@
#include "servers/physics_server_3d.h"
#include "servers/physics_server_3d_dummy.h"
#endif // PHYSICS_3D_DISABLED
#include "servers/rendering/rendering_server_default.h"
int test_main(int argc, char *argv[]) {
@ -289,10 +293,13 @@ struct GodotTestCaseListener : public doctest::IReporter {
#ifndef PHYSICS_3D_DISABLED
PhysicsServer3D *physics_server_3d = nullptr;
#endif // PHYSICS_3D_DISABLED
#ifndef _3D_DISABLED
NavigationServer3D *navigation_server_3d = nullptr;
#endif // _3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
NavigationServer2D *navigation_server_2d = nullptr;
#endif // NAVIGATION_2D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
NavigationServer3D *navigation_server_3d = nullptr;
#endif // NAVIGATION_3D_DISABLED
void test_case_start(const doctest::TestCaseData &p_in) override {
reinitialize();
@ -341,10 +348,12 @@ struct GodotTestCaseListener : public doctest::IReporter {
#endif // PHYSICS_2D_DISABLED
ERR_PRINT_OFF;
#ifndef _3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
navigation_server_3d = NavigationServer3DManager::new_default_server();
#endif // _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
navigation_server_2d = NavigationServer2DManager::new_default_server();
#endif // NAVIGATION_2D_DISABLED
ERR_PRINT_ON;
memnew(InputMap);
@ -376,21 +385,23 @@ struct GodotTestCaseListener : public doctest::IReporter {
return;
}
#ifndef _3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
if (suite_name.contains("[Navigation3D]") && navigation_server_3d == nullptr) {
ERR_PRINT_OFF;
navigation_server_3d = NavigationServer3DManager::new_default_server();
ERR_PRINT_ON;
return;
}
#endif // _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
if (suite_name.contains("[Navigation2D]") && navigation_server_2d == nullptr) {
ERR_PRINT_OFF;
navigation_server_2d = NavigationServer2DManager::new_default_server();
ERR_PRINT_ON;
return;
}
#endif // NAVIGATION_2D_DISABLED
}
void test_case_end(const doctest::CurrentTestCaseStats &) override {
@ -420,17 +431,19 @@ struct GodotTestCaseListener : public doctest::IReporter {
memdelete(SceneTree::get_singleton());
}
#ifndef _3D_DISABLED
#ifndef NAVIGATION_3D_DISABLED
if (navigation_server_3d) {
memdelete(navigation_server_3d);
navigation_server_3d = nullptr;
}
#endif // _3D_DISABLED
#endif // NAVIGATION_3D_DISABLED
#ifndef NAVIGATION_2D_DISABLED
if (navigation_server_2d) {
memdelete(navigation_server_2d);
navigation_server_2d = nullptr;
}
#endif // NAVIGATION_2D_DISABLED
#ifndef PHYSICS_3D_DISABLED
if (physics_server_3d) {