Make possible to undo rotation of selected GridMap cells.
This commit is contained in:
parent
0df713417b
commit
513d869839
1 changed files with 8 additions and 1 deletions
|
|
@ -125,13 +125,20 @@ void GridMapEditor::_menu_option(int p_option) {
|
|||
paste_indicator.orientation = node->get_orthogonal_index_from_basis(r);
|
||||
_update_paste_indicator();
|
||||
} else if (_has_selection()) {
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(TTR("GridMap Rotate"));
|
||||
|
||||
Array cells = _get_selected_cells();
|
||||
for (int i = 0; i < cells.size(); i++) {
|
||||
Vector3i cell = cells[i];
|
||||
r = node->get_basis_with_orthogonal_index(node->get_cell_item_orientation(cell));
|
||||
r.rotate(rotation_axis, rotation_angle);
|
||||
node->set_cell_item(cell, node->get_cell_item(cell), node->get_orthogonal_index_from_basis(r));
|
||||
undo_redo->add_do_method(node, "set_cell_item", cell, node->get_cell_item(cell), node->get_orthogonal_index_from_basis(r));
|
||||
undo_redo->add_undo_method(node, "set_cell_item", cell, node->get_cell_item(cell), node->get_cell_item_orientation(cell));
|
||||
}
|
||||
|
||||
undo_redo->commit_action();
|
||||
|
||||
} else {
|
||||
r = node->get_basis_with_orthogonal_index(cursor_rot);
|
||||
r.rotate(rotation_axis, rotation_angle);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue