summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorRicardo Buring <ricardo.buring@gmail.com>2024-02-17 00:57:32 +0100
committerRicardo Buring <ricardo.buring@gmail.com>2024-03-23 12:28:36 +0100
commit2ed2ccc2d8ff17b97d8ac0fd80fc0190ea47ed00 (patch)
tree0b0595cc3bf93413b4a394967ea96fde2f7cd3d3 /main
parentfe01776f05b1787b28b4a270d53037a3c25f4ca2 (diff)
downloadredot-engine-2ed2ccc2d8ff17b97d8ac0fd80fc0190ea47ed00.tar.gz
Fixed Timestep Interpolation (2D)
Adds fixed timestep interpolation to the rendering server (2D only). Switchable on and off with a project setting (default is off). Co-authored-by: lawnjelly <lawnjelly@gmail.com>
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp5
-rw-r--r--main/main_timer_sync.cpp11
2 files changed, 16 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 9215f2e848..f1ba25bf02 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -3967,6 +3967,11 @@ bool Main::iteration() {
PhysicsServer3D::get_singleton()->flush_queries();
#endif // _3D_DISABLED
+ // Prepare the fixed timestep interpolated nodes BEFORE they are updated
+ // by the physics server, otherwise the current and previous transforms
+ // may be the same, and no interpolation takes place.
+ OS::get_singleton()->get_main_loop()->iteration_prepare();
+
PhysicsServer2D::get_singleton()->sync();
PhysicsServer2D::get_singleton()->flush_queries();
diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp
index 569930d427..d358d9fa93 100644
--- a/main/main_timer_sync.cpp
+++ b/main/main_timer_sync.cpp
@@ -299,6 +299,17 @@ 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
double MainTimerSync::get_physics_jitter_fix() {
+ // Turn off jitter fix when using fixed timestep interpolation.
+ // Note this shouldn't be on UNTIL 3d interpolation is implemented,
+ // otherwise we will get people making 3d 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();
}