Stabilize snapping 2D transforms to pixel
Co-authored-by: Danni <34800072+KeyboardDanni@users.noreply.github.com>
This commit is contained in:
parent
4e990cd7e5
commit
35b640107f
|
@ -268,8 +268,9 @@ void AnimatedSprite2D::_notification(int p_what) {
|
|||
}
|
||||
|
||||
if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
|
||||
ofs = ofs.floor();
|
||||
ofs = ofs.round();
|
||||
}
|
||||
|
||||
Rect2 dst_rect(ofs, s);
|
||||
|
||||
if (hflip) {
|
||||
|
|
|
@ -99,7 +99,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.floor();
|
||||
dest_offset = dest_offset.round();
|
||||
}
|
||||
|
||||
r_dst_rect = Rect2(dest_offset, frame_size);
|
||||
|
@ -402,7 +402,7 @@ Rect2 Sprite2D::get_rect() const {
|
|||
}
|
||||
|
||||
if (get_viewport() && get_viewport()->is_snap_2d_transforms_to_pixel_enabled()) {
|
||||
ofs = ofs.floor();
|
||||
ofs = ofs.round();
|
||||
}
|
||||
|
||||
if (s == Size2(0, 0)) {
|
||||
|
|
|
@ -223,7 +223,7 @@ void RendererCanvasCull::_attach_canvas_item_for_draw(RendererCanvasCull::Item *
|
|||
}
|
||||
}
|
||||
|
||||
void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool p_allow_y_sort, uint32_t p_canvas_cull_mask) {
|
||||
void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2D &p_parent_xform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool p_allow_y_sort, uint32_t p_canvas_cull_mask) {
|
||||
Item *ci = p_canvas_item;
|
||||
|
||||
if (!ci->visible) {
|
||||
|
@ -248,10 +248,14 @@ void RendererCanvasCull::_cull_canvas_item(Item *p_canvas_item, const Transform2
|
|||
}
|
||||
|
||||
Transform2D xform = ci->xform;
|
||||
Transform2D parent_xform = p_parent_xform;
|
||||
|
||||
if (snapping_2d_transforms_to_pixel) {
|
||||
xform.columns[2] = xform.columns[2].floor();
|
||||
xform.columns[2] = xform.columns[2].round();
|
||||
parent_xform.columns[2] = parent_xform.columns[2].round();
|
||||
}
|
||||
xform = p_transform * xform;
|
||||
|
||||
xform = parent_xform * xform;
|
||||
|
||||
Rect2 global_rect = xform.xform(rect);
|
||||
global_rect.position += p_clip_rect.position;
|
||||
|
|
|
@ -188,7 +188,7 @@ public:
|
|||
|
||||
private:
|
||||
void _render_canvas_item_tree(RID p_to_render_target, Canvas::ChildItem *p_child_items, int p_child_item_count, Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, RendererCanvasRender::Light *p_lights, RendererCanvasRender::Light *p_directional_lights, RS::CanvasItemTextureFilter p_default_filter, RS::CanvasItemTextureRepeat p_default_repeat, bool p_snap_2d_vertices_to_pixel, uint32_t p_canvas_cull_mask, RenderingMethod::RenderInfo *r_render_info = nullptr);
|
||||
void _cull_canvas_item(Item *p_canvas_item, const Transform2D &p_transform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool p_allow_y_sort, uint32_t p_canvas_cull_mask);
|
||||
void _cull_canvas_item(Item *p_canvas_item, const Transform2D &p_parent_xform, const Rect2 &p_clip_rect, const Color &p_modulate, int p_z, RendererCanvasRender::Item **r_z_list, RendererCanvasRender::Item **r_z_last_list, Item *p_canvas_clip, Item *p_material_owner, bool p_allow_y_sort, uint32_t p_canvas_cull_mask);
|
||||
|
||||
static constexpr int z_range = RS::CANVAS_ITEM_Z_MAX - RS::CANVAS_ITEM_Z_MIN + 1;
|
||||
|
||||
|
|
|
@ -43,19 +43,11 @@ static Transform2D _canvas_get_transform(RendererViewport::Viewport *p_viewport,
|
|||
float scale = 1.0;
|
||||
if (p_viewport->canvas_map.has(p_canvas->parent)) {
|
||||
Transform2D c_xform = p_viewport->canvas_map[p_canvas->parent].transform;
|
||||
if (p_viewport->snap_2d_transforms_to_pixel) {
|
||||
c_xform.columns[2] = c_xform.columns[2].floor();
|
||||
}
|
||||
xf = xf * c_xform;
|
||||
scale = p_canvas->parent_scale;
|
||||
}
|
||||
|
||||
Transform2D c_xform = p_canvas_data->transform;
|
||||
|
||||
if (p_viewport->snap_2d_transforms_to_pixel) {
|
||||
c_xform.columns[2] = c_xform.columns[2].floor();
|
||||
}
|
||||
|
||||
xf = xf * c_xform;
|
||||
|
||||
if (scale != 1.0 && !RSG::canvas->disable_scale) {
|
||||
|
|
Loading…
Reference in New Issue