Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pixel rounding with floor(x + 0.5) #93740

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scene/2d/animated_sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ void AnimatedSprite2D::_notification(int p_what) {
}

if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.round();
ofs = (ofs + Point2(0.5, 0.5)).floor();
}

Rect2 dst_rect(ofs, s);
Expand Down
4 changes: 2 additions & 2 deletions scene/2d/sprite_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void Sprite2D::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_c
}

if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
dest_offset = dest_offset.round();
dest_offset = (dest_offset + Point2(0.5, 0.5)).floor();
}

r_dst_rect = Rect2(dest_offset, frame_size);
Expand Down Expand Up @@ -400,7 +400,7 @@ Rect2 Sprite2D::get_rect() const {
}

if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
ofs = ofs.round();
ofs = (ofs + Point2(0.5, 0.5)).floor();
}

if (s == Size2(0, 0)) {
Expand Down
2 changes: 1 addition & 1 deletion scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@ int RichTextLabel::_draw_line(ItemFrame *p_frame, int p_line, const Vector2 &p_o
}

if (is_inside_tree() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
fx_offset = fx_offset.round();
fx_offset = (fx_offset + Point2(0.5, 0.5)).floor();
}

Vector2 char_off = char_xform.get_origin();
Expand Down
4 changes: 2 additions & 2 deletions servers/rendering/renderer_canvas_cull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2
}

if (snapping_2d_transforms_to_pixel) {
final_xform.columns[2] = final_xform.columns[2].round();
parent_xform.columns[2] = parent_xform.columns[2].round();
final_xform.columns[2] = (final_xform.columns[2] + Point2(0.5, 0.5)).floor();
parent_xform.columns[2] = (parent_xform.columns[2] + Point2(0.5, 0.5)).floor();
}

final_xform = parent_xform * final_xform;
Expand Down
Loading