From 6d60d92b8753ab4c4be67ec91d25d20a2e6c79a6 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 8 Jun 2021 19:52:48 +0200 Subject: [PATCH] Tweak the physics FPS property hint to only allow reasonable values Physics FPS above 1000 cause the whole project to slow down and are not very practical in the first place (since no CPU currently available can keep up). (cherry picked from commit 8f4ac7bc4a72ea76e27c7afea28760e041569465) --- doc/classes/Engine.xml | 1 + doc/classes/ProjectSettings.xml | 3 ++- main/main.cpp | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index e99c396993e..aeb42b3abd4 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -159,6 +159,7 @@ Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. + [b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics_jitter_fix] to [code]0[/code]. The desired frames per second. If the hardware cannot keep up, this setting may not be respected. A value of 0 means no limit. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 59054752212..140c95cabb4 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1047,7 +1047,8 @@ [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.iterations_per_second] instead. - Fix to improve physics jitter, specially on monitors where refresh rate is different than the physics FPS. + Controls how much physics ticks are synchronized with real time. For 0 or less, the ticks are synchronized. Such values are recommended for network games, where clock synchronization matters. Higher values cause higher deviation of in-game clock and real clock, but allows smoothing out framerate jitters. The default value of 0.5 should be fine for most; values above 2 could cause the game to react to dropped frames with a noticeable delay and are not recommended. + [b]Note:[/b] For best results, when using a custom physics interpolation solution, the physics jitter fix should be disabled by setting [member physics/common/physics_jitter_fix] to [code]0[/code]. [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_jitter_fix] instead. diff --git a/main/main.cpp b/main/main.cpp index a4231358610..74e6ae85a8d 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1169,10 +1169,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph } Engine::get_singleton()->set_iterations_per_second(GLOBAL_DEF("physics/common/physics_fps", 60)); - ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", PropertyInfo(Variant::INT, "physics/common/physics_fps", PROPERTY_HINT_RANGE, "1,120,1,or_greater")); + ProjectSettings::get_singleton()->set_custom_property_info("physics/common/physics_fps", PropertyInfo(Variant::INT, "physics/common/physics_fps", 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)); - ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/fps/force_fps", PropertyInfo(Variant::INT, "debug/settings/fps/force_fps", PROPERTY_HINT_RANGE, "0,120,1,or_greater")); + ProjectSettings::get_singleton()->set_custom_property_info("debug/settings/fps/force_fps", PropertyInfo(Variant::INT, "debug/settings/fps/force_fps", PROPERTY_HINT_RANGE, "0,1000,1")); GLOBAL_DEF("physics/common/enable_pause_aware_picking", false); GLOBAL_DEF("debug/settings/stdout/print_fps", false);