summaryrefslogtreecommitdiff
path: root/scene/2d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d')
-rw-r--r--scene/2d/animated_sprite_2d.cpp3
-rw-r--r--scene/2d/sprite_2d.cpp6
2 files changed, 6 insertions, 3 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp
index 127748cdd5..0f98fad824 100644
--- a/scene/2d/animated_sprite_2d.cpp
+++ b/scene/2d/animated_sprite_2d.cpp
@@ -31,6 +31,7 @@
#include "animated_sprite_2d.h"
#include "core/os/os.h"
+#include "scene/main/viewport.h"
#include "scene/scene_string_names.h"
#ifdef TOOLS_ENABLED
@@ -443,7 +444,7 @@ void AnimatedSprite2D::_notification(int p_what) {
ofs -= s / 2;
}
- if (Engine::get_singleton()->get_use_pixel_snap()) {
+ if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.floor();
}
Rect2 dst_rect(ofs, s);
diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp
index c795ce9cf7..a065565a0f 100644
--- a/scene/2d/sprite_2d.cpp
+++ b/scene/2d/sprite_2d.cpp
@@ -99,7 +99,8 @@ void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_c
if (centered) {
dest_offset -= frame_size / 2;
}
- if (Engine::get_singleton()->get_use_pixel_snap()) {
+
+ if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
dest_offset = dest_offset.floor();
}
@@ -366,7 +367,8 @@ Rect2 Sprite2D::get_rect() const {
if (centered) {
ofs -= Size2(s) / 2;
}
- if (Engine::get_singleton()->get_use_pixel_snap()) {
+
+ if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.floor();
}