diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/main/main.cpp b/main/main.cpp index d91cc5c9bf..9076d110bd 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -571,8 +571,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph List<String>::Element *I = args.front(); - I = args.front(); - while (I) { I->get() = unescape_cmdline(I->get().strip_edges()); I = I->next(); @@ -1340,9 +1338,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph { window_vsync_mode = DisplayServer::VSyncMode(int(GLOBAL_DEF("display/window/vsync/vsync_mode", DisplayServer::VSyncMode::VSYNC_ENABLED))); } - Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF_BASIC("physics/common/physics_fps", 60)); - ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", - PropertyInfo(Variant::INT, "physics/common/physics_fps", + Engine::get_singleton()->set_physics_ticks_per_second(GLOBAL_DEF_BASIC("physics/common/physics_ticks_per_second", 60)); + ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_ticks_per_second", + PropertyInfo(Variant::INT, "physics/common/physics_ticks_per_second", PROPERTY_HINT_RANGE, "1,1000,1")); Engine::get_singleton()->set_physics_jitter_fix(GLOBAL_DEF("physics/common/physics_jitter_fix", 0.5)); Engine::get_singleton()->set_target_fps(GLOBAL_DEF("debug/settings/fps/force_fps", 0)); @@ -1352,6 +1350,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph PROPERTY_HINT_RANGE, "0,1000,1")); GLOBAL_DEF("debug/settings/stdout/print_fps", false); + GLOBAL_DEF("debug/settings/stdout/print_gpu_profile", false); GLOBAL_DEF("debug/settings/stdout/verbose_stdout", false); if (!OS::get_singleton()->_verbose_stdout) { // Not manually overridden. @@ -1591,7 +1590,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { rendering_server->init(); rendering_server->set_render_loop_enabled(!disable_render_loop); - if (profile_gpu) { + if (profile_gpu || (!editor && bool(GLOBAL_GET("debug/settings/stdout/print_gpu_profile")))) { rendering_server->set_print_gpu_profile(true); } @@ -1734,6 +1733,8 @@ Error Main::setup2(Thread::ID p_main_tid_override) { Input *id = Input::get_singleton(); 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)) && !(editor || project_manager)) { bool found_touchscreen = false; @@ -1966,7 +1967,7 @@ bool Main::start() { for (int i = 0; i < _doc_data_class_path_count; i++) { // Custom modules are always located by absolute path. String path = _doc_data_class_paths[i].path; - if (path.is_rel_path()) { + if (path.is_relative_path()) { path = doc_tool_path.plus_file(path); } String name = _doc_data_class_paths[i].name; @@ -2124,11 +2125,11 @@ bool Main::start() { if (!project_manager && !editor) { // game if (game_path != "" || script != "") { //autoload - Map<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); + OrderedHashMap<StringName, ProjectSettings::AutoloadInfo> autoloads = ProjectSettings::get_singleton()->get_autoload_list(); //first pass, add the constants so they exist before any script is loaded - for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) { - const ProjectSettings::AutoloadInfo &info = E->get(); + for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) { + const ProjectSettings::AutoloadInfo &info = E.get(); if (info.is_singleton) { for (int i = 0; i < ScriptServer::get_language_count(); i++) { @@ -2139,8 +2140,8 @@ bool Main::start() { //second pass, load into global constants List<Node *> to_add; - for (Map<StringName, ProjectSettings::AutoloadInfo>::Element *E = autoloads.front(); E; E = E->next()) { - const ProjectSettings::AutoloadInfo &info = E->get(); + for (OrderedHashMap<StringName, ProjectSettings::AutoloadInfo>::Element E = autoloads.front(); E; E = E.next()) { + const ProjectSettings::AutoloadInfo &info = E.get(); RES res = ResourceLoader::load(info.path); ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path); @@ -2200,7 +2201,7 @@ bool Main::start() { //standard helpers that can be changed from main config String stretch_mode = GLOBAL_DEF_BASIC("display/window/stretch/mode", "disabled"); - String stretch_aspect = GLOBAL_DEF_BASIC("display/window/stretch/aspect", "ignore"); + String stretch_aspect = GLOBAL_DEF_BASIC("display/window/stretch/aspect", "keep"); Size2i stretch_size = Size2i(GLOBAL_DEF_BASIC("display/window/size/width", 0), GLOBAL_DEF_BASIC("display/window/size/height", 0)); @@ -2239,6 +2240,10 @@ bool Main::start() { DisplayServer::get_singleton()->window_set_title(appname); #endif + // Define a very small minimum window size to prevent bugs such as GH-37242. + // It can still be overridden by the user in a script. + DisplayServer::get_singleton()->window_set_min_size(Size2i(64, 64)); + bool snap_controls = GLOBAL_DEF("gui/common/snap_controls_to_pixels", true); sml->get_root()->set_snap_controls_to_pixels(snap_controls); @@ -2259,7 +2264,7 @@ bool Main::start() { "display/window/stretch/mode", PROPERTY_HINT_ENUM, "disabled,canvas_items,viewport")); - GLOBAL_DEF_BASIC("display/window/stretch/aspect", "ignore"); + GLOBAL_DEF_BASIC("display/window/stretch/aspect", "keep"); ProjectSettings::get_singleton()->set_custom_property_info("display/window/stretch/aspect", PropertyInfo(Variant::STRING, "display/window/stretch/aspect", @@ -2441,6 +2446,7 @@ uint32_t Main::frames = 0; uint32_t Main::frame = 0; bool Main::force_redraw_requested = false; int Main::iterating = 0; +bool Main::agile_input_event_flushing = false; bool Main::is_iterating() { return iterating > 0; @@ -2463,12 +2469,12 @@ bool Main::iteration() { uint64_t ticks_elapsed = ticks - last_ticks; - int physics_fps = Engine::get_singleton()->get_iterations_per_second(); - float physics_step = 1.0 / physics_fps; + int physics_ticks_per_second = Engine::get_singleton()->get_physics_ticks_per_second(); + float physics_step = 1.0 / physics_ticks_per_second; float time_scale = Engine::get_singleton()->get_time_scale(); - MainFrameTime advance = main_timer_sync.advance(physics_step, physics_fps); + MainFrameTime advance = main_timer_sync.advance(physics_step, physics_ticks_per_second); double process_step = advance.process_step; double scaled_step = process_step * time_scale; @@ -2490,9 +2496,13 @@ bool Main::iteration() { bool exit = false; - Engine::get_singleton()->_in_physics = true; - for (int iters = 0; iters < advance.physics_steps; ++iters) { + if (Input::get_singleton()->is_using_input_buffering() && agile_input_event_flushing) { + Input::get_singleton()->flush_buffered_events(); + } + + Engine::get_singleton()->_in_physics = true; + uint64_t physics_begin = OS::get_singleton()->get_ticks_usec(); PhysicsServer3D::get_singleton()->sync(); @@ -2521,9 +2531,13 @@ bool Main::iteration() { physics_process_ticks = MAX(physics_process_ticks, OS::get_singleton()->get_ticks_usec() - physics_begin); // keep the largest one for reference physics_process_max = MAX(OS::get_singleton()->get_ticks_usec() - physics_begin, physics_process_max); Engine::get_singleton()->_physics_frames++; + + Engine::get_singleton()->_in_physics = false; } - Engine::get_singleton()->_in_physics = false; + if (Input::get_singleton()->is_using_input_buffering() && agile_input_event_flushing) { + Input::get_singleton()->flush_buffered_events(); + } uint64_t process_begin = OS::get_singleton()->get_ticks_usec(); @@ -2586,6 +2600,11 @@ bool Main::iteration() { iterating--; + // Needed for OSs using input buffering regardless accumulation (like Android) + if (Input::get_singleton()->is_using_input_buffering() && !agile_input_event_flushing) { + Input::get_singleton()->flush_buffered_events(); + } + if (fixed_fps != -1) { return exit; } |