Merge pull request #112810 from lawnjelly/fti_camera2d_accept_resets

`FTI` - `Camera2D` accepts resets only after entering tree
This commit is contained in:
Thaddeus Crews
2025-11-25 09:52:26 -06:00
2 changed files with 13 additions and 4 deletions

View File

@ -307,10 +307,12 @@ void Camera2D::_notification(int p_what) {
} break; } break;
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: { case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
// Force the limits etc. to update. if (_interpolation_data.accepting_resets) {
_interpolation_data.xform_curr = get_camera_transform(); // Force the limits etc. to update.
_interpolation_data.xform_prev = _interpolation_data.xform_curr; _interpolation_data.xform_curr = get_camera_transform();
_update_process_callback(); _interpolation_data.xform_prev = _interpolation_data.xform_curr;
_update_process_callback();
}
} break; } break;
case NOTIFICATION_SUSPENDED: case NOTIFICATION_SUSPENDED:
@ -365,6 +367,8 @@ void Camera2D::_notification(int p_what) {
_interpolation_data.xform_curr = get_camera_transform(); _interpolation_data.xform_curr = get_camera_transform();
_interpolation_data.xform_prev = _interpolation_data.xform_curr; _interpolation_data.xform_prev = _interpolation_data.xform_curr;
} }
_interpolation_data.accepting_resets = true;
} break; } break;
case NOTIFICATION_EXIT_TREE: { case NOTIFICATION_EXIT_TREE: {
@ -375,6 +379,7 @@ void Camera2D::_notification(int p_what) {
} }
viewport = nullptr; viewport = nullptr;
just_exited_tree = true; just_exited_tree = true;
_interpolation_data.accepting_resets = false;
callable_mp(this, &Camera2D::_reset_just_exited).call_deferred(); callable_mp(this, &Camera2D::_reset_just_exited).call_deferred();
} break; } break;

View File

@ -108,6 +108,10 @@ protected:
Transform2D xform_curr; Transform2D xform_curr;
Transform2D xform_prev; Transform2D xform_prev;
uint32_t last_update_physics_tick = UINT32_MAX; // Ensure tick 0 is detected as a change. 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; } _interpolation_data;
void _ensure_update_interpolation_data(); void _ensure_update_interpolation_data();