Browse Source

Fix TileMap editor drawing

the tile cursor did not follow the mouse cursor, and the tile grid was displayed wrong,
because the forward_canvas_draw_over_viewport function used the wrong xform and thus its
map_to_world is not the inverse of the mouse interactor world_to_map, making the tiles
draw from 0,0 of the screen instead of 0,0 of the tile map (which is in a different place)
the 8th mage 7 years ago
parent
commit
f7a9866417
1 changed files with 2 additions and 3 deletions
  1. 2 3
      editor/plugins/tile_map_editor_plugin.cpp

+ 2 - 3
editor/plugins/tile_map_editor_plugin.cpp

@@ -882,7 +882,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) {
 	if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree())
 	if (!node || !node->get_tileset().is_valid() || !node->is_visible_in_tree())
 		return false;
 		return false;
 
 
-	Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
+	Transform2D xform = canvas_item_editor->get_canvas_transform() * node->get_global_transform();
 	Transform2D xform_inv = xform.affine_inverse();
 	Transform2D xform_inv = xform.affine_inverse();
 
 
 	Ref<InputEventMouseButton> mb = p_event;
 	Ref<InputEventMouseButton> mb = p_event;
@@ -1396,8 +1396,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) {
 		return;
 		return;
 
 
 	Transform2D cell_xf = node->get_cell_transform();
 	Transform2D cell_xf = node->get_cell_transform();
-
-	Transform2D xform = p_overlay->get_canvas_transform() * node->get_global_transform();
+	Transform2D xform = CanvasItemEditor::get_singleton()->get_canvas_transform() * node->get_global_transform();
 	Transform2D xform_inv = xform.affine_inverse();
 	Transform2D xform_inv = xform.affine_inverse();
 
 
 	Size2 screen_size = p_overlay->get_size();
 	Size2 screen_size = p_overlay->get_size();