From 4d2642b666ad8bbb39a2c9e44cab221e8a4a7546 Mon Sep 17 00:00:00 2001 From: Bojidar Marinov Date: Sat, 1 Jul 2017 20:56:51 +0300 Subject: Readd tilemap's shape_transform and bugfixes This reverts commit a808f53020aa710ff81392e2349b8a39c55d2717. --- editor/plugins/tile_set_editor_plugin.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'editor') diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 70b6257bb..3563f70d0 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -90,9 +90,10 @@ void TileSetEditor::_import_node(Node *p_node, Ref p_library) { phys_offset += -s / 2; } - Vector > collisions; + Vector collisions; Ref nav_poly; Ref occluder; + bool found_collisions = false; for (int j = 0; j < mi->get_child_count(); j++) { @@ -106,24 +107,38 @@ void TileSetEditor::_import_node(Node *p_node, Ref p_library) { if (!child2->cast_to()) continue; + + found_collisions = true; + StaticBody2D *sb = child2->cast_to(); List shapes; sb->get_shape_owners(&shapes); for (List::Element *E = shapes.front(); E; E = E->next()) { + if (sb->is_shape_owner_disabled(E->get())) continue; - Vector2 shape_offset = sb->shape_owner_get_transform(E->get()).get_origin(); + Transform2D shape_transform = sb->shape_owner_get_transform(E->get()); bool one_way = sb->is_shape_owner_one_way_collision_enabled(E->get()); + shape_transform.set_origin(shape_transform.get_origin() - phys_offset); + for (int k = 0; k < sb->shape_owner_get_shape_count(E->get()); k++) { - Ref shape = sb->shape_owner_get_shape(E->get(), k); - p_library->tile_add_shape(id, shape, shape_offset, one_way); + Ref shape = sb->shape_owner_get_shape(E->get(), k); + TileSet::ShapeData shape_data; + shape_data.shape = shape; + shape_data.shape_transform = shape_transform; + shape_data.one_way_collision = one_way; + collisions.push_back(shape_data); } } } + if (found_collisions) { + p_library->tile_set_shapes(id, collisions); + } + p_library->tile_set_texture_offset(id, mi->get_offset()); p_library->tile_set_navigation_polygon(id, nav_poly); p_library->tile_set_light_occluder(id, occluder); -- cgit v1.2.3-70-g09d2