From 087dea4b15f43adf824ccedd82773b41fdb0b4e1 Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Sat, 15 Nov 2025 12:02:43 +0000 Subject: [PATCH] `FTI` - `Camera2D` accepts resets only after entering tree --- scene/2d/camera_2d.cpp | 13 +++++++++---- scene/2d/camera_2d.h | 4 ++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/scene/2d/camera_2d.cpp b/scene/2d/camera_2d.cpp index 9288ade5493..78957460a3e 100644 --- a/scene/2d/camera_2d.cpp +++ b/scene/2d/camera_2d.cpp @@ -307,10 +307,12 @@ void Camera2D::_notification(int p_what) { } break; case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: { - // Force the limits etc. to update. - _interpolation_data.xform_curr = get_camera_transform(); - _interpolation_data.xform_prev = _interpolation_data.xform_curr; - _update_process_callback(); + if (_interpolation_data.accepting_resets) { + // Force the limits etc. to update. + _interpolation_data.xform_curr = get_camera_transform(); + _interpolation_data.xform_prev = _interpolation_data.xform_curr; + _update_process_callback(); + } } break; case NOTIFICATION_SUSPENDED: @@ -365,6 +367,8 @@ void Camera2D::_notification(int p_what) { _interpolation_data.xform_curr = get_camera_transform(); _interpolation_data.xform_prev = _interpolation_data.xform_curr; } + + _interpolation_data.accepting_resets = true; } break; case NOTIFICATION_EXIT_TREE: { @@ -375,6 +379,7 @@ void Camera2D::_notification(int p_what) { } viewport = nullptr; just_exited_tree = true; + _interpolation_data.accepting_resets = false; callable_mp(this, &Camera2D::_reset_just_exited).call_deferred(); } break; diff --git a/scene/2d/camera_2d.h b/scene/2d/camera_2d.h index ff1a894a7bd..b686d574e2b 100644 --- a/scene/2d/camera_2d.h +++ b/scene/2d/camera_2d.h @@ -108,6 +108,10 @@ protected: Transform2D xform_curr; Transform2D xform_prev; uint32_t last_update_physics_tick = UINT32_MAX; // Ensure tick 0 is detected as a change. + + // Camera2D can only call get_camera_transform() without flagging warnings after setting up viewports + // during NOTIFICATION_ENTER_TREE, so we reject resets outside this lifetime. + bool accepting_resets = false; } _interpolation_data; void _ensure_update_interpolation_data();