Repository: godotengine/godot
File: editor/scene/3d/node_3d_editor_plugin.cpp (C++)

Code before:
				r.origin = Basis(p_motion, p_extra).xform(p_original.origin - _edit.center) + _edit.center;
			}

			return r;
		}
		default: {
			ERR_FAIL_V_MSG(Transform3D(), "Invalid mode in '_compute_transform'");
		}
	}
}

void Node3DEditorViewport::_reset_transform(TransformType p_type) {
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Reset Transform"));
	Array selection = editor_selection->get_selected_nodes();

	for (int i = 0; i < selection.size(); i++) {
		Node3D *sp = Object::cast_to<Node3D>(selection[i]);
		if (!sp) {
			continue;
		}

		switch (p_type) {
			case TransformType::POSITION:
				undo_redo->add_undo_method(sp, "set_position", sp->get_position());
				sp->set_position(Vector3(0, 0, 0));
				break;
			case TransformType::ROTATION:
				undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation());
				sp->set_rotation(Vector3(0, 0, 0));
				break;
			case TransformType::SCALE:
				undo_redo->add_undo_method(sp, "set_scale", sp->get_scale());
				sp->set_scale(Vector3(1, 1, 1));
				break;
		}
	}
	undo_redo->commit_action();
}

void Node3DEditorViewport::_surface_mouse_enter() {
	if (Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
		return;
	}

	if (!surface->has_focus() && (!get_viewport()->gui_get_focus_owner() || !get_viewport()->gui_get_focus_owner()->is_text_field())) {
		surface->grab_focus();
	}
}

void Node3DEditorViewport::_surface_mouse_exit() {

Review comment (suggestion):
```suggestion
				undo_redo->add_do_method(sp, "set_position", Vector3());
```
Otherwise if you undo, you can't perform the action again.

Same everywhere else.

Code after:
				r.origin = Basis(p_motion, p_extra).xform(p_original.origin - _edit.center) + _edit.center;
			}

			return r;
		}
		default: {
			ERR_FAIL_V_MSG(Transform3D(), "Invalid mode in '_compute_transform'");
		}
	}
}

void Node3DEditorViewport::_reset_transform(TransformType p_type) {
	List<Node *> selection = editor_selection->get_full_selected_node_list();
	if (selection.is_empty()) {
		return;
	}
	EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
	undo_redo->create_action(TTR("Reset Transform"));
	for (Node *node : selection) {
		Node3D *sp = Object::cast_to<Node3D>(node);
		if (!sp) {
			continue;
		}

		switch (p_type) {
			case TransformType::POSITION:
				undo_redo->add_undo_method(sp, "set_position", sp->get_position());
				undo_redo->add_do_method(sp, "set_position", Vector3());
				break;
			case TransformType::ROTATION:
				undo_redo->add_undo_method(sp, "set_rotation", sp->get_rotation());
				undo_redo->add_do_method(sp, "set_rotation", Vector3());
				break;
			case TransformType::SCALE:
				undo_redo->add_undo_method(sp, "set_scale", sp->get_scale());
				undo_redo->add_do_method(sp, "set_scale", Vector3(1, 1, 1));
				break;
		}
	}
	undo_redo->commit_action();
}

void Node3DEditorViewport::_surface_mouse_enter() {
	if (Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
		return;
	}

	if (!surface->has_focus() && (!get_viewport()->gui_get_focus_owner() || !get_viewport()->gui_get_focus_owner()->is_text_field())) {
		surface->grab_focus();
	}
}