Prevent jitter in Parallax2D
This commit is contained in:
parent
1bd66af54c
commit
3f9bb59606
|
@ -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) {
|
void Parallax2D::_camera_moved(const Transform2D &p_transform, const Point2 &p_screen_offset, const Point2 &p_adj_screen_pos) {
|
||||||
if (!ignore_camera_scroll) {
|
if (!ignore_camera_scroll) {
|
||||||
if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
|
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 {
|
} else {
|
||||||
set_screen_offset(p_adj_screen_pos);
|
set_screen_offset(p_adj_screen_pos);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue