diff options
Diffstat (limited to 'main/main.cpp')
-rw-r--r-- | main/main.cpp | 68 |
1 files changed, 33 insertions, 35 deletions
diff --git a/main/main.cpp b/main/main.cpp index c492cfaad7..58782fa9c1 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */ /* */ /* Permission is hereby granted, free of charge, to any person obtaining */ /* a copy of this software and associated documentation files (the */ @@ -256,8 +256,8 @@ void finalize_navigation_server() { void Main::print_help(const char *p_binary) { print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - " + String(VERSION_WEBSITE)); OS::get_singleton()->print("Free and open source software under the terms of the MIT license.\n"); - OS::get_singleton()->print("(c) 2007-2020 Juan Linietsky, Ariel Manzur.\n"); - OS::get_singleton()->print("(c) 2014-2020 Godot Engine contributors.\n"); + OS::get_singleton()->print("(c) 2007-2021 Juan Linietsky, Ariel Manzur.\n"); + OS::get_singleton()->print("(c) 2014-2021 Godot Engine contributors.\n"); OS::get_singleton()->print("\n"); OS::get_singleton()->print("Usage: %s [options] [path to scene or 'project.godot' file]\n", p_binary); OS::get_singleton()->print("\n"); @@ -528,6 +528,11 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ClassDB::register_class<Performance>(); engine->add_singleton(Engine::Singleton("Performance", performance)); + // Only flush stdout in debug builds by default, as spamming `print()` will + // decrease performance if this is enabled. + GLOBAL_DEF("application/run/flush_stdout_on_print", false); + GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true); + GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); @@ -1121,11 +1126,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } #endif - // Only flush stdout in debug builds by default, as spamming `print()` will - // decrease performance if this is enabled. - GLOBAL_DEF("application/run/flush_stdout_on_print", false); - GLOBAL_DEF("application/run/flush_stdout_on_print.debug", true); - GLOBAL_DEF("logging/file_logging/enable_file_logging", false); // Only file logging by default on desktop platforms as logs can't be // accessed easily on mobile/Web platforms (if at all). @@ -2007,7 +2007,7 @@ bool Main::start() { script)); } - script_loop->set_init_script(script_res); + script_loop->set_initialize_script(script_res); main_loop = script_loop; } else { return false; @@ -2026,7 +2026,7 @@ bool Main::start() { DisplayServer::get_singleton()->alert("Error: Invalid MainLoop script base type: " + script_base); ERR_FAIL_V_MSG(false, vformat("The global class %s does not inherit from SceneTree or MainLoop.", main_loop_type)); } - script_loop->set_init_script(script_res); + script_loop->set_initialize_script(script_res); main_loop = script_loop; } } @@ -2422,7 +2422,7 @@ bool Main::is_iterating() { // For performance metrics. static uint64_t physics_process_max = 0; -static uint64_t idle_process_max = 0; +static uint64_t process_max = 0; bool Main::iteration() { //for now do not error on this @@ -2438,19 +2438,19 @@ bool Main::iteration() { uint64_t ticks_elapsed = ticks - last_ticks; int physics_fps = Engine::get_singleton()->get_iterations_per_second(); - float frame_slice = 1.0 / physics_fps; + float physics_step = 1.0 / physics_fps; float time_scale = Engine::get_singleton()->get_time_scale(); - MainFrameTime advance = main_timer_sync.advance(frame_slice, physics_fps); - double step = advance.idle_step; - double scaled_step = step * time_scale; + MainFrameTime advance = main_timer_sync.advance(physics_step, physics_fps); + double process_step = advance.process_step; + double scaled_step = process_step * time_scale; - Engine::get_singleton()->_frame_step = step; + Engine::get_singleton()->_process_step = process_step; Engine::get_singleton()->_physics_interpolation_fraction = advance.interpolation_fraction; uint64_t physics_process_ticks = 0; - uint64_t idle_process_ticks = 0; + uint64_t process_ticks = 0; frame += ticks_elapsed; @@ -2458,7 +2458,7 @@ bool Main::iteration() { static const int max_physics_steps = 8; if (fixed_fps == -1 && advance.physics_steps > max_physics_steps) { - step -= (advance.physics_steps - max_physics_steps) * frame_slice; + process_step -= (advance.physics_steps - max_physics_steps) * physics_step; advance.physics_steps = max_physics_steps; } @@ -2474,33 +2474,32 @@ bool Main::iteration() { PhysicsServer2D::get_singleton()->sync(); PhysicsServer2D::get_singleton()->flush_queries(); - if (OS::get_singleton()->get_main_loop()->iteration(frame_slice * time_scale)) { + if (OS::get_singleton()->get_main_loop()->physics_process(physics_step * time_scale)) { exit = true; break; } - NavigationServer3D::get_singleton_mut()->process(frame_slice * time_scale); + NavigationServer3D::get_singleton_mut()->process(physics_step * time_scale); message_queue->flush(); - PhysicsServer3D::get_singleton()->step(frame_slice * time_scale); + PhysicsServer3D::get_singleton()->step(physics_step * time_scale); PhysicsServer2D::get_singleton()->end_sync(); - PhysicsServer2D::get_singleton()->step(frame_slice * time_scale); + PhysicsServer2D::get_singleton()->step(physics_step * time_scale); message_queue->flush(); - physics_process_ticks = MAX(physics_process_ticks, OS::get_singleton()->get_ticks_usec() - - physics_begin); // keep the largest one for reference + 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; - uint64_t idle_begin = OS::get_singleton()->get_ticks_usec(); + uint64_t process_begin = OS::get_singleton()->get_ticks_usec(); - if (OS::get_singleton()->get_main_loop()->idle(step * time_scale)) { + if (OS::get_singleton()->get_main_loop()->process(process_step * time_scale)) { exit = true; } message_queue->flush(); @@ -2521,8 +2520,8 @@ bool Main::iteration() { } } - idle_process_ticks = OS::get_singleton()->get_ticks_usec() - idle_begin; - idle_process_max = MAX(idle_process_ticks, idle_process_max); + process_ticks = OS::get_singleton()->get_ticks_usec() - process_begin; + process_max = MAX(process_ticks, process_max); uint64_t frame_time = OS::get_singleton()->get_ticks_usec() - ticks; for (int i = 0; i < ScriptServer::get_language_count(); i++) { @@ -2532,11 +2531,11 @@ bool Main::iteration() { AudioServer::get_singleton()->update(); if (EngineDebugger::is_active()) { - EngineDebugger::get_singleton()->iteration(frame_time, idle_process_ticks, physics_process_ticks, frame_slice); + EngineDebugger::get_singleton()->iteration(frame_time, process_ticks, physics_process_ticks, physics_step); } frames++; - Engine::get_singleton()->_idle_frames++; + Engine::get_singleton()->_process_frames++; if (frame > 1000000) { if (editor || project_manager) { @@ -2548,9 +2547,9 @@ bool Main::iteration() { } Engine::get_singleton()->_fps = frames; - performance->set_process_time(USEC_TO_SEC(idle_process_max)); + performance->set_process_time(USEC_TO_SEC(process_max)); performance->set_physics_process_time(USEC_TO_SEC(physics_process_max)); - idle_process_max = 0; + process_max = 0; physics_process_max = 0; frame %= 1000000; @@ -2687,8 +2686,7 @@ void Main::cleanup() { //attempt to restart with arguments String exec = OS::get_singleton()->get_executable_path(); List<String> args = OS::get_singleton()->get_restart_on_exit_arguments(); - OS::ProcessID pid = 0; - OS::get_singleton()->execute(exec, args, false, &pid); + OS::get_singleton()->create_process(exec, args); OS::get_singleton()->set_restart_on_exit(false, List<String>()); //clear list (uses memory) } |