MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _do_paste

Method _do_paste

modules/gridmap/editor/grid_map_editor_plugin.cpp:594–635  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594void GridMapEditor::_do_paste() {
595 int idx = options->get_popup()->get_item_index(MENU_OPTION_PASTE_SELECTS);
596 bool reselect = options->get_popup()->is_item_checked(idx);
597
598 Basis rot;
599 rot = node->get_basis_with_orthogonal_index(paste_indicator.orientation);
600
601 Vector3 ofs = paste_indicator.current - paste_indicator.click;
602 EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
603 undo_redo->create_action(TTR("GridMap Paste Selection"));
604
605 for (const ClipboardItem &item : clipboard_items) {
606 Vector3 position = rot.xform(item.grid_offset) + paste_indicator.begin + ofs;
607
608 Basis orm;
609 orm = node->get_basis_with_orthogonal_index(item.orientation);
610 orm = rot * orm;
611
612 undo_redo->add_do_method(node, "set_cell_item", position, item.cell_item, node->get_orthogonal_index_from_basis(orm));
613 undo_redo->add_undo_method(node, "set_cell_item", position, node->get_cell_item(position), node->get_cell_item_orientation(position));
614 }
615
616 if (reselect) {
617 // We need to rotate the paste_indicator to find the selection begin and end:
618 Vector3 temp_end = rot.xform(paste_indicator.end - paste_indicator.begin) + paste_indicator.begin + ofs;
619 Vector3 temp_begin = paste_indicator.begin + ofs;
620 // _set_selection expects that selection_begin is the corner closer to the origin:
621 for (int i = 0; i < 3; ++i) {
622 if (temp_begin[i] > temp_end[i]) {
623 float p = temp_begin[i];
624 temp_begin[i] = temp_end[i];
625 temp_end[i] = p;
626 }
627 }
628 undo_redo->add_do_method(this, "_set_selection", true, temp_begin, temp_end);
629 undo_redo->add_undo_method(this, "_set_selection", selection.active, selection.begin, selection.end);
630 }
631
632 undo_redo->commit_action();
633
634 _clear_clipboard_data();
635}
636
637void GridMapEditor::_show_viewports_transform_gizmo(bool p_value) {
638 Dictionary new_state;

Callers

nothing calls this directly

Calls 13

TTRFunction · 0.85
get_cell_itemMethod · 0.80
get_item_indexMethod · 0.45
get_popupMethod · 0.45
is_item_checkedMethod · 0.45
create_actionMethod · 0.45
xformMethod · 0.45
add_do_methodMethod · 0.45
add_undo_methodMethod · 0.45

Tested by

no test coverage detected