From d73cdeb2487bbd21d2eb062a13d92199c85cda2f Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Sun, 3 Jun 2018 16:32:23 +0300 Subject: [PATCH] Fix bugs related to bad handling of rotated/translated shapes in tilemap Fixup #18529 and #12870 --- editor/plugins/tile_set_editor_plugin.cpp | 4 ++-- scene/2d/tile_map.cpp | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index c79cf020629..087c4293f16 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -123,10 +123,10 @@ void TileSetEditor::_import_node(Node *p_node, Ref p_library) { for (List::Element *E = shapes.front(); E; E = E->next()) { if (sb->is_shape_owner_disabled(E->get())) continue; - Transform2D shape_transform = sb->shape_owner_get_transform(E->get()); + Transform2D shape_transform = sb->get_transform() * sb->shape_owner_get_transform(E->get()); bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get()); - shape_transform[2] -= phys_offset - sb->get_transform().xform(shape_transform[2]); + shape_transform[2] -= phys_offset; for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index d88e148b2c0..439bc43f3da 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -466,10 +466,12 @@ void TileMap::_update_dirty_quadrants() { Transform2D xform; xform.set_origin(offset.floor()); - Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id, i); + Vector2 shape_ofs = shapes[i].shape_transform.get_origin(); _fix_cell_transform(xform, c, shape_ofs + center_ofs, s); + xform *= shapes[i].shape_transform.untranslated(); + if (debug_canvas_item.is_valid()) { vs->canvas_item_add_set_transform(debug_canvas_item, xform); shape->draw(debug_canvas_item, debug_collision_color);