Преглед на файлове

Merge pull request #53062 from stebulba/4.0_undo_CloseCurve

Rémi Verschelde преди 4 години
родител
ревизия
1979266a17
променени са 1 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 8 1
      editor/plugins/path_3d_editor_plugin.cpp

+ 8 - 1
editor/plugins/path_3d_editor_plugin.cpp

@@ -510,7 +510,14 @@ void Path3DEditorPlugin::_close_curve() {
 	if (c->get_point_count() < 2) {
 		return;
 	}
-	c->add_point(c->get_point_position(0), c->get_point_in(0), c->get_point_out(0));
+	if (c->get_point_position(0) == c->get_point_position(c->get_point_count() - 1)) {
+		return;
+	}
+	UndoRedo *ur = editor->get_undo_redo();
+	ur->create_action(TTR("Close Curve"));
+	ur->add_do_method(c.ptr(), "add_point", c->get_point_position(0), c->get_point_in(0), c->get_point_out(0), -1);
+	ur->add_undo_method(c.ptr(), "remove_point", c->get_point_count());
+	ur->commit_action();
 }
 
 void Path3DEditorPlugin::_handle_option_pressed(int p_option) {