Merge pull request #112810 from lawnjelly/fti_camera2d_accept_resets
`FTI` - `Camera2D` accepts resets only after entering tree
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user