Fix Parallax2D fixed timestep interpolation

The camera_screen_center value was stale in case of interpolation.
This commit is contained in:
Ricardo Buring 2024-05-08 12:56:56 +02:00
parent be56cab58c
commit efb6a1c23d
1 changed files with 3 additions and 1 deletions

View File

@ -54,16 +54,18 @@ void Camera2D::_update_scroll() {
if (is_current()) { if (is_current()) {
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)); ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));
Size2 screen_size = _get_camera_screen_size();
Transform2D xform; Transform2D xform;
if (is_physics_interpolated_and_enabled()) { if (is_physics_interpolated_and_enabled()) {
xform = _interpolation_data.xform_prev.interpolate_with(_interpolation_data.xform_curr, Engine::get_singleton()->get_physics_interpolation_fraction()); xform = _interpolation_data.xform_prev.interpolate_with(_interpolation_data.xform_curr, Engine::get_singleton()->get_physics_interpolation_fraction());
camera_screen_center = xform.affine_inverse().xform(0.5 * screen_size);
} else { } else {
xform = get_camera_transform(); xform = get_camera_transform();
} }
viewport->set_canvas_transform(xform); viewport->set_canvas_transform(xform);
Size2 screen_size = _get_camera_screen_size();
Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2()); Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2());
Point2 adj_screen_pos = camera_screen_center - (screen_size * 0.5); Point2 adj_screen_pos = camera_screen_center - (screen_size * 0.5);