summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp169
-rw-r--r--main/main.h4
-rw-r--r--main/main_timer_sync.cpp76
-rw-r--r--main/main_timer_sync.h22
-rw-r--r--main/performance.cpp4
-rw-r--r--main/performance.h4
6 files changed, 181 insertions, 98 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 82be327cbb..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 */
@@ -70,8 +70,9 @@
#include "servers/physics_server_2d.h"
#include "servers/physics_server_3d.h"
#include "servers/register_server_types.h"
-#include "servers/rendering/rendering_server_raster.h"
+#include "servers/rendering/rendering_server_default.h"
#include "servers/rendering/rendering_server_wrap_mt.h"
+#include "servers/text_server.h"
#include "servers/xr_server.h"
#ifdef TESTS_ENABLED
@@ -80,8 +81,8 @@
#ifdef TOOLS_ENABLED
-#include "editor/doc_data.h"
#include "editor/doc_data_class_path.gen.h"
+#include "editor/doc_tools.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
#include "editor/progress_dialog.h"
@@ -113,6 +114,7 @@ static DisplayServer *display_server = nullptr;
static RenderingServer *rendering_server = nullptr;
static CameraServer *camera_server = nullptr;
static XRServer *xr_server = nullptr;
+static TextServerManager *tsman = nullptr;
static PhysicsServer3D *physics_server = nullptr;
static PhysicsServer2D *physics_2d_server = nullptr;
static NavigationServer3D *navigation_server = nullptr;
@@ -122,6 +124,8 @@ static bool _start_success = false;
// Drivers
+String text_driver = "";
+static int text_driver_idx = -1;
static int display_driver_idx = -1;
static int audio_driver_idx = -1;
@@ -252,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");
@@ -304,7 +308,11 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(")");
}
OS::get_singleton()->print("].\n");
+
OS::get_singleton()->print(" --rendering-driver <driver> Rendering driver (depends on display driver).\n");
+
+ OS::get_singleton()->print(" --text-driver <driver> Text driver (Fonts, BiDi, shaping)\n");
+
OS::get_singleton()->print("\n");
#ifndef SERVER_ENABLED
@@ -520,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"));
@@ -649,6 +662,14 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
OS::get_singleton()->print("Missing audio driver argument, aborting.\n");
goto error;
}
+ } else if (I->get() == "--text-driver") {
+ if (I->next()) {
+ text_driver = I->next()->get();
+ N = I->next()->next();
+ } else {
+ OS::get_singleton()->print("Missing text driver argument, aborting.\n");
+ goto error;
+ }
} else if (I->get() == "--display-driver") { // force video driver
@@ -1228,6 +1249,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
}
}
+ GLOBAL_DEF("display/window/force_right_to_left_layout_direction", false);
+
if (!force_lowdpi) {
OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false);
}
@@ -1388,6 +1411,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
error:
+ text_driver = "";
display_driver = "";
audio_driver = "";
tablet_driver = "";
@@ -1449,6 +1473,65 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
Thread::_main_thread_id = p_main_tid_override;
}
+ /* Determine text driver */
+
+ GLOBAL_DEF("display/window/text_name", "");
+ if (text_driver == "") {
+ text_driver = GLOBAL_GET("display/window/text_name");
+ }
+
+ if (text_driver != "") {
+ /* Load user selected text server. */
+ for (int i = 0; i < TextServerManager::get_interface_count(); i++) {
+ if (text_driver == TextServerManager::get_interface_name(i)) {
+ text_driver_idx = i;
+ break;
+ }
+ }
+ }
+
+ if (text_driver_idx < 0) {
+ /* If not selected, use one with the most features available. */
+ int max_features = 0;
+ for (int i = 0; i < TextServerManager::get_interface_count(); i++) {
+ uint32_t ftrs = TextServerManager::get_interface_features(i);
+ int features = 0;
+ while (ftrs) {
+ features += ftrs & 1;
+ ftrs >>= 1;
+ }
+ if (features >= max_features) {
+ max_features = features;
+ text_driver_idx = i;
+ }
+ }
+ }
+ printf("Using %s text server...\n", TextServerManager::get_interface_name(text_driver_idx).utf8().get_data());
+
+ /* Initialize Text Server */
+
+ {
+ tsman = memnew(TextServerManager);
+ Error err;
+ TextServer *text_server = TextServerManager::initialize(text_driver_idx, err);
+ if (err != OK || text_server == nullptr) {
+ for (int i = 0; i < TextServerManager::get_interface_count(); i++) {
+ if (i == text_driver_idx) {
+ continue; //don't try the same twice
+ }
+ text_server = TextServerManager::initialize(i, err);
+ if (err == OK && text_server != nullptr) {
+ break;
+ }
+ }
+ }
+
+ if (err != OK || text_server == nullptr) {
+ ERR_PRINT("Unable to create TextServer, all text drivers failed.");
+ return err;
+ }
+ }
+
/* Initialize Input */
input = memnew(Input);
@@ -1459,23 +1542,21 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
String rendering_driver; // temp broken
Error err;
- display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_flags,
- window_size, err);
- if (err != OK) {
+ display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_flags, window_size, err);
+ if (err != OK || display_server == nullptr) {
//ok i guess we can't use this display server, try other ones
for (int i = 0; i < DisplayServer::get_create_function_count(); i++) {
if (i == display_driver_idx) {
continue; //don't try the same twice
}
- display_server = DisplayServer::create(display_driver_idx, rendering_driver, window_mode, window_flags,
- window_size, err);
- if (err == OK) {
+ display_server = DisplayServer::create(i, rendering_driver, window_mode, window_flags, window_size, err);
+ if (err == OK && display_server != nullptr) {
break;
}
}
}
- if (!display_server || err != OK) {
+ if (err != OK || display_server == nullptr) {
ERR_PRINT("Unable to create DisplayServer, all display drivers failed.");
return err;
}
@@ -1487,7 +1568,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
/* Initialize Visual Server */
- rendering_server = memnew(RenderingServerRaster);
+ rendering_server = memnew(RenderingServerDefault);
if (OS::get_singleton()->get_render_thread_mode() != OS::RENDER_THREAD_UNSAFE) {
rendering_server = memnew(RenderingServerWrapMT(rendering_server,
OS::get_singleton()->get_render_thread_mode() ==
@@ -1838,10 +1919,10 @@ bool Main::start() {
GLOBAL_DEF("mono/project/auto_update_project", true);
#endif
- DocData doc;
+ DocTools doc;
doc.generate(doc_base);
- DocData docsrc;
+ DocTools docsrc;
Map<String, String> doc_data_classes;
Set<String> checked_paths;
print_line("Loading docs...");
@@ -1881,7 +1962,7 @@ bool Main::start() {
doc.merge_from(docsrc);
for (Set<String>::Element *E = checked_paths.front(); E; E = E->next()) {
print_line("Erasing old docs at: " + E->get());
- DocData::erase_classes(E->get());
+ DocTools::erase_classes(E->get());
}
print_line("Generating new docs...");
@@ -1926,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;
@@ -1945,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;
}
}
@@ -2341,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
@@ -2357,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;
@@ -2377,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;
}
@@ -2393,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();
@@ -2440,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++) {
@@ -2451,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) {
@@ -2467,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;
@@ -2572,6 +2652,10 @@ void Main::cleanup() {
finalize_navigation_server();
finalize_display();
+ if (tsman) {
+ memdelete(tsman);
+ }
+
if (input) {
memdelete(input);
}
@@ -2602,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)
}
diff --git a/main/main.h b/main/main.h
index 168b2e5e86..9e606c188d 100644
--- a/main/main.h
+++ b/main/main.h
@@ -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 */
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 5252ea005b..93448d0904 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.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 */
@@ -30,17 +30,17 @@
#include "main_timer_sync.h"
-void MainFrameTime::clamp_idle(float min_idle_step, float max_idle_step) {
- if (idle_step < min_idle_step) {
- idle_step = min_idle_step;
- } else if (idle_step > max_idle_step) {
- idle_step = max_idle_step;
+void MainFrameTime::clamp_process_step(float min_process_step, float max_process_step) {
+ if (process_step < min_process_step) {
+ process_step = min_process_step;
+ } else if (process_step > max_process_step) {
+ process_step = max_process_step;
}
}
/////////////////////////////////
-// returns the fraction of p_frame_slice required for the timer to overshoot
+// returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
float MainTimerSync::get_physics_jitter_fix() {
@@ -72,15 +72,15 @@ int MainTimerSync::get_average_physics_steps(float &p_min, float &p_max) {
return CONTROL_STEPS;
}
-// advance physics clock by p_idle_step, return appropriate number of steps to simulate
-MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_per_second, float p_idle_step) {
+// advance physics clock by p_process_step, return appropriate number of steps to simulate
+MainFrameTime MainTimerSync::advance_core(float p_physics_step, int p_physics_fps, float p_process_step) {
MainFrameTime ret;
- ret.idle_step = p_idle_step;
+ ret.process_step = p_process_step;
// simple determination of number of physics iteration
- time_accum += ret.idle_step;
- ret.physics_steps = floor(time_accum * p_iterations_per_second);
+ time_accum += ret.process_step;
+ ret.physics_steps = floor(time_accum * p_physics_fps);
int min_typical_steps = typical_physics_steps[0];
int max_typical_steps = min_typical_steps + 1;
@@ -107,7 +107,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
// try to keep it consistent with previous iterations
if (ret.physics_steps < min_typical_steps) {
- const int max_possible_steps = floor((time_accum)*p_iterations_per_second + get_physics_jitter_fix());
+ const int max_possible_steps = floor((time_accum)*p_physics_fps + get_physics_jitter_fix());
if (max_possible_steps < min_typical_steps) {
ret.physics_steps = max_possible_steps;
update_typical = true;
@@ -115,7 +115,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
ret.physics_steps = min_typical_steps;
}
} else if (ret.physics_steps > max_typical_steps) {
- const int min_possible_steps = floor((time_accum)*p_iterations_per_second - get_physics_jitter_fix());
+ const int min_possible_steps = floor((time_accum)*p_physics_fps - get_physics_jitter_fix());
if (min_possible_steps > max_typical_steps) {
ret.physics_steps = min_possible_steps;
update_typical = true;
@@ -124,7 +124,7 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
}
}
- time_accum -= ret.physics_steps * p_frame_slice;
+ time_accum -= ret.physics_steps * p_physics_step;
// keep track of accumulated step counts
for (int i = CONTROL_STEPS - 2; i >= 0; --i) {
@@ -146,52 +146,52 @@ MainFrameTime MainTimerSync::advance_core(float p_frame_slice, int p_iterations_
}
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
-MainFrameTime MainTimerSync::advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step) {
+MainFrameTime MainTimerSync::advance_checked(float p_physics_step, int p_physics_fps, float p_process_step) {
if (fixed_fps != -1) {
- p_idle_step = 1.0 / fixed_fps;
+ p_process_step = 1.0 / fixed_fps;
}
// compensate for last deficit
- p_idle_step += time_deficit;
+ p_process_step += time_deficit;
- MainFrameTime ret = advance_core(p_frame_slice, p_iterations_per_second, p_idle_step);
+ MainFrameTime ret = advance_core(p_physics_step, p_physics_fps, p_process_step);
- // we will do some clamping on ret.idle_step and need to sync those changes to time_accum,
+ // we will do some clamping on ret.process_step and need to sync those changes to time_accum,
// that's easiest if we just remember their fixed difference now
- const double idle_minus_accum = ret.idle_step - time_accum;
+ const double process_minus_accum = ret.process_step - time_accum;
- // first, least important clamping: keep ret.idle_step consistent with typical_physics_steps.
- // this smoothes out the idle steps and culls small but quick variations.
+ // first, least important clamping: keep ret.process_step consistent with typical_physics_steps.
+ // this smoothes out the process steps and culls small but quick variations.
{
float min_average_physics_steps, max_average_physics_steps;
int consistent_steps = get_average_physics_steps(min_average_physics_steps, max_average_physics_steps);
if (consistent_steps > 3) {
- ret.clamp_idle(min_average_physics_steps * p_frame_slice, max_average_physics_steps * p_frame_slice);
+ ret.clamp_process_step(min_average_physics_steps * p_physics_step, max_average_physics_steps * p_physics_step);
}
}
// second clamping: keep abs(time_deficit) < jitter_fix * frame_slise
- float max_clock_deviation = get_physics_jitter_fix() * p_frame_slice;
- ret.clamp_idle(p_idle_step - max_clock_deviation, p_idle_step + max_clock_deviation);
+ float max_clock_deviation = get_physics_jitter_fix() * p_physics_step;
+ ret.clamp_process_step(p_process_step - max_clock_deviation, p_process_step + max_clock_deviation);
- // last clamping: make sure time_accum is between 0 and p_frame_slice for consistency between physics and idle
- ret.clamp_idle(idle_minus_accum, idle_minus_accum + p_frame_slice);
+ // last clamping: make sure time_accum is between 0 and p_physics_step for consistency between physics and process
+ ret.clamp_process_step(process_minus_accum, process_minus_accum + p_physics_step);
// restore time_accum
- time_accum = ret.idle_step - idle_minus_accum;
+ time_accum = ret.process_step - process_minus_accum;
// track deficit
- time_deficit = p_idle_step - ret.idle_step;
+ time_deficit = p_process_step - ret.process_step;
- // p_frame_slice is 1.0 / iterations_per_sec
+ // p_physics_step is 1.0 / iterations_per_sec
// i.e. the time in seconds taken by a physics tick
- ret.interpolation_fraction = time_accum / p_frame_slice;
+ ret.interpolation_fraction = time_accum / p_physics_step;
return ret;
}
// determine wall clock step since last iteration
-float MainTimerSync::get_cpu_idle_step() {
+float MainTimerSync::get_cpu_process_step() {
uint64_t cpu_ticks_elapsed = current_cpu_ticks_usec - last_cpu_ticks_usec;
last_cpu_ticks_usec = current_cpu_ticks_usec;
@@ -219,9 +219,9 @@ void MainTimerSync::set_fixed_fps(int p_fixed_fps) {
fixed_fps = p_fixed_fps;
}
-// advance one frame, return timesteps to take
-MainFrameTime MainTimerSync::advance(float p_frame_slice, int p_iterations_per_second) {
- float cpu_idle_step = get_cpu_idle_step();
+// advance one physics frame, return timesteps to take
+MainFrameTime MainTimerSync::advance(float p_physics_step, int p_physics_fps) {
+ float cpu_process_step = get_cpu_process_step();
- return advance_checked(p_frame_slice, p_iterations_per_second, cpu_idle_step);
+ return advance_checked(p_physics_step, p_physics_fps, cpu_process_step);
}
diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h
index f8497140cd..884978bf96 100644
--- a/main/main_timer_sync.h
+++ b/main/main_timer_sync.h
@@ -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 */
@@ -34,11 +34,11 @@
#include "core/config/engine.h"
struct MainFrameTime {
- float idle_step; // time to advance idles for (argument to process())
+ float process_step; // delta time to advance during process()
int physics_steps; // number of times to iterate the physics engine
float interpolation_fraction; // fraction through the current physics tick
- void clamp_idle(float min_idle_step, float max_idle_step);
+ void clamp_process_step(float min_process_step, float max_process_step);
};
class MainTimerSync {
@@ -49,7 +49,7 @@ class MainTimerSync {
// logical game time since last physics timestep
float time_accum = 0;
- // current difference between wall clock time and reported sum of idle_steps
+ // current difference between wall clock time and reported sum of process_steps
float time_deficit = 0;
// number of frames back for keeping accumulated physics steps roughly constant.
@@ -67,7 +67,7 @@ class MainTimerSync {
int fixed_fps = 0;
protected:
- // returns the fraction of p_frame_slice required for the timer to overshoot
+ // returns the fraction of p_physics_step required for the timer to overshoot
// before advance_core considers changing the physics_steps return from
// the typical values as defined by typical_physics_steps
float get_physics_jitter_fix();
@@ -76,14 +76,14 @@ protected:
// return value: number of frames back this data is consistent
int get_average_physics_steps(float &p_min, float &p_max);
- // advance physics clock by p_idle_step, return appropriate number of steps to simulate
- MainFrameTime advance_core(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
+ // advance physics clock by p_process_step, return appropriate number of steps to simulate
+ MainFrameTime advance_core(float p_physics_step, int p_physics_fps, float p_process_step);
// calls advance_core, keeps track of deficit it adds to animaption_step, make sure the deficit sum stays close to zero
- MainFrameTime advance_checked(float p_frame_slice, int p_iterations_per_second, float p_idle_step);
+ MainFrameTime advance_checked(float p_physics_step, int p_physics_fps, float p_process_step);
// determine wall clock step since last iteration
- float get_cpu_idle_step();
+ float get_cpu_process_step();
public:
MainTimerSync();
@@ -96,7 +96,7 @@ public:
void set_fixed_fps(int p_fixed_fps);
// advance one frame, return timesteps to take
- MainFrameTime advance(float p_frame_slice, int p_iterations_per_second);
+ MainFrameTime advance(float p_physics_step, int p_physics_fps);
};
#endif // MAIN_TIMER_SYNC_H
diff --git a/main/performance.cpp b/main/performance.cpp
index 9de269ba5f..1a422dc499 100644
--- a/main/performance.cpp
+++ b/main/performance.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 */
diff --git a/main/performance.h b/main/performance.h
index 40f1d5cb05..122e5a4f9a 100644
--- a/main/performance.h
+++ b/main/performance.h
@@ -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 */