diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-02-12 06:55:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-12 06:55:03 +0100 |
commit | 6ac6bade0af42207ae33f3d44b5d70a9a9e3a1d4 (patch) | |
tree | c9d2e70a097fd9047386960f87de567b62cf526c /editor | |
parent | 948d95897c58d1940e3f76fa033d446def294637 (diff) | |
parent | eeb972faefc988833693faea77d81cc8d2d2d2b4 (diff) |
Merge pull request #36119 from YeldhamDev/tileeditor_concave_fixes
Fix problems with concave shapes in the TileSet editor
Diffstat (limited to 'editor')
-rw-r--r-- | editor/plugins/tile_set_editor_plugin.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/editor/plugins/tile_set_editor_plugin.cpp b/editor/plugins/tile_set_editor_plugin.cpp index 5700623f98..ce865510b4 100644 --- a/editor/plugins/tile_set_editor_plugin.cpp +++ b/editor/plugins/tile_set_editor_plugin.cpp @@ -1794,13 +1794,13 @@ void TileSetEditor::_on_tool_clicked(int p_tool) { Array sd = tileset->call("tile_get_shapes", get_current_tile()); if (convex.is_valid()) { - // Make concave + // Make concave. undo_redo->create_action(TTR("Make Polygon Concave")); Ref<ConcavePolygonShape2D> _concave = memnew(ConcavePolygonShape2D); edited_collision_shape = _concave; _set_edited_shape_points(_get_collision_shape_points(convex)); } else if (concave.is_valid()) { - // Make convex + // Make convex. undo_redo->create_action(TTR("Make Polygon Convex")); Ref<ConvexPolygonShape2D> _convex = memnew(ConvexPolygonShape2D); edited_collision_shape = _convex; @@ -1810,14 +1810,20 @@ void TileSetEditor::_on_tool_clicked(int p_tool) { if (sd[i].get("shape") == previous_shape) { undo_redo->add_undo_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd.duplicate()); sd.remove(i); - sd.insert(i, edited_collision_shape); - undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd); - undo_redo->add_do_method(this, "_select_edited_shape_coord"); - undo_redo->add_undo_method(this, "_select_edited_shape_coord"); - undo_redo->commit_action(); break; } } + + undo_redo->add_do_method(tileset.ptr(), "tile_set_shapes", get_current_tile(), sd); + if (tileset->tile_get_tile_mode(get_current_tile()) == TileSet::AUTO_TILE || tileset->tile_get_tile_mode(get_current_tile()) == TileSet::ATLAS_TILE) { + undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D(), false, edited_shape_coord); + } else { + undo_redo->add_do_method(tileset.ptr(), "tile_add_shape", get_current_tile(), edited_collision_shape, Transform2D()); + } + undo_redo->add_do_method(this, "_select_edited_shape_coord"); + undo_redo->add_undo_method(this, "_select_edited_shape_coord"); + undo_redo->commit_action(); + _update_toggle_shape_button(); workspace->update(); workspace_container->update(); @@ -1984,11 +1990,8 @@ void TileSetEditor::_set_edited_shape_points(const Vector<Vector2> &points) { } segments.push_back(points[points.size() - 1]); segments.push_back(points[0]); - concave->set_segments(segments); undo_redo->add_do_method(concave.ptr(), "set_segments", segments); undo_redo->add_undo_method(concave.ptr(), "set_segments", concave->get_segments()); - } else { - // Invalid shape } } |