diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/main.cpp | 81 | ||||
-rw-r--r-- | main/performance.cpp | 57 | ||||
-rw-r--r-- | main/performance.h | 12 |
3 files changed, 140 insertions, 10 deletions
diff --git a/main/main.cpp b/main/main.cpp index de00738c57..c5a9f94417 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -185,6 +185,7 @@ static bool init_maximized = false; static bool init_windowed = false; static bool init_always_on_top = false; static bool init_use_custom_pos = false; +static bool init_use_custom_screen = false; static Vector2 init_custom_pos; // Debug @@ -528,7 +529,11 @@ Error Main::test_setup() { } } if (text_driver_idx >= 0) { - TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx)); + Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(text_driver_idx); + TextServerManager::get_singleton()->set_primary_interface(ts); + if (ts->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) { + ts->load_support_data("res://" + ts->get_support_data_filename()); + } } else { ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface."); } @@ -969,6 +974,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph if (I->next()) { init_screen = I->next()->get().to_int(); + init_use_custom_screen = true; N = I->next()->next(); } else { @@ -1395,7 +1401,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph #ifdef TOOLS_ENABLED if (editor) { packed_data->set_disabled(true); - globals->set_disable_feature_overrides(true); Engine::get_singleton()->set_editor_hint(true); main_args.push_back("--editor"); if (!init_windowed) { @@ -1680,7 +1685,23 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph window_flags |= DisplayServer::WINDOW_FLAG_NO_FOCUS_BIT; } window_mode = (DisplayServer::WindowMode)(GLOBAL_GET("display/window/size/mode").operator int()); - init_screen = GLOBAL_GET("display/window/size/initial_screen").operator int(); + int initial_position_type = GLOBAL_GET("display/window/size/initial_position_type").operator int(); + if (initial_position_type == 0) { + if (!init_use_custom_pos) { + init_custom_pos = GLOBAL_GET("display/window/size/initial_position").operator Vector2i(); + init_use_custom_pos = true; + } + } else if (initial_position_type == 1) { + if (!init_use_custom_screen) { + init_screen = DisplayServer::SCREEN_PRIMARY; + init_use_custom_screen = true; + } + } else if (initial_position_type == 2) { + if (!init_use_custom_screen) { + init_screen = GLOBAL_GET("display/window/size/initial_screen").operator int(); + init_use_custom_screen = true; + } + } } GLOBAL_DEF("internationalization/locale/include_text_server_data", false); @@ -1688,10 +1709,21 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", true); OS::get_singleton()->_allow_layered = GLOBAL_DEF("display/window/per_pixel_transparency/allowed", false); +#ifdef TOOLS_ENABLED if (editor || project_manager) { - // The editor and project manager always detect and use hiDPI if needed + // The editor and project manager always detect and use hiDPI if needed. OS::get_singleton()->_allow_hidpi = true; + // Disable Vulkan overlays in editor, they cause various issues. + OS::get_singleton()->set_environment("DISABLE_MANGOHUD", "1"); // GH-57403. + OS::get_singleton()->set_environment("DISABLE_RTSS_LAYER", "1"); // GH-57937. + OS::get_singleton()->set_environment("DISABLE_VKBASALT", "1"); + } else { + // Re-allow using Vulkan overlays, disabled while using the editor. + OS::get_singleton()->unset_environment("DISABLE_MANGOHUD"); + OS::get_singleton()->unset_environment("DISABLE_RTSS_LAYER"); + OS::get_singleton()->unset_environment("DISABLE_VKBASALT"); } +#endif if (rtm == -1) { rtm = GLOBAL_DEF("rendering/driver/threads/thread_model", OS::RENDER_THREAD_SAFE); @@ -1930,6 +1962,9 @@ Error Main::setup2(Thread::ID p_main_tid_override) { window_position = &position; } + Color boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color); + DisplayServer::set_early_window_clear_color_override(true, boot_bg_color); + // rendering_driver now held in static global String in main and initialized in setup() Error err; display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_vsync_mode, window_flags, window_position, window_size, init_screen, err); @@ -2095,7 +2130,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { boot_logo->set_pixel(0, 0, Color(0, 0, 0, 0)); } - Color boot_bg_color = GLOBAL_DEF_BASIC("application/boot_splash/bg_color", boot_splash_bg_color); + Color boot_bg_color = GLOBAL_GET("application/boot_splash/bg_color"); #if defined(TOOLS_ENABLED) && !defined(NO_EDITOR_SPLASH) boot_bg_color = @@ -2122,7 +2157,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { #endif } -#ifdef TOOLS_ENABLED +#if defined(TOOLS_ENABLED) && defined(MACOS_ENABLED) if (OS::get_singleton()->get_bundle_icon_path().is_empty()) { Ref<Image> icon = memnew(Image(app_icon_png)); DisplayServer::get_singleton()->set_icon(icon); @@ -2130,6 +2165,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) { #endif } + DisplayServer::set_early_window_clear_color_override(false); + MAIN_PRINT("Main: DCC"); RenderingServer::get_singleton()->set_default_clear_color( GLOBAL_GET("rendering/environment/defaults/default_clear_color")); @@ -2142,7 +2179,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { if (id) { agile_input_event_flushing = GLOBAL_DEF("input_devices/buffering/agile_event_flushing", false); - if (bool(GLOBAL_DEF("input_devices/pointing/emulate_touch_from_mouse", false)) && + if (bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_touch_from_mouse", false)) && !(editor || project_manager)) { if (!DisplayServer::get_singleton()->is_touchscreen_available()) { //only if no touchscreen ui hint, set emulation @@ -2150,7 +2187,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { } } - id->set_emulate_mouse_from_touch(bool(GLOBAL_DEF("input_devices/pointing/emulate_mouse_from_touch", true))); + id->set_emulate_mouse_from_touch(bool(GLOBAL_DEF_BASIC("input_devices/pointing/emulate_mouse_from_touch", true))); } MAIN_PRINT("Main: Load Translations and Remaps"); @@ -2215,7 +2252,11 @@ Error Main::setup2(Thread::ID p_main_tid_override) { } } if (text_driver_idx >= 0) { - TextServerManager::get_singleton()->set_primary_interface(TextServerManager::get_singleton()->get_interface(text_driver_idx)); + Ref<TextServer> ts = TextServerManager::get_singleton()->get_interface(text_driver_idx); + TextServerManager::get_singleton()->set_primary_interface(ts); + if (ts->has_feature(TextServer::FEATURE_USE_SUPPORT_DATA)) { + ts->load_support_data("res://" + ts->get_support_data_filename()); + } } else { ERR_FAIL_V_MSG(ERR_CANT_CREATE, "TextServer: Unable to create TextServer interface."); } @@ -2426,6 +2467,14 @@ bool Main::start() { ERR_FAIL_COND_V_MSG(da.is_null(), false, "Argument supplied to --doctool must be a valid directory path."); } +#ifndef MODULE_MONO_ENABLED + // Hack to define .NET-specific project settings even on non-.NET builds, + // so that we don't lose their descriptions and default values in DocTools. + // Default values should be synced with mono_gd/gd_mono.cpp. + GLOBAL_DEF("dotnet/project/assembly_name", ""); + GLOBAL_DEF("dotnet/project/solution_directory", ""); +#endif + Error err; DocTools doc; doc.generate(doc_base); @@ -2974,6 +3023,7 @@ bool Main::is_iterating() { // For performance metrics. static uint64_t physics_process_max = 0; static uint64_t process_max = 0; +static uint64_t navigation_process_max = 0; bool Main::iteration() { //for now do not error on this @@ -3002,6 +3052,7 @@ bool Main::iteration() { uint64_t physics_process_ticks = 0; uint64_t process_ticks = 0; + uint64_t navigation_process_ticks = 0; frame += ticks_elapsed; @@ -3034,12 +3085,20 @@ bool Main::iteration() { PhysicsServer2D::get_singleton()->flush_queries(); if (OS::get_singleton()->get_main_loop()->physics_process(physics_step * time_scale)) { + PhysicsServer3D::get_singleton()->end_sync(); + PhysicsServer2D::get_singleton()->end_sync(); + exit = true; break; } + uint64_t navigation_begin = OS::get_singleton()->get_ticks_usec(); + NavigationServer3D::get_singleton()->process(physics_step * time_scale); + 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(); PhysicsServer3D::get_singleton()->end_sync(); @@ -3118,8 +3177,10 @@ bool Main::iteration() { Engine::get_singleton()->_fps = frames; performance->set_process_time(USEC_TO_SEC(process_max)); performance->set_physics_process_time(USEC_TO_SEC(physics_process_max)); + performance->set_navigation_process_time(USEC_TO_SEC(navigation_process_max)); process_max = 0; physics_process_max = 0; + navigation_process_max = 0; frame %= 1000000; frames = 0; @@ -3150,10 +3211,12 @@ bool Main::iteration() { auto_build_solutions = false; // Only relevant when running the editor. if (!editor) { + OS::get_singleton()->set_exit_code(EXIT_FAILURE); ERR_FAIL_V_MSG(true, "Command line option --build-solutions was passed, but no project is being edited. Aborting."); } if (!EditorNode::get_singleton()->call_build()) { + OS::get_singleton()->set_exit_code(EXIT_FAILURE); ERR_FAIL_V_MSG(true, "Command line option --build-solutions was passed, but the build callback failed. Aborting."); } diff --git a/main/performance.cpp b/main/performance.cpp index c2624c708f..e24a3673b9 100644 --- a/main/performance.cpp +++ b/main/performance.cpp @@ -36,6 +36,7 @@ #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "servers/audio_server.h" +#include "servers/navigation_server_3d.h" #include "servers/physics_server_2d.h" #include "servers/physics_server_3d.h" #include "servers/rendering_server.h" @@ -54,6 +55,7 @@ void Performance::_bind_methods() { BIND_ENUM_CONSTANT(TIME_FPS); BIND_ENUM_CONSTANT(TIME_PROCESS); BIND_ENUM_CONSTANT(TIME_PHYSICS_PROCESS); + BIND_ENUM_CONSTANT(TIME_NAVIGATION_PROCESS); BIND_ENUM_CONSTANT(MEMORY_STATIC); BIND_ENUM_CONSTANT(MEMORY_STATIC_MAX); BIND_ENUM_CONSTANT(MEMORY_MESSAGE_BUFFER_MAX); @@ -74,7 +76,15 @@ void Performance::_bind_methods() { BIND_ENUM_CONSTANT(PHYSICS_3D_COLLISION_PAIRS); BIND_ENUM_CONSTANT(PHYSICS_3D_ISLAND_COUNT); BIND_ENUM_CONSTANT(AUDIO_OUTPUT_LATENCY); - + BIND_ENUM_CONSTANT(NAVIGATION_ACTIVE_MAPS); + BIND_ENUM_CONSTANT(NAVIGATION_REGION_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_AGENT_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_LINK_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_POLYGON_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_EDGE_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_EDGE_MERGE_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_EDGE_CONNECTION_COUNT); + BIND_ENUM_CONSTANT(NAVIGATION_EDGE_FREE_COUNT); BIND_ENUM_CONSTANT(MONITOR_MAX); } @@ -93,6 +103,7 @@ String Performance::get_monitor_name(Monitor p_monitor) const { "time/fps", "time/process", "time/physics_process", + "time/navigation_process", "memory/static", "memory/static_max", "memory/msg_buf_max", @@ -113,6 +124,15 @@ String Performance::get_monitor_name(Monitor p_monitor) const { "physics_3d/collision_pairs", "physics_3d/islands", "audio/driver/output_latency", + "navigation/active_maps", + "navigation/regions", + "navigation/agents", + "navigation/links", + "navigation/polygons", + "navigation/edges", + "navigation/edges_merged", + "navigation/edges_connected", + "navigation/edges_free", }; @@ -127,6 +147,8 @@ double Performance::get_monitor(Monitor p_monitor) const { return _process_time; case TIME_PHYSICS_PROCESS: return _physics_process_time; + case TIME_NAVIGATION_PROCESS: + return _navigation_process_time; case MEMORY_STATIC: return Memory::get_mem_usage(); case MEMORY_STATIC_MAX: @@ -167,6 +189,24 @@ double Performance::get_monitor(Monitor p_monitor) const { return PhysicsServer3D::get_singleton()->get_process_info(PhysicsServer3D::INFO_ISLAND_COUNT); case AUDIO_OUTPUT_LATENCY: return AudioServer::get_singleton()->get_output_latency(); + case NAVIGATION_ACTIVE_MAPS: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_ACTIVE_MAPS); + case NAVIGATION_REGION_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_REGION_COUNT); + case NAVIGATION_AGENT_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_AGENT_COUNT); + case NAVIGATION_LINK_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_LINK_COUNT); + case NAVIGATION_POLYGON_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_POLYGON_COUNT); + case NAVIGATION_EDGE_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_COUNT); + case NAVIGATION_EDGE_MERGE_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_MERGE_COUNT); + case NAVIGATION_EDGE_CONNECTION_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_CONNECTION_COUNT); + case NAVIGATION_EDGE_FREE_COUNT: + return NavigationServer3D::get_singleton()->get_process_info(NavigationServer3D::INFO_EDGE_FREE_COUNT); default: { } @@ -182,6 +222,7 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const MONITOR_TYPE_QUANTITY, MONITOR_TYPE_TIME, MONITOR_TYPE_TIME, + MONITOR_TYPE_TIME, MONITOR_TYPE_MEMORY, MONITOR_TYPE_MEMORY, MONITOR_TYPE_MEMORY, @@ -202,6 +243,15 @@ Performance::MonitorType Performance::get_monitor_type(Monitor p_monitor) const MONITOR_TYPE_QUANTITY, MONITOR_TYPE_QUANTITY, MONITOR_TYPE_TIME, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, + MONITOR_TYPE_QUANTITY, }; @@ -216,6 +266,10 @@ void Performance::set_physics_process_time(double p_pt) { _physics_process_time = p_pt; } +void Performance::set_navigation_process_time(double p_pt) { + _navigation_process_time = p_pt; +} + void Performance::add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args) { ERR_FAIL_COND_MSG(has_custom_monitor(p_id), "Custom monitor with id '" + String(p_id) + "' already exists."); _monitor_map.insert(p_id, MonitorCall(p_callable, p_args)); @@ -262,6 +316,7 @@ uint64_t Performance::get_monitor_modification_time() { Performance::Performance() { _process_time = 0; _physics_process_time = 0; + _navigation_process_time = 0; _monitor_modification_time = 0; singleton = this; } diff --git a/main/performance.h b/main/performance.h index 14695ab5a3..34162b2da9 100644 --- a/main/performance.h +++ b/main/performance.h @@ -50,6 +50,7 @@ class Performance : public Object { double _process_time; double _physics_process_time; + double _navigation_process_time; class MonitorCall { Callable _callable; @@ -69,6 +70,7 @@ public: TIME_FPS, TIME_PROCESS, TIME_PHYSICS_PROCESS, + TIME_NAVIGATION_PROCESS, MEMORY_STATIC, MEMORY_STATIC_MAX, MEMORY_MESSAGE_BUFFER_MAX, @@ -89,6 +91,15 @@ public: PHYSICS_3D_COLLISION_PAIRS, PHYSICS_3D_ISLAND_COUNT, AUDIO_OUTPUT_LATENCY, + NAVIGATION_ACTIVE_MAPS, + NAVIGATION_REGION_COUNT, + NAVIGATION_AGENT_COUNT, + NAVIGATION_LINK_COUNT, + NAVIGATION_POLYGON_COUNT, + NAVIGATION_EDGE_COUNT, + NAVIGATION_EDGE_MERGE_COUNT, + NAVIGATION_EDGE_CONNECTION_COUNT, + NAVIGATION_EDGE_FREE_COUNT, MONITOR_MAX }; @@ -105,6 +116,7 @@ public: void set_process_time(double p_pt); void set_physics_process_time(double p_pt); + void set_navigation_process_time(double p_pt); void add_custom_monitor(const StringName &p_id, const Callable &p_callable, const Vector<Variant> &p_args); void remove_custom_monitor(const StringName &p_id); |