diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index d86b82b72a11..52a22d4a3ad9 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -944,7 +944,8 @@ - A copy of the canvas item will be drawn with a local offset of the mirroring [Vector2]. + A copy of the canvas item will be drawn with a local offset of the [param mirroring]. + [b]Note:[/b] It is equivalent to calling [method canvas_set_item_repeat] like [code]canvas_set_item_repeat(item, mirroring, 1)[/code], with an additional check ensuring [param canvas] is a parent of [param item]. diff --git a/servers/rendering/renderer_canvas_cull.cpp b/servers/rendering/renderer_canvas_cull.cpp index ecdb19b4040f..97f98830c5b3 100644 --- a/servers/rendering/renderer_canvas_cull.cpp +++ b/servers/rendering/renderer_canvas_cull.cpp @@ -51,7 +51,7 @@ void RendererCanvasCull::_render_canvas_item_tree(RID p_to_render_target, Canvas memset(z_last_list, 0, z_range * sizeof(RendererCanvasRender::Item *)); for (int i = 0; i < p_child_item_count; i++) { - _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr, true, p_canvas_cull_mask, p_child_items[i].mirror, 1, nullptr); + _cull_canvas_item(p_child_items[i].item, p_transform, p_clip_rect, Color(1, 1, 1, 1), 0, z_list, z_last_list, nullptr, nullptr, true, p_canvas_cull_mask, Point2(), 1, nullptr); } RendererCanvasRender::Item *list = nullptr; @@ -453,7 +453,12 @@ void RendererCanvasCull::canvas_set_item_mirroring(RID p_canvas, RID p_item, con int idx = canvas->find_item(canvas_item); ERR_FAIL_COND(idx == -1); - canvas->child_items.write[idx].mirror = p_mirroring; + + bool is_repeat_source = (p_mirroring.x || p_mirroring.y); + canvas_item->repeat_source = is_repeat_source; + canvas_item->repeat_source_item = is_repeat_source ? canvas_item : nullptr; + canvas_item->repeat_size = p_mirroring; + canvas_item->repeat_times = 1; } void RendererCanvasCull::canvas_set_item_repeat(RID p_item, const Point2 &p_repeat_size, int p_repeat_times) { diff --git a/servers/rendering/renderer_canvas_cull.h b/servers/rendering/renderer_canvas_cull.h index ce71a0b427ab..91c03054f718 100644 --- a/servers/rendering/renderer_canvas_cull.h +++ b/servers/rendering/renderer_canvas_cull.h @@ -126,7 +126,6 @@ class RendererCanvasCull { struct Canvas : public RendererViewport::CanvasBase { HashSet viewports; struct ChildItem { - Point2 mirror; Item *item = nullptr; bool operator<(const ChildItem &p_item) const { return item->index < p_item.item->index;