godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.14k stars 20.21k forks source link

Applying a canvas transform to the editor viewport doesn't apply to all node position markers #68215

Open berarma opened 1 year ago

berarma commented 1 year ago

Godot version

v4.0.beta3.official [01ae26d31]

System information

Debian GNU/Linux 11.5, Nvidia RTX 2070 Super (470.141.03)

Issue description

I'm applying a scale and translate transform to my viewport canvas in the editor. It works as intented except that markers for nodes that aren't selected don't scale and translate. When I select a node the position in the 2D editor is right, but when it's not selected it's shown where it would be if the viewport canvas hadn't been changed.

I expect the node position markers to not change position depending on the selected status. I'm trying to put a hires layer over the game that works in the editor too so I can add visual information about the nodes.

Steps to reproduce

See the attached project. Selecting node 1 and node 2 alternatively and their position marks change. When it's selected the position is right according to the transform applied, when it's unselected the position shown is that of the node without the transform.

Minimal reproduction project

test.zip

berarma commented 1 year ago

The transform is neither applied to the tilemap editor.

kleonc commented 1 year ago

The original issue is located in canvas_item_editor_plugin.cpp, by brief look many transform related calculations are not done properly in there (e.g. canvas transform is not taken into account, like observed in this example). The problem is it's 6k-lines file thus it's not so straightforward to understand how things work in there. And it's not like the canvas transform is skipped only in one place etc. Seems quite time consuming to investigate and fix it properly.

The transform is neither applied to the tilemap editor.

Do you mean everything is drawn ignoring the canvas transform set or just the editor stuff like grid etc.? Because in what you reported the problem is the editor stuff like position markers, lock/unlock markers, input/rects for picking etc. Canvas items themselves are drawn properly (e.g. sprites or custom drawing in _draw).

berarma commented 1 year ago

The original issue is located in canvas_item_editor_plugin.cpp, by brief look many transform related calculations are not done properly in there (e.g. canvas transform is not taken into account, like observed in this example). The problem is it's 6k-lines file thus it's not so straightforward to understand how things work in there. And it's not like the canvas transform is skipped only in one place etc. Seems quite time consuming to investigate and fix it properly.

OK. I understand. I hope someone can give it a check someday.

The transform is neither applied to the tilemap editor.

Do you mean everything is drawn ignoring the canvas transform set or just the editor stuff like grid etc.? Because in what you reported the problem is the editor stuff like position markers, lock/unlock markers, input/rects for picking etc. Canvas items themselves are drawn properly (e.g. sprites or custom drawing in _draw).

Yes, just the editor stuff, grids, etc. Tiles are shown correctly, same as sprites and drawings.

kleonc commented 1 year ago

Yes, just the editor stuff, grids, etc. Tiles are shown correctly, same as sprites and drawings.

Then it's the same issue, the TileMapEditorTilesPlugin is drawing its stuff according to a Control passed to it by the CanvasItemEditor (and CanvasItemEditor is not applying canvas transform to such control in the first place).