Skip to content

Commit

Permalink
Merge pull request #91706 from rburing/interpolate_parallax2d
Browse files Browse the repository at this point in the history
Fix Parallax2D physics interpolation
  • Loading branch information
akien-mga committed May 28, 2024
2 parents ac6f578 + efb6a1c commit 1e76e83
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,18 @@ void Camera2D::_update_scroll() {
if (is_current()) {
ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id));

Size2 screen_size = _get_camera_screen_size();

Transform2D xform;
if (is_physics_interpolated_and_enabled()) {
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 {
xform = get_camera_transform();
}

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 adj_screen_pos = camera_screen_center - (screen_size * 0.5);

Expand Down

0 comments on commit 1e76e83

Please sign in to comment.