Make possible to undo rotation of selected GridMap cells.

This commit is contained in:
Michael Alexsander 2026-02-20 21:24:01 -03:00
parent 0df713417b
commit 513d869839
No known key found for this signature in database
GPG key ID: A9C91EE110F4EABA

View file

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