Order of 2D nodes in tree affects drawing properly again.
This commit is contained in:
parent
fb72edf45e
commit
57ebad28a9
|
@ -58,6 +58,12 @@ void VisualServerCanvas::_render_canvas_item(Item *p_canvas_item, const Transfor
|
|||
if (!ci->visible)
|
||||
return;
|
||||
|
||||
if (p_canvas_item->children_order_dirty) {
|
||||
|
||||
p_canvas_item->child_items.sort_custom<ItemIndexSort>();
|
||||
p_canvas_item->children_order_dirty = false;
|
||||
}
|
||||
|
||||
Rect2 rect = ci->get_rect();
|
||||
Transform2D xform = p_transform * ci->xform;
|
||||
Rect2 global_rect = xform.xform(rect);
|
||||
|
@ -171,6 +177,12 @@ void VisualServerCanvas::render_canvas(Canvas *p_canvas, const Transform2D &p_tr
|
|||
|
||||
VSG::canvas_render->canvas_begin();
|
||||
|
||||
if (p_canvas->children_order_dirty) {
|
||||
|
||||
p_canvas->child_items.sort();
|
||||
p_canvas->children_order_dirty = false;
|
||||
}
|
||||
|
||||
int l = p_canvas->child_items.size();
|
||||
Canvas::ChildItem *ci = p_canvas->child_items.ptr();
|
||||
|
||||
|
|
|
@ -63,6 +63,14 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct ItemIndexSort {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
|
||||
|
||||
return p_left->index < p_right->index;
|
||||
}
|
||||
};
|
||||
|
||||
struct ItemPtrSort {
|
||||
|
||||
_FORCE_INLINE_ bool operator()(const Item *p_left, const Item *p_right) const {
|
||||
|
|
Loading…
Reference in New Issue