| 43 | #include "scene/main/viewport.h" |
| 44 | |
| 45 | void Camera2D::_update_scroll() { |
| 46 | if (!is_inside_tree() || !viewport) { |
| 47 | return; |
| 48 | } |
| 49 | |
| 50 | if (is_part_of_edited_scene()) { |
| 51 | queue_redraw(); |
| 52 | return; |
| 53 | } |
| 54 | |
| 55 | if (is_current()) { |
| 56 | ERR_FAIL_COND(custom_viewport && !ObjectDB::get_instance(custom_viewport_id)); |
| 57 | |
| 58 | Size2 screen_size = _get_camera_screen_size(); |
| 59 | |
| 60 | Transform2D xform; |
| 61 | if (is_physics_interpolated_and_enabled()) { |
| 62 | xform = _interpolation_data.xform_prev.interpolate_with(_interpolation_data.xform_curr, Engine::get_singleton()->get_physics_interpolation_fraction()); |
| 63 | camera_screen_center = xform.affine_inverse().xform(0.5 * screen_size); |
| 64 | } else { |
| 65 | xform = get_camera_transform(); |
| 66 | } |
| 67 | |
| 68 | viewport->set_canvas_transform(xform); |
| 69 | |
| 70 | Point2 screen_offset = (anchor_mode == ANCHOR_MODE_DRAG_CENTER ? (screen_size * 0.5) : Point2()); |
| 71 | Point2 adj_screen_pos = camera_screen_center - (screen_size * 0.5); |
| 72 | |
| 73 | /// @todo Remove xform and screen_offset when ParallaxBackground/ParallaxLayer is removed. |
| 74 | get_tree()->call_group(group_name, SNAME("_camera_moved"), xform, screen_offset, adj_screen_pos); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | #ifdef TOOLS_ENABLED |
| 79 | void Camera2D::_project_settings_changed() { |
nothing calls this directly
no test coverage detected