-Fix small bug regarding to canvas layer detection, closes #4381
(cherry picked from commit 2b9cab25c0
)
This commit is contained in:
parent
5a45b295ae
commit
bb8b57cbae
|
@ -455,19 +455,14 @@ void CanvasItem::_enter_canvas() {
|
||||||
if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
|
if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
|
||||||
|
|
||||||
Node *n = this;
|
Node *n = this;
|
||||||
Viewport *viewport=NULL;
|
|
||||||
canvas_layer=NULL;
|
canvas_layer=NULL;
|
||||||
|
|
||||||
while(n) {
|
while(n) {
|
||||||
|
|
||||||
if (n->cast_to<Viewport>()) {
|
canvas_layer = n->cast_to<CanvasLayer>();
|
||||||
|
if (canvas_layer) {
|
||||||
viewport = n->cast_to<Viewport>();
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!canvas_layer && n->cast_to<CanvasLayer>()) {
|
|
||||||
|
|
||||||
canvas_layer = n->cast_to<CanvasLayer>();
|
|
||||||
}
|
}
|
||||||
n=n->get_parent();
|
n=n->get_parent();
|
||||||
}
|
}
|
||||||
|
@ -476,7 +471,7 @@ void CanvasItem::_enter_canvas() {
|
||||||
if (canvas_layer)
|
if (canvas_layer)
|
||||||
canvas=canvas_layer->get_world_2d()->get_canvas();
|
canvas=canvas_layer->get_world_2d()->get_canvas();
|
||||||
else
|
else
|
||||||
canvas=viewport->find_world_2d()->get_canvas();
|
canvas=get_viewport()->find_world_2d()->get_canvas();
|
||||||
|
|
||||||
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);
|
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);
|
||||||
|
|
||||||
|
@ -487,7 +482,9 @@ void CanvasItem::_enter_canvas() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
CanvasItem *parent = get_parent_item();
|
CanvasItem *parent = get_parent_item();
|
||||||
|
canvas_layer=parent->canvas_layer;
|
||||||
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
|
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
|
||||||
parent->_queue_sort_children();
|
parent->_queue_sort_children();
|
||||||
}
|
}
|
||||||
|
@ -1176,12 +1173,10 @@ Matrix32 CanvasItem::get_viewport_transform() const {
|
||||||
return canvas_layer->get_transform();
|
return canvas_layer->get_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (get_viewport()) {
|
} else {
|
||||||
return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform();
|
return get_viewport()->get_final_transform() * get_viewport()->get_canvas_transform();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Matrix32();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue