summaryrefslogtreecommitdiffstats
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-25 12:39:10 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-25 12:39:10 +0200
commit73bf121ceb8637c88d5ed4bb8721a1feda80dc42 (patch)
tree4672d32dd4b53a82c4ada16fc78c98a3f9487e1e /scene
parent70fede82c52998bc3fc7201d8406d21b4e8a6023 (diff)
parent3f9bb596064b0fb15ad2e5a6a59a9efd339a1974 (diff)
downloadredot-engine-73bf121ceb8637c88d5ed4bb8721a1feda80dc42.tar.gz
Merge pull request #93786 from alvinhochun/viewport-pixel-snap-fix
Apply "snap 2D transforms to pixel" to viewport
Diffstat (limited to 'scene')
-rw-r--r--scene/2d/parallax_2d.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/2d/parallax_2d.cpp b/scene/2d/parallax_2d.cpp
index fdb2d2cdd0..c6176390dc 100644
--- a/scene/2d/parallax_2d.cpp
+++ b/scene/2d/parallax_2d.cpp
@@ -83,7 +83,11 @@ void Parallax2D::_validate_property(PropertyInfo &p_property) const {
void Parallax2D::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset, const Point2 &p_adj_screen_pos) {
if (!ignore_camera_scroll) {
if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
- set_screen_offset((p_adj_screen_pos + Vector2(0.5, 0.5)).floor());
+ Size2 vps = get_viewport_rect().size;
+ Vector2 offset;
+ offset.x = ((int)vps.width % 2) ? 0.0 : 0.5;
+ offset.y = ((int)vps.height % 2) ? 0.0 : 0.5;
+ set_screen_offset((p_adj_screen_pos + offset).floor());
} else {
set_screen_offset(p_adj_screen_pos);
}