1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

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
79 changed files with 665 additions and 220 deletions

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: {
}