Fix bugs related to bad handling of rotated/translated shapes in tilemap

Fixup #18529 and #12870
This commit is contained in:
Bojidar Marinov 2018-06-03 16:32:23 +03:00
parent 8684b63118
commit d73cdeb248
No known key found for this signature in database
GPG key ID: 4D546A8F1E091856
2 changed files with 5 additions and 3 deletions

View file

@ -123,10 +123,10 @@ void TileSetEditor::_import_node(Node *p_node, Ref<TileSet> p_library) {
for (List<uint32_t>::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++) {

View file

@ -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);