From b90f1a3ec042aa79d9f168cf0c6f72fc7f489e33 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Mon, 21 Feb 2022 10:32:42 +0000 Subject: [PATCH] Disable jitter fix when physics interpolation is enabled. --- doc/classes/ProjectSettings.xml | 3 ++- main/main_timer_sync.cpp | 11 ----------- scene/main/scene_tree.cpp | 7 +++++++ 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 0b64a6f24c3..9529b104f4b 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1159,7 +1159,8 @@ 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. + [b]Note:[/b] Jitter fix is automatically disabled at runtime when [member physics/common/physics_interpolation] is enabled. + [b]Note:[/b] This property is only read when the project starts. To change the value at runtime, set [member Engine.physics_jitter_fix] instead. [b]Experimental.[/b] Calls [code]glBufferData[/code] with NULL data prior to uploading batching data. This may not be necessary but can be used for safety. diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp index a4cd78e6dcb..0c1499e9abb 100644 --- a/main/main_timer_sync.cpp +++ b/main/main_timer_sync.cpp @@ -291,17 +291,6 @@ int64_t MainTimerSync::DeltaSmoother::smooth_delta(int64_t p_delta) { // 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() { - // Turn off jitter fix when using fixed timestep interpolation - // Note this shouldn't be on UNTIL 2d interpolation is implemented, - // otherwise we will get people making 2d games with the physics_interpolation - // set to on getting jitter fix disabled unexpectedly. -#if 0 - if (Engine::get_singleton()->is_physics_interpolation_enabled()) { - // would be better to write a simple bypass for jitter fix but this will do to get started - return 0.0; - } -#endif - return Engine::get_singleton()->get_physics_jitter_fix(); } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 1f047cfafa2..312a8d8488f 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -2097,7 +2097,14 @@ SceneTree::SceneTree() { if (!root->get_world().is_valid()) { root->set_world(Ref(memnew(World))); } + set_physics_interpolation_enabled(GLOBAL_DEF("physics/common/physics_interpolation", false)); + // Always disable jitter fix if physics interpolation is enabled - + // Jitter fix will interfere with interpolation, and is not necessary + // when interpolation is active. + if (is_physics_interpolation_enabled()) { + Engine::get_singleton()->set_physics_jitter_fix(0); + } // Initialize network state multiplayer_poll = true;