1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Take CanvasLayer transform into account for 2D physics

Fixes #18073.
This commit is contained in:
Pedro J. Estébanez
2018-08-19 12:14:21 +02:00
parent 031f763d4f
commit 4839e5f6d9
6 changed files with 38 additions and 30 deletions

View File

@@ -29,6 +29,7 @@
/*************************************************************************/
#include "canvas_layer.h"
#include "scene/2d/canvas_item.h"
#include "viewport.h"
void CanvasLayer::set_layer(int p_xform) {
@@ -62,6 +63,24 @@ void CanvasLayer::_update_xform() {
transform.set_origin(ofs);
if (viewport.is_valid())
VisualServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
if (!is_inside_tree())
return;
_notify_xform(this);
}
void CanvasLayer::_notify_xform(Node *p_node) {
for (int i = 0; i < p_node->get_child_count(); i++) {
CanvasItem *ci = Object::cast_to<CanvasItem>(p_node->get_child(i));
if (ci) {
ci->_notify_transform(ci);
} else {
_notify_xform(p_node->get_child(i));
}
}
}
void CanvasLayer::_update_locrotscale() {